From d74fd924513d636e0aa339d0774867f78250da33 Mon Sep 17 00:00:00 2001 From: Bernd Herzog Date: Sun, 16 Apr 2023 19:51:06 +0200 Subject: [PATCH] added dfu button to debug app --- firmware/application/apps/ui_debug.cpp | 7 ++++--- .../boards/PORTAPACK_APPLICATION/board.cpp | 3 +-- firmware/common/portapack_io.cpp | 8 ++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/firmware/application/apps/ui_debug.cpp b/firmware/application/apps/ui_debug.cpp index 4b402483..338891db 100644 --- a/firmware/application/apps/ui_debug.cpp +++ b/firmware/application/apps/ui_debug.cpp @@ -274,13 +274,14 @@ void ControlsSwitchesWidget::paint(Painter& painter) { { 32, 32, 16, 16 }, // Select { 16, 96, 16, 16 }, // Encoder phase 0 { 48, 96, 16, 16 }, // Encoder phase 1 - { 64, 0, 16, 16 }, // Dfu + { 80, 0, 16, 16 }, // Dfu } }; const auto pos = screen_pos(); auto switches_raw = control::debug::switches(); // all 7 + dfu auto switches_debounced = get_switches_state().to_ulong(); // stops at 5, 6 is dfu - switches_debounced = (switches_debounced & 0x1f) | ((switches_debounced >> 5) << 7); - auto switches_event = key_event_mask; + switches_debounced = (switches_debounced & 0x1f) | ((switches_debounced & 0x40) << 2); + auto switches_event = key_event_mask; // 5 keys, 6 is "back", 7 is dfu + key_event_mask = (key_event_mask & 0x1f) | ((key_event_mask & 0x80) << 1); for(const auto r : button_rects) { const auto c = diff --git a/firmware/chibios-portapack/boards/PORTAPACK_APPLICATION/board.cpp b/firmware/chibios-portapack/boards/PORTAPACK_APPLICATION/board.cpp index 294997a7..3a9aa622 100755 --- a/firmware/chibios-portapack/boards/PORTAPACK_APPLICATION/board.cpp +++ b/firmware/chibios-portapack/boards/PORTAPACK_APPLICATION/board.cpp @@ -508,8 +508,7 @@ static const std::array pins_setup_portapack { { { 2, 1, scu_config_normal_drive_t { .mode=4, .epd=0, .epun=1, .ehs=0, .ezi=1, .zif=0 } }, /* U0_RXD: PortaPack P2_1/ADDR */ { 2, 3, scu_config_normal_drive_t { .mode=4, .epd=0, .epun=1, .ehs=0, .ezi=1, .zif=0 } }, /* I2C1_SDA: PortaPack P2_3/LCD_TE */ { 2, 4, scu_config_normal_drive_t { .mode=4, .epd=0, .epun=1, .ehs=0, .ezi=1, .zif=0 } }, /* I2C1_SCL: PortaPack P2_4/LCD_RDX */ - //TODO: find right settings - { 2, 8, scu_config_normal_drive_t { .mode=4, .epd=0, .epun=1, .ehs=0, .ezi=0, .zif=0 } }, /* P2_8: 10K PD, BOOT2, DFU switch, PortaPack P2_8/ */ + { 2, 8, scu_config_normal_drive_t { .mode=1, .epd=0, .epun=0, .ehs=0, .ezi=1, .zif=1 } }, /* P2_8: 10K PD, BOOT2, DFU switch, PortaPack P2_8/ */ { 2, 9, scu_config_normal_drive_t { .mode=0, .epd=0, .epun=1, .ehs=0, .ezi=1, .zif=0 } }, /* P2_9: 10K PD, BOOT3, PortaPack P2_9/LCD_WRX */ { 2, 13, scu_config_normal_drive_t { .mode=0, .epd=0, .epun=1, .ehs=0, .ezi=1, .zif=0 } }, /* P2_13: PortaPack P2_13/DIR */ { 7, 0, scu_config_normal_drive_t { .mode=0, .epd=0, .epun=1, .ehs=0, .ezi=1, .zif=0 } }, /* GPIO3_8: PortaPack GPIO3_8(IO) */ diff --git a/firmware/common/portapack_io.cpp b/firmware/common/portapack_io.cpp index beed82f1..ad939739 100644 --- a/firmware/common/portapack_io.cpp +++ b/firmware/common/portapack_io.cpp @@ -48,11 +48,7 @@ void IO::init() { gpio_io_stbx.output(); gpio_addr.output(); gpio_rot_a.input(); - - //TODO: find right settings - //gpio_rot_b.set(); gpio_rot_b.input(); - //gpio_rot_b.configure(); } void IO::lcd_backlight(const bool value) { @@ -114,8 +110,8 @@ uint32_t IO::io_update(const TouchPinsConfig write_value) { } gpio_addr.write(addr); - auto dfu_btn = portapack::io.dfu_read(); - return (switches_raw & 0x7f) | (dfu_btn << 7 ); + auto dfu_btn = portapack::io.dfu_read() & 0x01; + return (switches_raw & 0x7f) | (dfu_btn << 7); } }