mirror of
https://codeberg.org/mclemens/ubitxv6.git
synced 2025-02-21 06:57:27 -05:00
Have checkTouch support ButtonPress_e
This commit is contained in:
parent
bd616caaba
commit
e50857f181
3
ubitx.h
3
ubitx.h
@ -120,7 +120,8 @@ int getValueByKnob(int minimum, int maximum, int step_size, int initial, char*
|
|||||||
|
|
||||||
//main functions to check if any button is pressed and other user interface events
|
//main functions to check if any button is pressed and other user interface events
|
||||||
void doCommands(); //does the commands with encoder to jump from button to button
|
void doCommands(); //does the commands with encoder to jump from button to button
|
||||||
void checkTouch(); //does the commands with a touch on the buttons
|
#include "menu.h"
|
||||||
|
ButtonPress_e checkTouch(Point *const touch_point_out); //does the commands with a touch on the buttons
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
47
ubitx_ui.cpp
47
ubitx_ui.cpp
@ -418,7 +418,7 @@ void enterFreq(){
|
|||||||
active_delay(50);
|
active_delay(50);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!readTouch())
|
if(!readTouch(&ts_point))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
scaleTouch(&ts_point);
|
scaleTouch(&ts_point);
|
||||||
@ -508,7 +508,7 @@ void enterFreq(){
|
|||||||
strncat_P(b,(const char*)F(" KHz"),sizeof(b) - strlen(b));
|
strncat_P(b,(const char*)F(" KHz"),sizeof(b) - strlen(b));
|
||||||
displayText(b, LAYOUT_MODE_TEXT_X, LAYOUT_MODE_TEXT_Y, LAYOUT_MODE_TEXT_WIDTH, LAYOUT_MODE_TEXT_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_BACKGROUND);
|
displayText(b, LAYOUT_MODE_TEXT_X, LAYOUT_MODE_TEXT_Y, LAYOUT_MODE_TEXT_WIDTH, LAYOUT_MODE_TEXT_HEIGHT, COLOR_TEXT, COLOR_BACKGROUND, COLOR_BACKGROUND);
|
||||||
active_delay(300);
|
active_delay(300);
|
||||||
while(readTouch())
|
while(readTouch(&ts_point))
|
||||||
checkCAT();
|
checkCAT();
|
||||||
} // end of event loop : while(!exit)
|
} // end of event loop : while(!exit)
|
||||||
|
|
||||||
@ -811,27 +811,32 @@ void doCommand(Button* button){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkTouch(){
|
#include "menu.h"
|
||||||
if (!readTouch())
|
static const uint8_t DEBOUNCE_DELAY_MS = 50;
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
while(readTouch())
|
scaleTouch(touch_point_out);
|
||||||
checkCAT();
|
|
||||||
scaleTouch(&ts_point);
|
|
||||||
|
|
||||||
/* //debug code
|
|
||||||
Serial.print(ts_point.x); Serial.print(' ');Serial.println(ts_point.y);
|
|
||||||
*/
|
|
||||||
for (int i = 0; i < BUTTON_TOTAL; i++){
|
|
||||||
Button button;
|
|
||||||
memcpy_P(&button, &(btn_set[i]), sizeof(Button));
|
|
||||||
|
|
||||||
int x2 = button.x + button.w;
|
if(down_time < LONG_PRESS_TIME_MS){
|
||||||
int y2 = button.y + button.h;
|
return ButtonPress_e::ShortPress;
|
||||||
|
}
|
||||||
if(button.x < ts_point.x && ts_point.x < x2 &&
|
else{
|
||||||
button.y < ts_point.y && ts_point.y < y2)
|
return ButtonPress_e::LongPress;
|
||||||
doCommand(&button);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user