diff options
Diffstat (limited to 'apps/plugins/oscilloscope.c')
-rw-r--r-- | apps/plugins/oscilloscope.c | 288 |
1 files changed, 245 insertions, 43 deletions
diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c index e215f78efe..2d1425b5b7 100644 --- a/apps/plugins/oscilloscope.c +++ b/apps/plugins/oscilloscope.c | |||
@@ -39,6 +39,7 @@ PLUGIN_HEADER | |||
39 | #define OSCILLOSCOPE_QUIT BUTTON_OFF | 39 | #define OSCILLOSCOPE_QUIT BUTTON_OFF |
40 | #define OSCILLOSCOPE_MODE BUTTON_F1 | 40 | #define OSCILLOSCOPE_MODE BUTTON_F1 |
41 | #define OSCILLOSCOPE_SCROLL BUTTON_F2 | 41 | #define OSCILLOSCOPE_SCROLL BUTTON_F2 |
42 | #define OSCILLOSCOPE_ORIENTATION BUTTON_F3 | ||
42 | #define OSCILLOSCOPE_PAUSE BUTTON_PLAY | 43 | #define OSCILLOSCOPE_PAUSE BUTTON_PLAY |
43 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT | 44 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT |
44 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT | 45 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT |
@@ -50,6 +51,7 @@ PLUGIN_HEADER | |||
50 | #define OSCILLOSCOPE_MODE_PRE BUTTON_MENU | 51 | #define OSCILLOSCOPE_MODE_PRE BUTTON_MENU |
51 | #define OSCILLOSCOPE_MODE (BUTTON_MENU | BUTTON_REL) | 52 | #define OSCILLOSCOPE_MODE (BUTTON_MENU | BUTTON_REL) |
52 | #define OSCILLOSCOPE_SCROLL (BUTTON_MENU | BUTTON_RIGHT) | 53 | #define OSCILLOSCOPE_SCROLL (BUTTON_MENU | BUTTON_RIGHT) |
54 | #define OSCILLOSCOPE_ORIENTATION (BUTTON_MENU | BUTTON_LEFT) | ||
53 | #define OSCILLOSCOPE_PAUSE (BUTTON_MENU | BUTTON_OFF) | 55 | #define OSCILLOSCOPE_PAUSE (BUTTON_MENU | BUTTON_OFF) |
54 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT | 56 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT |
55 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT | 57 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT |
@@ -60,6 +62,7 @@ PLUGIN_HEADER | |||
60 | #define OSCILLOSCOPE_QUIT BUTTON_OFF | 62 | #define OSCILLOSCOPE_QUIT BUTTON_OFF |
61 | #define OSCILLOSCOPE_MODE BUTTON_SELECT | 63 | #define OSCILLOSCOPE_MODE BUTTON_SELECT |
62 | #define OSCILLOSCOPE_SCROLL BUTTON_MODE | 64 | #define OSCILLOSCOPE_SCROLL BUTTON_MODE |
65 | #define OSCILLOSCOPE_ORIENTATION BUTTON_REC | ||
63 | #define OSCILLOSCOPE_PAUSE BUTTON_ON | 66 | #define OSCILLOSCOPE_PAUSE BUTTON_ON |
64 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT | 67 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT |
65 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT | 68 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT |
@@ -70,6 +73,7 @@ PLUGIN_HEADER | |||
70 | #define OSCILLOSCOPE_QUIT (BUTTON_SELECT | BUTTON_MENU) | 73 | #define OSCILLOSCOPE_QUIT (BUTTON_SELECT | BUTTON_MENU) |
71 | #define OSCILLOSCOPE_MODE (BUTTON_SELECT | BUTTON_PLAY) | 74 | #define OSCILLOSCOPE_MODE (BUTTON_SELECT | BUTTON_PLAY) |
72 | #define OSCILLOSCOPE_SCROLL (BUTTON_SELECT | BUTTON_RIGHT) | 75 | #define OSCILLOSCOPE_SCROLL (BUTTON_SELECT | BUTTON_RIGHT) |
76 | #define OSCILLOSCOPE_ORIENTATION (BUTTON_SELECT | BUTTON_LEFT) | ||
73 | #define OSCILLOSCOPE_PAUSE BUTTON_PLAY | 77 | #define OSCILLOSCOPE_PAUSE BUTTON_PLAY |
74 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT | 78 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT |
75 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT | 79 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT |
@@ -79,7 +83,8 @@ PLUGIN_HEADER | |||
79 | #elif (CONFIG_KEYPAD == GIGABEAT_PAD) | 83 | #elif (CONFIG_KEYPAD == GIGABEAT_PAD) |
80 | #define OSCILLOSCOPE_QUIT BUTTON_POWER | 84 | #define OSCILLOSCOPE_QUIT BUTTON_POWER |
81 | #define OSCILLOSCOPE_MODE BUTTON_SELECT | 85 | #define OSCILLOSCOPE_MODE BUTTON_SELECT |
82 | #define OSCILLOSCOPE_SCROLL BUTTON_MENU | 86 | #define OSCILLOSCOPE_SCROLL BUTTON_DOWN |
87 | #define OSCILLOSCOPE_ORIENTATION BUTTON_UP | ||
83 | #define OSCILLOSCOPE_PAUSE BUTTON_A | 88 | #define OSCILLOSCOPE_PAUSE BUTTON_A |
84 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT | 89 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT |
85 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT | 90 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT |
@@ -88,8 +93,10 @@ PLUGIN_HEADER | |||
88 | 93 | ||
89 | #elif CONFIG_KEYPAD == IAUDIO_X5_PAD | 94 | #elif CONFIG_KEYPAD == IAUDIO_X5_PAD |
90 | #define OSCILLOSCOPE_QUIT BUTTON_POWER | 95 | #define OSCILLOSCOPE_QUIT BUTTON_POWER |
91 | #define OSCILLOSCOPE_MODE BUTTON_SELECT | 96 | #define OSCILLOSCOPE_MODE_PRE BUTTON_SELECT |
97 | #define OSCILLOSCOPE_MODE (BUTTON_SELECT | BUTTON_REL) | ||
92 | #define OSCILLOSCOPE_SCROLL BUTTON_REC | 98 | #define OSCILLOSCOPE_SCROLL BUTTON_REC |
99 | #define OSCILLOSCOPE_ORIENTATION (BUTTON_SELECT | BUTTON_REPEAT) | ||
93 | #define OSCILLOSCOPE_PAUSE BUTTON_PLAY | 100 | #define OSCILLOSCOPE_PAUSE BUTTON_PLAY |
94 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT | 101 | #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT |
95 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT | 102 | #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT |
@@ -102,22 +109,33 @@ PLUGIN_HEADER | |||
102 | #define mas_codec_readreg(x) rand()%MAX_PEAK | 109 | #define mas_codec_readreg(x) rand()%MAX_PEAK |
103 | #endif | 110 | #endif |
104 | 111 | ||
112 | /* prototypes */ | ||
113 | |||
114 | void anim_horizontal(int, int); | ||
115 | void anim_vertical(int, int); | ||
116 | |||
105 | /* global variables */ | 117 | /* global variables */ |
106 | 118 | ||
107 | struct plugin_api* rb; /* global api struct pointer */ | 119 | struct plugin_api* rb; /* global api struct pointer */ |
108 | 120 | ||
109 | int osc_mode = OSC_MODE_FILLED; | 121 | int osc_mode = OSC_MODE_FILLED; |
110 | int osc_delay = 1; /* in ticks */ | 122 | int osc_delay = 2; /* in ticks */ |
111 | bool osc_scroll = true; | 123 | bool osc_scroll = true; |
112 | long last_tick = 0; | 124 | void (*anim)(int, int) = anim_horizontal; |
125 | |||
126 | long last_tick = 0; /* time of last drawing */ | ||
127 | int last_pos = 0; /* last x or y drawing position. Reset for aspect switch. */ | ||
128 | int last_left; /* last channel values */ | ||
129 | int last_right; | ||
130 | |||
131 | unsigned char message[16]; /* message to display */ | ||
132 | bool displaymsg = false; | ||
133 | int font_height = 8; | ||
113 | 134 | ||
114 | /* implementation */ | 135 | /* implementation */ |
115 | 136 | ||
116 | void animate(int cur_left, int cur_right) | 137 | void anim_horizontal(int cur_left, int cur_right) |
117 | { | 138 | { |
118 | static int last_x = 0; | ||
119 | static int last_left, last_right; | ||
120 | |||
121 | int cur_x, x; | 139 | int cur_x, x; |
122 | int left, right, dl, dr; | 140 | int left, right, dl, dr; |
123 | long cur_tick = *rb->current_tick; | 141 | long cur_tick = *rb->current_tick; |
@@ -135,7 +153,7 @@ void animate(int cur_left, int cur_right) | |||
135 | last_right = cur_right; | 153 | last_right = cur_right; |
136 | return; | 154 | return; |
137 | } | 155 | } |
138 | cur_x = last_x + d; | 156 | cur_x = last_pos + d; |
139 | 157 | ||
140 | if (cur_x >= LCD_WIDTH) | 158 | if (cur_x >= LCD_WIDTH) |
141 | { | 159 | { |
@@ -145,7 +163,7 @@ void animate(int cur_left, int cur_right) | |||
145 | xlcd_scroll_left(shift); | 163 | xlcd_scroll_left(shift); |
146 | full_update = true; | 164 | full_update = true; |
147 | cur_x -= shift; | 165 | cur_x -= shift; |
148 | last_x -= shift; | 166 | last_pos -= shift; |
149 | } | 167 | } |
150 | else /* wrap */ | 168 | else /* wrap */ |
151 | { | 169 | { |
@@ -154,13 +172,13 @@ void animate(int cur_left, int cur_right) | |||
154 | } | 172 | } |
155 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 173 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
156 | 174 | ||
157 | if (cur_x > last_x) | 175 | if (cur_x > last_pos) |
158 | { | 176 | { |
159 | rb->lcd_fillrect(last_x + 1, 0, d + 2, LCD_HEIGHT); | 177 | rb->lcd_fillrect(last_pos + 1, 0, d + 2, LCD_HEIGHT); |
160 | } | 178 | } |
161 | else | 179 | else |
162 | { | 180 | { |
163 | rb->lcd_fillrect(last_x + 1, 0, (LCD_WIDTH-1) - last_x, LCD_HEIGHT); | 181 | rb->lcd_fillrect(last_pos + 1, 0, (LCD_WIDTH-1) - last_pos, LCD_HEIGHT); |
164 | rb->lcd_fillrect(0, 0, cur_x + 2, LCD_HEIGHT); | 182 | rb->lcd_fillrect(0, 0, cur_x + 2, LCD_HEIGHT); |
165 | } | 183 | } |
166 | rb->lcd_set_drawmode(DRMODE_SOLID); | 184 | rb->lcd_set_drawmode(DRMODE_SOLID); |
@@ -173,7 +191,7 @@ void animate(int cur_left, int cur_right) | |||
173 | dl = (cur_left - left) / d; | 191 | dl = (cur_left - left) / d; |
174 | dr = (cur_right - right) / d; | 192 | dr = (cur_right - right) / d; |
175 | 193 | ||
176 | for (x = last_x + 1; d > 0; x++, d--) | 194 | for (x = last_pos + 1; d > 0; x++, d--) |
177 | { | 195 | { |
178 | if (x == LCD_WIDTH) | 196 | if (x == LCD_WIDTH) |
179 | x = 0; | 197 | x = 0; |
@@ -181,47 +199,47 @@ void animate(int cur_left, int cur_right) | |||
181 | left += dl; | 199 | left += dl; |
182 | right += dr; | 200 | right += dr; |
183 | 201 | ||
184 | rb->lcd_vline(x, LCD_HEIGHT/2+1, | ||
185 | LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * left) >> 16)); | ||
186 | rb->lcd_vline(x, LCD_HEIGHT/2-1, | 202 | rb->lcd_vline(x, LCD_HEIGHT/2-1, |
187 | LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * right) >> 16)); | 203 | LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * left) >> 16)); |
204 | rb->lcd_vline(x, LCD_HEIGHT/2+1, | ||
205 | LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * right) >> 16)); | ||
188 | } | 206 | } |
189 | break; | 207 | break; |
190 | 208 | ||
191 | case OSC_MODE_OUTLINE: | 209 | case OSC_MODE_OUTLINE: |
192 | if (cur_x > last_x) | 210 | if (cur_x > last_pos) |
193 | { | 211 | { |
194 | rb->lcd_drawline( | 212 | rb->lcd_drawline( |
195 | last_x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * last_left) >> 16), | 213 | last_pos, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * last_left) >> 16), |
196 | cur_x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * cur_left) >> 16) | 214 | cur_x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * cur_left) >> 16) |
197 | ); | 215 | ); |
198 | rb->lcd_drawline( | 216 | rb->lcd_drawline( |
199 | last_x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * last_right) >> 16), | 217 | last_pos, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * last_right) >> 16), |
200 | cur_x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * cur_right) >> 16) | 218 | cur_x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * cur_right) >> 16) |
201 | ); | 219 | ); |
202 | } | 220 | } |
203 | else | 221 | else |
204 | { | 222 | { |
205 | left = last_left | 223 | left = last_left |
206 | + (LCD_WIDTH - last_x) * (last_left - cur_left) / d; | 224 | + (LCD_WIDTH - last_pos) * (last_left - cur_left) / d; |
207 | right = last_right | 225 | right = last_right |
208 | + (LCD_WIDTH - last_x) * (last_right - cur_right) / d; | 226 | + (LCD_WIDTH - last_pos) * (last_right - cur_right) / d; |
209 | 227 | ||
210 | rb->lcd_drawline( | 228 | rb->lcd_drawline( |
211 | last_x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * last_left) >> 16), | 229 | last_pos, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * last_left) >> 16), |
212 | LCD_WIDTH, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * left) >> 16) | 230 | LCD_WIDTH, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * left) >> 16) |
213 | ); | 231 | ); |
214 | rb->lcd_drawline( | 232 | rb->lcd_drawline( |
215 | last_x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * last_right) >> 16), | 233 | 0, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * left) >> 16), |
216 | LCD_WIDTH, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * right) >> 16) | 234 | cur_x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * cur_left) >> 16) |
217 | ); | 235 | ); |
218 | rb->lcd_drawline( | 236 | rb->lcd_drawline( |
219 | 0, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * left) >> 16), | 237 | last_pos, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * last_right) >> 16), |
220 | cur_x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * cur_left) >> 16) | 238 | LCD_WIDTH, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * right) >> 16) |
221 | ); | 239 | ); |
222 | rb->lcd_drawline( | 240 | rb->lcd_drawline( |
223 | 0, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * right) >> 16), | 241 | 0, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * right) >> 16), |
224 | cur_x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * cur_right) >> 16) | 242 | cur_x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * cur_right) >> 16) |
225 | ); | 243 | ); |
226 | } | 244 | } |
227 | break; | 245 | break; |
@@ -232,7 +250,7 @@ void animate(int cur_left, int cur_right) | |||
232 | dl = (cur_left - left) / d; | 250 | dl = (cur_left - left) / d; |
233 | dr = (cur_right - right) / d; | 251 | dr = (cur_right - right) / d; |
234 | 252 | ||
235 | for (x = last_x + 1; d > 0; x++, d--) | 253 | for (x = last_pos + 1; d > 0; x++, d--) |
236 | { | 254 | { |
237 | if (x == LCD_WIDTH) | 255 | if (x == LCD_WIDTH) |
238 | x = 0; | 256 | x = 0; |
@@ -240,8 +258,8 @@ void animate(int cur_left, int cur_right) | |||
240 | left += dl; | 258 | left += dl; |
241 | right += dr; | 259 | right += dr; |
242 | 260 | ||
243 | rb->lcd_drawpixel(x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * left) >> 16)); | 261 | rb->lcd_drawpixel(x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * left) >> 16)); |
244 | rb->lcd_drawpixel(x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * right) >> 16)); | 262 | rb->lcd_drawpixel(x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * right) >> 16)); |
245 | } | 263 | } |
246 | break; | 264 | break; |
247 | 265 | ||
@@ -255,17 +273,179 @@ void animate(int cur_left, int cur_right) | |||
255 | } | 273 | } |
256 | else | 274 | else |
257 | { | 275 | { |
258 | if (cur_x > last_x) | 276 | if (cur_x > last_pos) |
259 | { | 277 | { |
260 | rb->lcd_update_rect(last_x, 0, cur_x - last_x + 2, LCD_HEIGHT); | 278 | rb->lcd_update_rect(last_pos, 0, cur_x - last_pos + 2, LCD_HEIGHT); |
261 | } | 279 | } |
262 | else | 280 | else |
263 | { | 281 | { |
264 | rb->lcd_update_rect(last_x, 0, (LCD_WIDTH-1) - last_x, LCD_HEIGHT); | 282 | rb->lcd_update_rect(last_pos, 0, (LCD_WIDTH-1) - last_pos, LCD_HEIGHT); |
265 | rb->lcd_update_rect(0, 0, cur_x + 2, LCD_HEIGHT); | 283 | rb->lcd_update_rect(0, 0, cur_x + 2, LCD_HEIGHT); |
266 | } | 284 | } |
267 | } | 285 | } |
268 | last_x = cur_x; | 286 | last_pos = cur_x; |
287 | } | ||
288 | |||
289 | void anim_vertical(int cur_left, int cur_right) | ||
290 | { | ||
291 | int cur_y, y; | ||
292 | int left, right, dl, dr; | ||
293 | long cur_tick = *rb->current_tick; | ||
294 | long d = (cur_tick - last_tick) / osc_delay; | ||
295 | bool full_update = false; | ||
296 | |||
297 | if (d == 0) /* too early, bail out */ | ||
298 | return; | ||
299 | |||
300 | last_tick = cur_tick; | ||
301 | |||
302 | if (d > HZ) /* first call or too much delay, (re)start */ | ||
303 | { | ||
304 | last_left = cur_left; | ||
305 | last_right = cur_right; | ||
306 | return; | ||
307 | } | ||
308 | cur_y = last_pos + d; | ||
309 | |||
310 | if (cur_y >= LCD_HEIGHT) | ||
311 | { | ||
312 | if (osc_scroll) /* scroll */ | ||
313 | { | ||
314 | int shift = cur_y - (LCD_HEIGHT-1); | ||
315 | xlcd_scroll_up(shift); | ||
316 | full_update = true; | ||
317 | cur_y -= shift; | ||
318 | last_pos -= shift; | ||
319 | } | ||
320 | else /* wrap */ | ||
321 | { | ||
322 | cur_y -= LCD_HEIGHT; | ||
323 | } | ||
324 | } | ||
325 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
326 | |||
327 | if (cur_y > last_pos) | ||
328 | { | ||
329 | rb->lcd_fillrect(0, last_pos + 1, LCD_WIDTH, d + 2); | ||
330 | } | ||
331 | else | ||
332 | { | ||
333 | rb->lcd_fillrect(0, last_pos + 1, LCD_WIDTH, (LCD_HEIGHT-1) - last_pos); | ||
334 | rb->lcd_fillrect(0, 0, LCD_WIDTH, cur_y + 2); | ||
335 | } | ||
336 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
337 | |||
338 | switch (osc_mode) | ||
339 | { | ||
340 | case OSC_MODE_FILLED: | ||
341 | left = last_left; | ||
342 | right = last_right; | ||
343 | dl = (cur_left - left) / d; | ||
344 | dr = (cur_right - right) / d; | ||
345 | |||
346 | for (y = last_pos + 1; d > 0; y++, d--) | ||
347 | { | ||
348 | if (y == LCD_HEIGHT) | ||
349 | y = 0; | ||
350 | |||
351 | left += dl; | ||
352 | right += dr; | ||
353 | |||
354 | rb->lcd_hline(LCD_WIDTH/2-1, | ||
355 | LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * left) >> 16), y); | ||
356 | rb->lcd_hline(LCD_WIDTH/2+1, | ||
357 | LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * right) >> 16), y); | ||
358 | } | ||
359 | break; | ||
360 | |||
361 | case OSC_MODE_OUTLINE: | ||
362 | if (cur_y > last_pos) | ||
363 | { | ||
364 | rb->lcd_drawline( | ||
365 | LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * last_left) >> 16), last_pos, | ||
366 | LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * cur_left) >> 16), cur_y | ||
367 | ); | ||
368 | rb->lcd_drawline( | ||
369 | LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * last_right) >> 16), last_pos, | ||
370 | LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * cur_right) >> 16), cur_y | ||
371 | ); | ||
372 | } | ||
373 | else | ||
374 | { | ||
375 | left = last_left | ||
376 | + (LCD_HEIGHT - last_pos) * (last_left - cur_left) / d; | ||
377 | right = last_right | ||
378 | + (LCD_HEIGHT - last_pos) * (last_right - cur_right) / d; | ||
379 | |||
380 | rb->lcd_drawline( | ||
381 | LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * last_left) >> 16), last_pos, | ||
382 | LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * left) >> 16), LCD_HEIGHT | ||
383 | ); | ||
384 | rb->lcd_drawline( | ||
385 | LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * left) >> 16), 0, | ||
386 | LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * cur_left) >> 16), cur_y | ||
387 | ); | ||
388 | rb->lcd_drawline( | ||
389 | LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * last_right) >> 16), last_pos, | ||
390 | LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * right) >> 16), LCD_HEIGHT | ||
391 | ); | ||
392 | rb->lcd_drawline( | ||
393 | LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * right) >> 16), 0, | ||
394 | LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * cur_right) >> 16), cur_y | ||
395 | ); | ||
396 | } | ||
397 | break; | ||
398 | |||
399 | case OSC_MODE_PIXEL: | ||
400 | left = last_left; | ||
401 | right = last_right; | ||
402 | dl = (cur_left - left) / d; | ||
403 | dr = (cur_right - right) / d; | ||
404 | |||
405 | for (y = last_pos + 1; d > 0; y++, d--) | ||
406 | { | ||
407 | if (y == LCD_HEIGHT) | ||
408 | y = 0; | ||
409 | |||
410 | left += dl; | ||
411 | right += dr; | ||
412 | |||
413 | rb->lcd_drawpixel(LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * left) >> 16), y); | ||
414 | rb->lcd_drawpixel(LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * right) >> 16), y); | ||
415 | } | ||
416 | break; | ||
417 | |||
418 | } | ||
419 | last_left = cur_left; | ||
420 | last_right = cur_right; | ||
421 | |||
422 | if (displaymsg) | ||
423 | { | ||
424 | last_pos -= font_height - 1; | ||
425 | if (last_pos < 0) | ||
426 | last_pos = LCD_HEIGHT - font_height; | ||
427 | |||
428 | rb->lcd_putsxy(0, last_pos, message); | ||
429 | displaymsg = false; | ||
430 | } | ||
431 | |||
432 | if (full_update) | ||
433 | { | ||
434 | rb->lcd_update(); | ||
435 | } | ||
436 | else | ||
437 | { | ||
438 | if (cur_y > last_pos) | ||
439 | { | ||
440 | rb->lcd_update_rect(0, last_pos, LCD_WIDTH, cur_y - last_pos + 2); | ||
441 | } | ||
442 | else | ||
443 | { | ||
444 | rb->lcd_update_rect(0, last_pos, LCD_WIDTH, (LCD_HEIGHT-1) - last_pos); | ||
445 | rb->lcd_update_rect(0, 0, LCD_WIDTH, cur_y + 2); | ||
446 | } | ||
447 | } | ||
448 | last_pos = cur_y; | ||
269 | } | 449 | } |
270 | 450 | ||
271 | void cleanup(void *parameter) | 451 | void cleanup(void *parameter) |
@@ -284,6 +464,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
284 | int lastbutton = BUTTON_NONE; | 464 | int lastbutton = BUTTON_NONE; |
285 | bool exit = false; | 465 | bool exit = false; |
286 | bool paused = false; | 466 | bool paused = false; |
467 | bool tell_speed; | ||
287 | 468 | ||
288 | (void)parameter; | 469 | (void)parameter; |
289 | rb = api; | 470 | rb = api; |
@@ -297,7 +478,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
297 | rb->lcd_update(); | 478 | rb->lcd_update(); |
298 | rb->backlight_set_timeout(1); /* keep the light on */ | 479 | rb->backlight_set_timeout(1); /* keep the light on */ |
299 | #endif | 480 | #endif |
300 | 481 | rb->lcd_getstringsize("A", NULL, &font_height); | |
482 | |||
301 | while (!exit) | 483 | while (!exit) |
302 | { | 484 | { |
303 | if (!paused) | 485 | if (!paused) |
@@ -312,9 +494,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
312 | #elif (CONFIG_CODEC == SWCODEC) | 494 | #elif (CONFIG_CODEC == SWCODEC) |
313 | rb->pcm_calculate_peaks(&left, &right); | 495 | rb->pcm_calculate_peaks(&left, &right); |
314 | #endif | 496 | #endif |
315 | animate(left, right); | 497 | anim(left, right); |
316 | } | 498 | } |
317 | 499 | ||
500 | tell_speed = false; | ||
318 | button = rb->button_get(paused); | 501 | button = rb->button_get(paused); |
319 | switch (button) | 502 | switch (button) |
320 | { | 503 | { |
@@ -334,6 +517,15 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
334 | if (++osc_mode >= OSC_MODE_COUNT) | 517 | if (++osc_mode >= OSC_MODE_COUNT) |
335 | osc_mode = 0; | 518 | osc_mode = 0; |
336 | break; | 519 | break; |
520 | |||
521 | case OSCILLOSCOPE_ORIENTATION: | ||
522 | anim = (anim == anim_horizontal) ? anim_vertical : anim_horizontal; | ||
523 | last_pos = 0; | ||
524 | last_tick = 0; | ||
525 | displaymsg = false; | ||
526 | rb->lcd_clear_display(); | ||
527 | rb->lcd_update(); | ||
528 | break; | ||
337 | 529 | ||
338 | case OSCILLOSCOPE_PAUSE: | 530 | case OSCILLOSCOPE_PAUSE: |
339 | paused = !paused; | 531 | paused = !paused; |
@@ -343,12 +535,16 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
343 | case OSCILLOSCOPE_SPEED_UP: | 535 | case OSCILLOSCOPE_SPEED_UP: |
344 | case OSCILLOSCOPE_SPEED_UP | BUTTON_REPEAT: | 536 | case OSCILLOSCOPE_SPEED_UP | BUTTON_REPEAT: |
345 | if (osc_delay > 1) | 537 | if (osc_delay > 1) |
538 | { | ||
346 | osc_delay--; | 539 | osc_delay--; |
540 | tell_speed = true; | ||
541 | } | ||
347 | break; | 542 | break; |
348 | 543 | ||
349 | case OSCILLOSCOPE_SPEED_DOWN: | 544 | case OSCILLOSCOPE_SPEED_DOWN: |
350 | case OSCILLOSCOPE_SPEED_DOWN | BUTTON_REPEAT: | 545 | case OSCILLOSCOPE_SPEED_DOWN | BUTTON_REPEAT: |
351 | osc_delay++; | 546 | osc_delay++; |
547 | tell_speed = true; | ||
352 | break; | 548 | break; |
353 | 549 | ||
354 | case OSCILLOSCOPE_VOL_UP: | 550 | case OSCILLOSCOPE_VOL_UP: |
@@ -381,8 +577,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
381 | } | 577 | } |
382 | if (button != BUTTON_NONE) | 578 | if (button != BUTTON_NONE) |
383 | lastbutton = button; | 579 | lastbutton = button; |
580 | |||
581 | if (tell_speed) | ||
582 | { | ||
583 | rb->snprintf(message, sizeof(message), "Speed: %d", 100 / osc_delay); | ||
584 | displaymsg = true; | ||
585 | } | ||
384 | } | 586 | } |
385 | cleanup(NULL); | 587 | cleanup(NULL); |
386 | return PLUGIN_OK; | 588 | return PLUGIN_OK; |
387 | } | 589 | } |
388 | #endif /* if HAVE_LCD_BITMAP */ | 590 | #endif /* HAVE_LCD_BITMAP */ |