Cleanup
This commit is contained in:
@@ -136,18 +136,24 @@ void SwitchChoice::onEvent(event_t event)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#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)
|
void SwitchChoice::checkEvents(void)
|
||||||
{
|
{
|
||||||
event_t event = getEvent();
|
event_t event = getEvent();
|
||||||
|
|
||||||
if (duration10ms > 1) {
|
if (isLongPress()) {
|
||||||
touchDuration10ms = get_tmr10ms() - duration10ms;
|
int16_t val = getValue();
|
||||||
|
setValue(-val);
|
||||||
if (isLongPress()) {
|
duration10ms = 1;
|
||||||
int16_t val = getValue();
|
|
||||||
setValue(-val);
|
|
||||||
duration10ms = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFocus())
|
if (hasFocus())
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class SwitchChoice : public FormField
|
|||||||
{
|
{
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
duration10ms = 0;
|
duration10ms = 0;
|
||||||
touchDuration10ms = 0;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,10 +62,7 @@ class SwitchChoice : public FormField
|
|||||||
void checkEvents(void) override;
|
void checkEvents(void) override;
|
||||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||||
bool onTouchStart(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)
|
inline bool isLongPress(tmr10ms_t longPressDuration = LONG_PRESS_10MS);
|
||||||
{
|
|
||||||
return (touchDuration10ms > longPressDuration) ? true : false;
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -80,7 +76,6 @@ class SwitchChoice : public FormField
|
|||||||
int16_t vmax;
|
int16_t vmax;
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
tmr10ms_t duration10ms;
|
tmr10ms_t duration10ms;
|
||||||
tmr10ms_t touchDuration10ms;
|
|
||||||
#endif
|
#endif
|
||||||
std::function<int16_t()> getValue;
|
std::function<int16_t()> getValue;
|
||||||
std::function<void(int16_t)> setValue;
|
std::function<void(int16_t)> setValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user