This commit is contained in:
eshifri
2021-08-16 21:53:45 -07:00
parent 7e5bb15432
commit 2b5f2d5773
2 changed files with 15 additions and 14 deletions
+14 -8
View File
@@ -136,18 +136,24 @@ void SwitchChoice::onEvent(event_t event)
#endif
#if defined(HARDWARE_TOUCH)
bool SwitchChoice::isLongPress(tmr10ms_t longPressDuration)
{
if (duration10ms > 1) {
tmr10ms_t touchDuration10ms = get_tmr10ms() - duration10ms;
if (touchDuration10ms > longPressDuration) return true;
}
return false;
}
void SwitchChoice::checkEvents(void)
{
event_t event = getEvent();
if (duration10ms > 1) {
touchDuration10ms = get_tmr10ms() - duration10ms;
if (isLongPress()) {
int16_t val = getValue();
setValue(-val);
duration10ms = 1;
}
if (isLongPress()) {
int16_t val = getValue();
setValue(-val);
duration10ms = 1;
}
if (hasFocus())
+1 -6
View File
@@ -45,7 +45,6 @@ class SwitchChoice : public FormField
{
#if defined(HARDWARE_TOUCH)
duration10ms = 0;
touchDuration10ms = 0;
#endif
}
@@ -63,10 +62,7 @@ class SwitchChoice : public FormField
void checkEvents(void) override;
bool onTouchEnd(coord_t x, coord_t y) override;
bool onTouchStart(coord_t x, coord_t y) override;
inline bool isLongPress(tmr10ms_t longPressDuration = LONG_PRESS_10MS)
{
return (touchDuration10ms > longPressDuration) ? true : false;
};
inline bool isLongPress(tmr10ms_t longPressDuration = LONG_PRESS_10MS);
#endif
@@ -80,7 +76,6 @@ class SwitchChoice : public FormField
int16_t vmax;
#if defined(HARDWARE_TOUCH)
tmr10ms_t duration10ms;
tmr10ms_t touchDuration10ms;
#endif
std::function<int16_t()> getValue;
std::function<void(int16_t)> setValue;