diff --git a/firmware/application/apps/ui_debug.cpp b/firmware/application/apps/ui_debug.cpp index 552511f6..b907663d 100644 --- a/firmware/application/apps/ui_debug.cpp +++ b/firmware/application/apps/ui_debug.cpp @@ -253,7 +253,7 @@ bool ControlsSwitchesWidget::on_key(const KeyEvent key) { void ControlsSwitchesWidget::paint(Painter& painter) { const auto pos = screen_pos(); - const std::array button_rects{{ + const std::array button_rects{{ {64, 32, 16, 16}, // Right {0, 32, 16, 16}, // Left {32, 64, 16, 16}, // Down @@ -262,12 +262,16 @@ void ControlsSwitchesWidget::paint(Painter& painter) { {16, 96, 16, 16}, // Encoder phase 0 {48, 96, 16, 16}, // Encoder phase 1 {96, 0, 16, 16}, // Dfu + {96, 64, 16, 16}, // Touch }}; for (const auto r : button_rects) { painter.fill_rectangle(r + pos, Color::blue()); } + if (get_touch_frame().touch) + painter.fill_rectangle(button_rects[8] + pos, Color::yellow()); + const std::array raw_rects{{ {64 + 1, 32 + 1, 16 - 2, 16 - 2}, // Right {0 + 1, 32 + 1, 16 - 2, 16 - 2}, // Left diff --git a/firmware/application/hw/touch_adc.cpp b/firmware/application/hw/touch_adc.cpp index fe472812..7254f156 100644 --- a/firmware/application/hw/touch_adc.cpp +++ b/firmware/application/hw/touch_adc.cpp @@ -71,10 +71,10 @@ Samples get() { const auto yp_reg = LPC_ADC0->DR[portapack::adc0_touch_yp_input]; const auto yn_reg = LPC_ADC0->DR[portapack::adc0_touch_yn_input]; return { - ((xp_reg >> 6) & 0x3ff) * 16, - ((xn_reg >> 6) & 0x3ff) * 16, - ((yp_reg >> 6) & 0x3ff) * 16, - ((yn_reg >> 6) & 0x3ff) * 16, + (xp_reg >> 6) & 0x3ff, + (xn_reg >> 6) & 0x3ff, + (yp_reg >> 6) & 0x3ff, + (yn_reg >> 6) & 0x3ff, }; } diff --git a/firmware/application/touch.cpp b/firmware/application/touch.cpp index 21573ef8..16e9c218 100644 --- a/firmware/application/touch.cpp +++ b/firmware/application/touch.cpp @@ -34,16 +34,16 @@ Metrics calculate_metrics(const Frame& frame) { * fast *enough*?), so maybe leave it alone at least for now. */ - const auto x_max = frame.x.xp / 16; - const auto x_min = frame.x.xn / 16; + const auto x_max = frame.x.xp; + const auto x_min = frame.x.xn; const auto x_range = x_max - x_min; - const float x_position = (frame.x.yp / 16 + frame.x.yn / 16) * 0.5f; + const float x_position = (frame.x.yp + frame.x.yn) * 0.5f; const float x_norm = (x_position - x_min) / x_range; - const auto y_max = frame.y.yn / 16; - const auto y_min = frame.y.yp / 16; + const auto y_max = frame.y.yn; + const auto y_min = frame.y.yp; const auto y_range = y_max - y_min; - const float y_position = (frame.y.xp / 16 + frame.y.xn / 16) * 0.5f; + const float y_position = (frame.y.xp + frame.y.xn) * 0.5f; const float y_norm = (y_position - y_min) / y_range; const auto z_max = frame.pressure.yp; diff --git a/firmware/application/touch.hpp b/firmware/application/touch.hpp index e6ee9f9b..eecc6187 100644 --- a/firmware/application/touch.hpp +++ b/firmware/application/touch.hpp @@ -38,7 +38,7 @@ using sample_t = uint16_t; constexpr sample_t sample_max = 1023; -constexpr sample_t touch_threshold = sample_max / 5; +constexpr sample_t touch_threshold = sample_max / 16; struct Samples { sample_t xp;