Update to use new touch functions

This commit is contained in:
Reed Nightingale 2020-02-09 18:41:47 -08:00
parent 26c670ce14
commit a92fdc7793
2 changed files with 6 additions and 32 deletions

View File

@ -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)

View File

@ -30,12 +30,14 @@
* Si5351 object to control the clocks.
*/
#include <Wire.h>
#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);