Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index 4486af9..f454867 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -34,6 +34,7 @@ static bool hold_button = false;
 #define TIMER_TICK              (KERNEL_TIMER_FREQ/HZ)/* how long a tick lasts */
 #define TIMER_MS                (TIMER_TICK/(1000/HZ))/* how long a ms lasts */

+#define WHEEL_LOOP_INTERVAL     (  3*TIMER_MS)      /*  3 ms */
 #define WHEEL_REPEAT_INTERVAL   (300*TIMER_MS)      /* 300ms */
 #define WHEEL_FAST_ON_INTERVAL  ( 20*TIMER_MS)      /*  20ms */
 #define WHEEL_FAST_OFF_INTERVAL ( 60*TIMER_MS)      /*  60ms */
@@ -76,6 +77,18 @@ static void scrollwheel(unsigned int wheel_value)
         { 1, 3, 0, 2 }, /* Counter-clockwise  */
     };

+    int  repeat = 1; /* assume repeat */
+    long time = TIMER2_VALUE + current_tick*TIMER_TICK; /* to timer unit */
+    long v = (time - last_wheel_post);
+    if (v < WHEEL_LOOP_INTERVAL) /* avoid too frequent updates */
+        return ;
+
+   /* interpolate velocity in timer_freq/timer_unit == 1/s */
+    if (v) v = TIMER_FREQ / v;
+
+    /* accumulate velocities over time with each v */
+    wheel_velocity = (7*wheel_velocity + v) / 8;
+
     unsigned int btn = BUTTON_NONE;

     if (old_wheel_value == wheel_tbl[0][wheel_value])
@@ -89,16 +102,6 @@ static void scrollwheel(unsigned int wheel_value)
         return;
     }

-    int  repeat = 1; /* assume repeat */
-    long time = TIMER2_VALUE + current_tick*TIMER_TICK; /* to timer unit */
-    long v = (time - last_wheel_post);
-
-   /* interpolate velocity in timer_freq/timer_unit == 1/s */
-    if (v) v = TIMER_FREQ / v;
-
-    /* accumulate velocities over time with each v */
-    wheel_velocity = (7*wheel_velocity + v) / 8;
-
     if (btn != wheel_repeat)
     {
         /* direction reversals nullify all fast mode states */