Skip to content

Commit

Permalink
touch filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 28, 2019
1 parent 5b5d1fd commit cd35ecd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/eez/gui/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ void processTouchEvent(EventType type) {
#if defined(EEZ_PLATFORM_STM32)
if (type == EVENT_TYPE_TOUCH_MOVE) {
// ignore EVENT_TYPE_TOUCH_MOVE if it is the same as the last event
// or change is too big
int dx = (m_lastTouchMoveX - x);
int dy = (m_lastTouchMoveY - y);
int d = dx * dx + dy * dy;
Expand Down
7 changes: 5 additions & 2 deletions src/eez/gui/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ void tick() {

mcu::touch::read(touchIsPressed, g_x, g_y);

if (touchIsPressed) {
#ifndef EEZ_PLATFORM_SIMULATOR
transform(g_x, g_y);
touchIsPressed = filter(touchIsPressed, g_x, g_y);
if (touchIsPressed) {
transform(g_x, g_y);
}
#endif

if (touchIsPressed) {
if (g_eventType == EVENT_TYPE_TOUCH_NONE || g_eventType == EVENT_TYPE_TOUCH_UP) {
g_eventType = EVENT_TYPE_TOUCH_DOWN;
} else {
Expand Down
12 changes: 6 additions & 6 deletions src/eez/gui/touch_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
// Thanks to: http://dlbeer.co.nz/articles/tsf.html
//

#define CONF_GUI_TOUCH_FILTER_N 0
#define CONF_GUI_TOUCH_FILTER_D 1
#define CONF_GUI_TOUCH_FILTER_P 5
// #define CONF_GUI_TOUCH_FILTER_N 0
// #define CONF_GUI_TOUCH_FILTER_D 1
// #define CONF_GUI_TOUCH_FILTER_P 5

// #define CONF_GUI_TOUCH_FILTER_N 5
// #define CONF_GUI_TOUCH_FILTER_D 10
// #define CONF_GUI_TOUCH_FILTER_P 10
#define CONF_GUI_TOUCH_FILTER_N 5 // level of smoothing in the form of a fraction N / D
#define CONF_GUI_TOUCH_FILTER_D 10
#define CONF_GUI_TOUCH_FILTER_P 3 // debounce

namespace eez {
namespace gui {
Expand Down

0 comments on commit cd35ecd

Please sign in to comment.