From 25f7034e1d09d3c64c8a262b385c72508d8e7795 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Tue, 13 May 2014 07:58:19 +0200 Subject: Added a minimum movement threshold to QE buttons. --- main.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 4f3f897..2bd2cad 100644 --- a/main.cpp +++ b/main.cpp @@ -619,27 +619,33 @@ int main() { int8_t rx = qe1_count - last_x; int8_t ry = qe2_count - last_y; - last_x = qe1_count; - last_y = qe2_count; - if(rx > 0) { + if(rx > 1) { state_x = 100; - } else if(rx < 0) { + last_x = qe1_count; + } else if(rx < -1) { state_x = -100; + last_x = qe1_count; } else if(state_x > 0) { state_x--; + last_x = qe1_count; } else if(state_x < 0) { state_x++; + last_x = qe1_count; } - if(ry > 0) { + if(ry > 1) { state_y = 100; - } else if(ry < 0) { + last_y = qe2_count; + } else if(ry < -1) { state_y = -100; + last_y = qe2_count; } else if(state_y > 0) { state_y--; + last_y = qe2_count; } else if(state_y < 0) { state_y++; + last_y = qe2_count; } if(state_x > 0) { -- cgit v1.2.3