summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2014-05-13 07:58:19 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2014-11-09 22:56:50 +0100
commit25f7034e1d09d3c64c8a262b385c72508d8e7795 (patch)
tree88f9fcc0ed1de124b5fcb162f1397056e9939eae /main.cpp
parentafb3e6cdd24191d6cc2aa813dda646f2c1f19ee2 (diff)
Added a minimum movement threshold to QE buttons.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp18
1 files changed, 12 insertions, 6 deletions
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) {