summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/button.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 36cc0d2598..41d85aba87 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -31,9 +31,17 @@
31 31
32struct event_queue button_queue; 32struct event_queue button_queue;
33 33
34/* how often we check to see if a button is pressed */
34#define POLL_FREQUENCY HZ/20 35#define POLL_FREQUENCY HZ/20
36
37/* how long until repeat kicks in */
35#define REPEAT_START 6 38#define REPEAT_START 6
36#define REPEAT_INTERVAL 4 39
40/* the speed repeat starts at */
41#define REPEAT_INTERVAL_START 8
42
43/* speed repeat finishes at */
44#define REPEAT_INTERVAL_FINISH 2
37 45
38static int repeat_mask = DEFAULT_REPEAT_MASK; 46static int repeat_mask = DEFAULT_REPEAT_MASK;
39static int release_mask = DEFAULT_RELEASE_MASK; 47static int release_mask = DEFAULT_RELEASE_MASK;
@@ -45,6 +53,7 @@ static void button_tick(void)
45 static int tick=0; 53 static int tick=0;
46 static int count=0; 54 static int count=0;
47 static int lastbtn=0; 55 static int lastbtn=0;
56 static int repeat_speed=REPEAT_INTERVAL_START;
48 static bool repeat=false; 57 static bool repeat=false;
49 int diff; 58 int diff;
50 59
@@ -69,14 +78,21 @@ static void button_tick(void)
69 { 78 {
70 post = true; 79 post = true;
71 repeat = false; 80 repeat = false;
81 repeat_speed = REPEAT_INTERVAL_START;
82
72 } 83 }
73 else /* repeat? */ 84 else /* repeat? */
74 { 85 {
75 if ( repeat ) 86 if ( repeat )
76 { 87 {
77 if ( ! --count ) { 88 count--;
89 if (count == 0) {
78 post = true; 90 post = true;
79 count = REPEAT_INTERVAL; 91 /* yes we have repeat */
92 repeat_speed--;
93 if (repeat_speed < REPEAT_INTERVAL_FINISH)
94 repeat_speed = REPEAT_INTERVAL_FINISH;
95 count = repeat_speed;
80 } 96 }
81 } 97 }
82 else 98 else
@@ -95,7 +111,8 @@ static void button_tick(void)
95 { 111 {
96 post = true; 112 post = true;
97 repeat = true; 113 repeat = true;
98 count = REPEAT_INTERVAL; 114 /* initial repeat */
115 count = REPEAT_INTERVAL_START;
99 } 116 }
100 /* If the OFF button is pressed long enough, 117 /* If the OFF button is pressed long enough,
101 and we are still alive, then the unit must be 118 and we are still alive, then the unit must be