From a92fdc7793fdcfc239af002435141c776eba96ce Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Sun, 9 Feb 2020 18:41:47 -0800 Subject: [PATCH] Update to use new touch functions --- ubitx_ui.cpp | 32 +++----------------------------- ubitxv6.ino | 6 +++--- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/ubitx_ui.cpp b/ubitx_ui.cpp index c8ad956..3eb4fe5 100644 --- a/ubitx_ui.cpp +++ b/ubitx_ui.cpp @@ -5,6 +5,7 @@ #include "nano_gui.h" #include "settings.h" #include "setup.h" +#include "touch.h" #include "ubitx.h" #include "version.h" @@ -394,6 +395,8 @@ void fastTune(){ void enterFreq(){ //force the display to refresh everything //display all the buttons + + Point ts_point; for (int i = 0; i < KEYS_TOTAL; i++){ Button button; @@ -811,35 +814,6 @@ void doCommand(Button* button){ } } -#include "menu.h" -static const uint8_t DEBOUNCE_DELAY_MS = 50; -static const uint16_t LONG_PRESS_TIME_MS = 3000; -static const uint8_t LONG_PRESS_POLL_TIME_MS = 10; -ButtonPress_e checkTouch(Point *const touch_point_out){ - if (!readTouch(touch_point_out)){ - return ButtonPress_e::NotPressed; - } - delay(DEBOUNCE_DELAY_MS); - if (!readTouch(touch_point_out)){//debounce - return ButtonPress_e::NotPressed; - } - - uint16_t down_time = 0; - while(readTouch(touch_point_out) && (down_time < LONG_PRESS_TIME_MS)){ - delay(LONG_PRESS_POLL_TIME_MS); - down_time += LONG_PRESS_POLL_TIME_MS; - } - - scaleTouch(touch_point_out); - - if(down_time < LONG_PRESS_TIME_MS){ - return ButtonPress_e::ShortPress; - } - else{ - return ButtonPress_e::LongPress; - } -} - //returns true if the button is pressed int btnDown(){ if (digitalRead(FBUTTON) == HIGH) diff --git a/ubitxv6.ino b/ubitxv6.ino index b0febb6..d58c758 100644 --- a/ubitxv6.ino +++ b/ubitxv6.ino @@ -30,12 +30,14 @@ * Si5351 object to control the clocks. */ #include +#include "button_timing.h" #include "menu.h" #include "menu_main.h" #include "morse.h" #include "nano_gui.h" #include "settings.h" #include "setup.h" +#include "touch.h" #include "ubitx.h" /** @@ -304,9 +306,6 @@ void checkPTT(){ } //check if the encoder button was pressed -static const uint8_t DEBOUNCE_DELAY_MS = 50; -static const uint16_t LONG_PRESS_TIME_MS = 3000; -static const uint8_t LONG_PRESS_POLL_TIME_MS = 10; ButtonPress_e checkButton(){ if (!btnDown()){ return ButtonPress_e::NotPressed; @@ -462,6 +461,7 @@ void setup() initSettings(); displayInit(); + initTouch(); initPorts(); initOscillators(); setFrequency(globalSettings.vfoA.frequency);