ubitxv6/ui_touch.cpp
2020-02-09 18:41:13 -08:00

32 lines
697 B
C++

#include "ui_touch.h"
#include <Arduino.h>//delay
#include "button_timing.h"
#include "touch.h"
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;
}
}