summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c')
-rw-r--r--firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c
index 8654419f10..9a8b58fd3f 100644
--- a/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c
+++ b/firmware/target/arm/as3525/sansa-e200v2/button-e200v2.c
@@ -31,6 +31,7 @@
31#define WHEEL_FAST_OFF_INTERVAL 60000 31#define WHEEL_FAST_OFF_INTERVAL 60000
32#define WHEELCLICKS_PER_ROTATION 48 /* wheelclicks per full rotation */ 32#define WHEELCLICKS_PER_ROTATION 48 /* wheelclicks per full rotation */
33 33
34static short _dbop_din;
34/* Clickwheel */ 35/* Clickwheel */
35static unsigned int old_wheel_value = 0; 36static unsigned int old_wheel_value = 0;
36static unsigned int wheel_repeat = BUTTON_NONE; 37static unsigned int wheel_repeat = BUTTON_NONE;
@@ -47,7 +48,7 @@ static bool hold_button = false;
47static bool hold_button_old = false; 48static bool hold_button_old = false;
48#endif 49#endif
49 50
50extern void lcd_button_support(void); 51extern bool lcd_button_support(void);
51 52
52void button_init_device(void) 53void button_init_device(void)
53{ 54{
@@ -85,8 +86,7 @@ void clickwheel(unsigned int wheel_value)
85 unsigned long usec = TIMER1_VALUE; /* WAG!!! and it works!!*/ 86 unsigned long usec = TIMER1_VALUE; /* WAG!!! and it works!!*/
86 unsigned v = (usec - last_wheel_usec) & 0x7fffffff; 87 unsigned v = (usec - last_wheel_usec) & 0x7fffffff;
87 88
88 v = (v>0) ? 1000000 / v : 0; /* clicks/sec = 1000000 * 89 v = (v>0) ? 1000000 / v : 0; /* clicks/sec = 1000000 * +clicks/usec */
89+clicks/usec */
90 v = (v>0xffffff) ? 0xffffff : v; /* limit to 24 bit */ 90 v = (v>0xffffff) ? 0xffffff : v; /* limit to 24 bit */
91 91
92 /* some velocity filtering to smooth things out */ 92 /* some velocity filtering to smooth things out */
@@ -119,8 +119,7 @@ void clickwheel(unsigned int wheel_value)
119 } 119 }
120 else 120 else
121 { 121 {
122 /* fast ON gets filtered to avoid inadvertent jumps to fast mode 122 /* fast ON gets filtered to avoid inadvertent jumps to fast mode */
123*/
124 if (repeat && wheel_velocity > 1000000/WHEEL_FAST_ON_INTERVAL) 123 if (repeat && wheel_velocity > 1000000/WHEEL_FAST_ON_INTERVAL)
125 { 124 {
126 /* moving into fast mode */ 125 /* moving into fast mode */
@@ -180,12 +179,13 @@ void clickwheel(unsigned int wheel_value)
180 old_wheel_value = wheel_value; 179 old_wheel_value = wheel_value;
181} 180}
182 181
183int read_dbop(void) 182static short read_dbop(void)
184{ 183{
185 /*write a red pixel */ 184 /*write a red pixel */
186 lcd_button_support(); 185 if (!lcd_button_support())
186 return _dbop_din;
187 187
188 /* Set up dbop for input */ 188 /* Set up dbop for input */
189 while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */ 189 while (!(DBOP_STAT & (1<<10))); /* Wait for fifo to empty */
190 DBOP_CTRL |= (1<<19); 190 DBOP_CTRL |= (1<<19);
191 DBOP_CTRL &= ~(1<<16); /* disable output */ 191 DBOP_CTRL &= ~(1<<16); /* disable output */
@@ -198,14 +198,14 @@ int read_dbop(void)
198 int delay = 50; 198 int delay = 50;
199 while(delay--); /* small delay to set up read */ 199 while(delay--); /* small delay to set up read */
200 200
201 int ret = DBOP_DIN; /* now read dbop & store info*/ 201 _dbop_din = DBOP_DIN; /* now read dbop & store info*/
202 202
203 DBOP_TIMPOL_01 = 0x6e167; 203 DBOP_TIMPOL_01 = 0x6e167;
204 DBOP_TIMPOL_23 = 0xa167e06f; 204 DBOP_TIMPOL_23 = 0xa167e06f;
205 DBOP_CTRL |= (1<<16); 205 DBOP_CTRL |= (1<<16);
206 DBOP_CTRL &= ~(1<<19); 206 DBOP_CTRL &= ~(1<<19);
207 207
208 return ret; 208 return _dbop_din;
209} 209}
210 210
211/* 211/*
@@ -215,7 +215,7 @@ int button_read_device(void)
215{ 215{
216 int btn = BUTTON_NONE; 216 int btn = BUTTON_NONE;
217 /* read buttons from dbop */ 217 /* read buttons from dbop */
218 int dbop = read_dbop(); 218 short dbop = read_dbop();
219 219
220 /* hold button */ 220 /* hold button */
221 if(dbop & (1<<12)) 221 if(dbop & (1<<12))