1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Oscilloscope, with many different modes of operation.
12 * Copyright (C) 2004-2006 Jens Arnold
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
25 #include "lib/helper.h"
27 #ifdef HAVE_LCD_BITMAP
29 #include "lib/configfile.h"
33 /* variable button definitions */
34 #if CONFIG_KEYPAD == RECORDER_PAD
35 #define OSCILLOSCOPE_QUIT BUTTON_OFF
36 #define OSCILLOSCOPE_DRAWMODE BUTTON_F1
37 #define OSCILLOSCOPE_ADVMODE BUTTON_F2
38 #define OSCILLOSCOPE_ORIENTATION BUTTON_F3
39 #define OSCILLOSCOPE_PAUSE BUTTON_PLAY
40 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
41 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
42 #define OSCILLOSCOPE_VOL_UP BUTTON_UP
43 #define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
45 #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
46 #define OSCILLOSCOPE_QUIT BUTTON_OFF
47 #define OSCILLOSCOPE_DRAWMODE BUTTON_F1
48 #define OSCILLOSCOPE_ADVMODE BUTTON_F2
49 #define OSCILLOSCOPE_ORIENTATION BUTTON_F3
50 #define OSCILLOSCOPE_PAUSE BUTTON_SELECT
51 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
52 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
53 #define OSCILLOSCOPE_VOL_UP BUTTON_UP
54 #define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
56 #elif CONFIG_KEYPAD == ONDIO_PAD
57 #define OSCILLOSCOPE_QUIT BUTTON_OFF
58 #define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_MENU
59 #define OSCILLOSCOPE_DRAWMODE (BUTTON_MENU | BUTTON_REL)
60 #define OSCILLOSCOPE_ADVMODE (BUTTON_MENU | BUTTON_RIGHT)
61 #define OSCILLOSCOPE_ORIENTATION (BUTTON_MENU | BUTTON_LEFT)
62 #define OSCILLOSCOPE_PAUSE (BUTTON_MENU | BUTTON_OFF)
63 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
64 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
65 #define OSCILLOSCOPE_VOL_UP BUTTON_UP
66 #define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
68 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
69 #define OSCILLOSCOPE_QUIT BUTTON_OFF
70 #define OSCILLOSCOPE_DRAWMODE BUTTON_SELECT
71 #define OSCILLOSCOPE_ADVMODE BUTTON_MODE
72 #define OSCILLOSCOPE_ORIENTATION BUTTON_REC
73 #define OSCILLOSCOPE_PAUSE BUTTON_ON
74 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
75 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
76 #define OSCILLOSCOPE_VOL_UP BUTTON_UP
77 #define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
78 #define OSCILLOSCOPE_RC_QUIT BUTTON_RC_STOP
80 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
81 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
82 #define OSCILLOSCOPE_QUIT (BUTTON_SELECT | BUTTON_MENU)
83 #define OSCILLOSCOPE_DRAWMODE (BUTTON_SELECT | BUTTON_PLAY)
84 #define OSCILLOSCOPE_ADVMODE (BUTTON_SELECT | BUTTON_RIGHT)
85 #define OSCILLOSCOPE_ORIENTATION (BUTTON_SELECT | BUTTON_LEFT)
86 #define OSCILLOSCOPE_PAUSE BUTTON_PLAY
87 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
88 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
89 #define OSCILLOSCOPE_VOL_UP BUTTON_SCROLL_FWD
90 #define OSCILLOSCOPE_VOL_DOWN BUTTON_SCROLL_BACK
92 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
93 #define OSCILLOSCOPE_QUIT BUTTON_POWER
94 #define OSCILLOSCOPE_DRAWMODE BUTTON_SELECT
95 #define OSCILLOSCOPE_ADVMODE BUTTON_DOWN
96 #define OSCILLOSCOPE_ORIENTATION BUTTON_UP
97 #define OSCILLOSCOPE_PAUSE BUTTON_A
98 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
99 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
100 #define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
101 #define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
103 #elif (CONFIG_KEYPAD == SANSA_E200_PAD)
104 #define OSCILLOSCOPE_QUIT BUTTON_POWER
105 #define OSCILLOSCOPE_DRAWMODE BUTTON_SELECT
106 #define OSCILLOSCOPE_ADVMODE BUTTON_DOWN
107 #define OSCILLOSCOPE_ORIENTATION BUTTON_UP
108 #define OSCILLOSCOPE_PAUSE BUTTON_REC
109 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
110 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
111 #define OSCILLOSCOPE_VOL_UP BUTTON_SCROLL_FWD
112 #define OSCILLOSCOPE_VOL_DOWN BUTTON_SCROLL_BACK
114 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
115 #define OSCILLOSCOPE_QUIT (BUTTON_HOME|BUTTON_REPEAT)
116 #define OSCILLOSCOPE_DRAWMODE (BUTTON_SELECT | BUTTON_REL)
117 #define OSCILLOSCOPE_ADVMODE (BUTTON_SELECT | BUTTON_RIGHT)
118 #define OSCILLOSCOPE_ORIENTATION (BUTTON_SELECT | BUTTON_LEFT)
119 #define OSCILLOSCOPE_PAUSE BUTTON_UP
120 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
121 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
122 #define OSCILLOSCOPE_VOL_UP BUTTON_SCROLL_FWD
123 #define OSCILLOSCOPE_VOL_DOWN BUTTON_SCROLL_BACK
125 #elif (CONFIG_KEYPAD == SANSA_C200_PAD)
126 #define OSCILLOSCOPE_QUIT BUTTON_POWER
127 #define OSCILLOSCOPE_DRAWMODE BUTTON_SELECT
128 #define OSCILLOSCOPE_ADVMODE BUTTON_DOWN
129 #define OSCILLOSCOPE_ORIENTATION BUTTON_UP
130 #define OSCILLOSCOPE_PAUSE BUTTON_REC
131 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
132 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
133 #define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
134 #define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
136 #elif (CONFIG_KEYPAD == SANSA_CLIP_PAD)
137 #define OSCILLOSCOPE_QUIT BUTTON_POWER
138 #define OSCILLOSCOPE_DRAWMODE BUTTON_SELECT
139 #define OSCILLOSCOPE_ADVMODE BUTTON_DOWN
140 #define OSCILLOSCOPE_ORIENTATION BUTTON_UP
141 #define OSCILLOSCOPE_PAUSE BUTTON_HOME
142 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
143 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
144 #define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
145 #define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
147 #elif (CONFIG_KEYPAD == SANSA_M200_PAD)
148 #define OSCILLOSCOPE_QUIT BUTTON_POWER
149 #define OSCILLOSCOPE_DRAWMODE (BUTTON_SELECT | BUTTON_REL)
150 #define OSCILLOSCOPE_ADVMODE BUTTON_DOWN
151 #define OSCILLOSCOPE_ORIENTATION BUTTON_UP
152 #define OSCILLOSCOPE_PAUSE (BUTTON_SELECT | BUTTON_UP)
153 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
154 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
155 #define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
156 #define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
158 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
159 #define OSCILLOSCOPE_QUIT BUTTON_POWER
160 #define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_SELECT
161 #define OSCILLOSCOPE_DRAWMODE (BUTTON_SELECT | BUTTON_REL)
162 #define OSCILLOSCOPE_ADVMODE BUTTON_REC
163 #define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_SELECT
164 #define OSCILLOSCOPE_ORIENTATION (BUTTON_SELECT | BUTTON_REPEAT)
165 #define OSCILLOSCOPE_PAUSE BUTTON_PLAY
166 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
167 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
168 #define OSCILLOSCOPE_VOL_UP BUTTON_UP
169 #define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
171 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
172 #define OSCILLOSCOPE_QUIT BUTTON_POWER
173 #define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_REW
174 #define OSCILLOSCOPE_DRAWMODE (BUTTON_REW | BUTTON_REL)
175 #define OSCILLOSCOPE_ADVMODE BUTTON_FF
176 #define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_REW
177 #define OSCILLOSCOPE_ORIENTATION (BUTTON_REW | BUTTON_REPEAT)
178 #define OSCILLOSCOPE_PAUSE BUTTON_PLAY
179 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
180 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
181 #define OSCILLOSCOPE_VOL_UP BUTTON_SCROLL_UP
182 #define OSCILLOSCOPE_VOL_DOWN BUTTON_SCROLL_DOWN
184 #elif CONFIG_KEYPAD == GIGABEAT_S_PAD
185 #define OSCILLOSCOPE_QUIT BUTTON_BACK
186 #define OSCILLOSCOPE_DRAWMODE BUTTON_PREV
187 #define OSCILLOSCOPE_ADVMODE BUTTON_NEXT
188 #define OSCILLOSCOPE_ORIENTATION BUTTON_MENU
189 #define OSCILLOSCOPE_PAUSE BUTTON_PLAY
190 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
191 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
192 #define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
193 #define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
195 #elif (CONFIG_KEYPAD == MROBE100_PAD)
196 #define OSCILLOSCOPE_QUIT BUTTON_POWER
197 #define OSCILLOSCOPE_DRAWMODE BUTTON_SELECT
198 #define OSCILLOSCOPE_ADVMODE BUTTON_MENU
199 #define OSCILLOSCOPE_ORIENTATION BUTTON_PLAY
200 #define OSCILLOSCOPE_PAUSE BUTTON_DISPLAY
201 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
202 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
203 #define OSCILLOSCOPE_VOL_UP BUTTON_UP
204 #define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
206 #elif CONFIG_KEYPAD == IAUDIO_M3_PAD
207 #define OSCILLOSCOPE_QUIT BUTTON_RC_REC
208 #define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_RC_MODE
209 #define OSCILLOSCOPE_DRAWMODE (BUTTON_RC_MODE|BUTTON_REL)
210 #define OSCILLOSCOPE_ADVMODE BUTTON_RC_MENU
211 #define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_RC_MODE
212 #define OSCILLOSCOPE_ORIENTATION (BUTTON_RC_MODE|BUTTON_REPEAT)
213 #define OSCILLOSCOPE_PAUSE BUTTON_RC_PLAY
214 #define OSCILLOSCOPE_SPEED_UP BUTTON_RC_FF
215 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_RC_REW
216 #define OSCILLOSCOPE_VOL_UP BUTTON_RC_VOL_UP
217 #define OSCILLOSCOPE_VOL_DOWN BUTTON_RC_VOL_DOWN
219 #elif CONFIG_KEYPAD == COWOND2_PAD
220 #define OSCILLOSCOPE_QUIT BUTTON_POWER
221 #define OSCILLOSCOPE_VOL_UP BUTTON_PLUS
222 #define OSCILLOSCOPE_VOL_DOWN BUTTON_MINUS
224 #elif CONFIG_KEYPAD == CREATIVEZVM_PAD
225 #define OSCILLOSCOPE_QUIT BUTTON_BACK
226 #define OSCILLOSCOPE_DRAWMODE BUTTON_SELECT
227 #define OSCILLOSCOPE_ADVMODE BUTTON_CUSTOM
228 #define OSCILLOSCOPE_ORIENTATION BUTTON_MENU
229 #define OSCILLOSCOPE_PAUSE BUTTON_PLAY
230 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
231 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
232 #define OSCILLOSCOPE_VOL_UP BUTTON_UP
233 #define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
235 #elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
236 #define OSCILLOSCOPE_QUIT BUTTON_POWER
237 #define OSCILLOSCOPE_DRAWMODE BUTTON_MENU
238 #define OSCILLOSCOPE_ADVMODE BUTTON_VIEW
239 #define OSCILLOSCOPE_ORIENTATION BUTTON_UP
240 #define OSCILLOSCOPE_PAUSE BUTTON_SELECT
241 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
242 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
243 #define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
244 #define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
246 #elif CONFIG_KEYPAD == ONDAVX747_PAD
247 #define OSCILLOSCOPE_QUIT BUTTON_POWER
248 #define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
249 #define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
251 #elif CONFIG_KEYPAD == MROBE500_PAD
252 #define OSCILLOSCOPE_QUIT BUTTON_POWER
254 #elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
255 #define OSCILLOSCOPE_QUIT BUTTON_REC
256 #define OSCILLOSCOPE_DRAWMODE (BUTTON_PLAY|BUTTON_LEFT)
257 #define OSCILLOSCOPE_ADVMODE (BUTTON_PLAY|BUTTON_RIGHT)
258 #define OSCILLOSCOPE_ORIENTATION (BUTTON_PLAY|BUTTON_UP)
259 #define OSCILLOSCOPE_PAUSE (BUTTON_PLAY|BUTTON_DOWN)
260 #define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
261 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
262 #define OSCILLOSCOPE_VOL_UP BUTTON_UP
263 #define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
266 #error No keymap defined!
269 #ifdef HAVE_TOUCHSCREEN
270 #ifndef OSCILLOSCOPE_QUIT
271 #define OSCILLOSCOPE_QUIT BUTTON_TOPLEFT
273 #ifndef OSCILLOSCOPE_DRAWMODE
274 #define OSCILLOSCOPE_DRAWMODE BUTTON_TOPMIDDLE
276 #ifndef OSCILLOSCOPE_ADVMODE
277 #define OSCILLOSCOPE_ADVMODE BUTTON_BOTTOMMIDDLE
279 #ifndef OSCILLOSCOPE_ORIENTATION
280 #define OSCILLOSCOPE_ORIENTATION BUTTON_BOTTOMLEFT
282 #ifndef OSCILLOSCOPE_PAUSE
283 #define OSCILLOSCOPE_PAUSE BUTTON_CENTER
285 #ifndef OSCILLOSCOPE_SPEED_UP
286 #define OSCILLOSCOPE_SPEED_UP BUTTON_MIDRIGHT
288 #ifndef OSCILLOSCOPE_SPEED_DOWN
289 #define OSCILLOSCOPE_SPEED_DOWN BUTTON_MIDLEFT
291 #ifndef OSCILLOSCOPE_VOL_UP
292 #define OSCILLOSCOPE_VOL_UP BUTTON_TOPRIGHT
294 #ifndef OSCILLOSCOPE_VOL_DOWN
295 #define OSCILLOSCOPE_VOL_DOWN BUTTON_BOTTOMRIGHT
301 #ifdef HAVE_LCD_COLOR
302 #define BACKG_COLOR LCD_BLACK
303 #define GRAPH_COLOR LCD_RGBPACK(128, 255, 0)
304 #define CURSOR_COLOR LCD_RGBPACK(255, 0, 0)
306 #define BACKG_COLOR LCD_WHITE
307 #define GRAPH_COLOR LCD_BLACK
308 #define CURSOR_COLOR LCD_DARKGRAY
312 enum { DRAW_FILLED
, DRAW_LINE
, DRAW_PIXEL
, MAX_DRAW
};
313 enum { ADV_SCROLL
, ADV_WRAP
, MAX_ADV
};
314 enum { OSC_HORIZ
, OSC_VERT
, MAX_OSC
};
316 #define CFGFILE_VERSION 0 /* Current config file version */
317 #define CFGFILE_MINVERSION 0 /* Minimum config file version to accept */
320 #define MAX_PEAK 0x8000
322 #if defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
323 #define mas_codec_readreg(x) rand()%MAX_PEAK
326 /* global variables */
330 int delay
; /* in ticks */
336 struct osc_config osc_disk
= { 2, DRAW_FILLED
, ADV_SCROLL
, OSC_HORIZ
};
337 struct osc_config osc
; /* running config */
339 static const char cfg_filename
[] = "oscilloscope.cfg";
340 static char *draw_str
[3] = { "filled", "line", "pixel" };
341 static char *advance_str
[2] = { "scroll", "wrap" };
342 static char *orientation_str
[2] = { "horizontal", "vertical" };
344 struct configdata disk_config
[] = {
345 { TYPE_INT
, 1, 99, { .int_p
= &osc_disk
.delay
}, "delay", NULL
},
346 { TYPE_ENUM
, 0, MAX_DRAW
, { .int_p
= &osc_disk
.draw
}, "draw", draw_str
},
347 { TYPE_ENUM
, 0, MAX_ADV
, { .int_p
= &osc_disk
.advance
}, "advance",
349 { TYPE_ENUM
, 0, MAX_OSC
, { .int_p
= &osc_disk
.orientation
}, "orientation",
354 long last_tick
= 0; /* time of last drawing */
355 int last_pos
= 0; /* last x or y drawing position. Reset for aspect switch. */
356 int last_left
; /* last channel values */
359 unsigned char message
[16]; /* message to display */
360 bool displaymsg
= false;
365 void anim_horizontal(int cur_left
, int cur_right
)
368 int left
, right
, dl
, dr
;
369 long cur_tick
= *rb
->current_tick
;
370 long d
= (cur_tick
- last_tick
) / osc
.delay
;
371 bool full_update
= false;
373 if (d
== 0) /* too early, bail out */
376 last_tick
= cur_tick
;
378 if (d
> HZ
) /* first call or too much delay, (re)start */
380 last_left
= cur_left
;
381 last_right
= cur_right
;
384 cur_x
= last_pos
+ d
;
386 if (cur_x
>= LCD_WIDTH
)
388 if (osc
.advance
== ADV_SCROLL
)
390 int shift
= cur_x
- (LCD_WIDTH
-1);
391 xlcd_scroll_left(shift
);
401 rb
->lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
403 if (cur_x
> last_pos
)
405 rb
->lcd_fillrect(last_pos
+ 1, 0, d
, LCD_HEIGHT
);
409 rb
->lcd_fillrect(last_pos
+ 1, 0, LCD_WIDTH
- last_pos
, LCD_HEIGHT
);
410 rb
->lcd_fillrect(0, 0, cur_x
+ 1, LCD_HEIGHT
);
412 rb
->lcd_set_drawmode(DRMODE_SOLID
);
419 dl
= (cur_left
- left
) / d
;
420 dr
= (cur_right
- right
) / d
;
422 for (x
= last_pos
+ 1; d
> 0; x
++, d
--)
430 rb
->lcd_vline(x
, LCD_HEIGHT
/2-1,
431 LCD_HEIGHT
/2-1 - (((LCD_HEIGHT
-2) * left
) >> 16));
432 rb
->lcd_vline(x
, LCD_HEIGHT
/2+1,
433 LCD_HEIGHT
/2+1 + (((LCD_HEIGHT
-2) * right
) >> 16));
438 if (cur_x
> last_pos
)
441 last_pos
, LCD_HEIGHT
/2-1 - (((LCD_HEIGHT
-2) * last_left
) >> 16),
442 cur_x
, LCD_HEIGHT
/2-1 - (((LCD_HEIGHT
-2) * cur_left
) >> 16)
445 last_pos
, LCD_HEIGHT
/2+1 + (((LCD_HEIGHT
-2) * last_right
) >> 16),
446 cur_x
, LCD_HEIGHT
/2+1 + (((LCD_HEIGHT
-2) * cur_right
) >> 16)
452 + (LCD_WIDTH
- last_pos
) * (last_left
- cur_left
) / d
;
454 + (LCD_WIDTH
- last_pos
) * (last_right
- cur_right
) / d
;
457 last_pos
, LCD_HEIGHT
/2-1 - (((LCD_HEIGHT
-2) * last_left
) >> 16),
458 LCD_WIDTH
, LCD_HEIGHT
/2-1 - (((LCD_HEIGHT
-2) * left
) >> 16)
461 last_pos
, LCD_HEIGHT
/2+1 + (((LCD_HEIGHT
-2) * last_right
) >> 16),
462 LCD_WIDTH
, LCD_HEIGHT
/2+1 + (((LCD_HEIGHT
-2) * right
) >> 16)
467 0, LCD_HEIGHT
/2-1 - (((LCD_HEIGHT
-2) * left
) >> 16),
468 cur_x
, LCD_HEIGHT
/2-1 - (((LCD_HEIGHT
-2) * cur_left
) >> 16)
471 0, LCD_HEIGHT
/2+1 + (((LCD_HEIGHT
-2) * right
) >> 16),
472 cur_x
, LCD_HEIGHT
/2+1 + (((LCD_HEIGHT
-2) * cur_right
) >> 16)
481 dl
= (cur_left
- left
) / d
;
482 dr
= (cur_right
- right
) / d
;
484 for (x
= last_pos
+ 1; d
> 0; x
++, d
--)
492 rb
->lcd_drawpixel(x
, LCD_HEIGHT
/2-1 - (((LCD_HEIGHT
-2) * left
) >> 16));
493 rb
->lcd_drawpixel(x
, LCD_HEIGHT
/2+1 + (((LCD_HEIGHT
-2) * right
) >> 16));
498 last_left
= cur_left
;
499 last_right
= cur_right
;
505 rb
->lcd_getstringsize(message
, &width
, NULL
);
506 last_pos
-= width
- 1;
507 rb
->lcd_putsxy(last_pos
, 0, message
);
520 #if LCD_DEPTH > 1 /* cursor bar */
521 rb
->lcd_set_foreground(CURSOR_COLOR
);
522 rb
->lcd_vline(cur_x
+ 1, 0, LCD_HEIGHT
-1);
523 rb
->lcd_set_foreground(GRAPH_COLOR
);
525 rb
->lcd_set_drawmode(DRMODE_COMPLEMENT
);
526 rb
->lcd_vline(cur_x
+ 1, 0, LCD_HEIGHT
-1);
527 rb
->lcd_set_drawmode(DRMODE_SOLID
);
530 if (cur_x
> last_pos
)
532 rb
->lcd_update_rect(last_pos
, 0, cur_x
- last_pos
+ 2, LCD_HEIGHT
);
536 rb
->lcd_update_rect(last_pos
, 0, LCD_WIDTH
- last_pos
, LCD_HEIGHT
);
537 rb
->lcd_update_rect(0, 0, cur_x
+ 2, LCD_HEIGHT
);
543 void anim_vertical(int cur_left
, int cur_right
)
546 int left
, right
, dl
, dr
;
547 long cur_tick
= *rb
->current_tick
;
548 long d
= (cur_tick
- last_tick
) / osc
.delay
;
549 bool full_update
= false;
551 if (d
== 0) /* too early, bail out */
554 last_tick
= cur_tick
;
556 if (d
> HZ
) /* first call or too much delay, (re)start */
558 last_left
= cur_left
;
559 last_right
= cur_right
;
562 cur_y
= last_pos
+ d
;
564 if (cur_y
>= LCD_HEIGHT
)
566 if (osc
.advance
== ADV_SCROLL
)
568 int shift
= cur_y
- (LCD_HEIGHT
-1);
569 xlcd_scroll_up(shift
);
579 rb
->lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
581 if (cur_y
> last_pos
)
583 rb
->lcd_fillrect(0, last_pos
+ 1, LCD_WIDTH
, d
);
587 rb
->lcd_fillrect(0, last_pos
+ 1, LCD_WIDTH
, LCD_HEIGHT
- last_pos
);
588 rb
->lcd_fillrect(0, 0, LCD_WIDTH
, cur_y
+ 1);
590 rb
->lcd_set_drawmode(DRMODE_SOLID
);
597 dl
= (cur_left
- left
) / d
;
598 dr
= (cur_right
- right
) / d
;
600 for (y
= last_pos
+ 1; d
> 0; y
++, d
--)
608 rb
->lcd_hline(LCD_WIDTH
/2-1,
609 LCD_WIDTH
/2-1 - (((LCD_WIDTH
-2) * left
) >> 16), y
);
610 rb
->lcd_hline(LCD_WIDTH
/2+1,
611 LCD_WIDTH
/2+1 + (((LCD_WIDTH
-2) * right
) >> 16), y
);
616 if (cur_y
> last_pos
)
619 LCD_WIDTH
/2-1 - (((LCD_WIDTH
-2) * last_left
) >> 16), last_pos
,
620 LCD_WIDTH
/2-1 - (((LCD_WIDTH
-2) * cur_left
) >> 16), cur_y
623 LCD_WIDTH
/2+1 + (((LCD_WIDTH
-2) * last_right
) >> 16), last_pos
,
624 LCD_WIDTH
/2+1 + (((LCD_WIDTH
-2) * cur_right
) >> 16), cur_y
630 + (LCD_HEIGHT
- last_pos
) * (last_left
- cur_left
) / d
;
632 + (LCD_HEIGHT
- last_pos
) * (last_right
- cur_right
) / d
;
635 LCD_WIDTH
/2-1 - (((LCD_WIDTH
-2) * last_left
) >> 16), last_pos
,
636 LCD_WIDTH
/2-1 - (((LCD_WIDTH
-2) * left
) >> 16), LCD_HEIGHT
639 LCD_WIDTH
/2+1 + (((LCD_WIDTH
-2) * last_right
) >> 16), last_pos
,
640 LCD_WIDTH
/2+1 + (((LCD_WIDTH
-2) * right
) >> 16), LCD_HEIGHT
645 LCD_WIDTH
/2-1 - (((LCD_WIDTH
-2) * left
) >> 16), 0,
646 LCD_WIDTH
/2-1 - (((LCD_WIDTH
-2) * cur_left
) >> 16), cur_y
649 LCD_WIDTH
/2+1 + (((LCD_WIDTH
-2) * right
) >> 16), 0,
650 LCD_WIDTH
/2+1 + (((LCD_WIDTH
-2) * cur_right
) >> 16), cur_y
659 dl
= (cur_left
- left
) / d
;
660 dr
= (cur_right
- right
) / d
;
662 for (y
= last_pos
+ 1; d
> 0; y
++, d
--)
670 rb
->lcd_drawpixel(LCD_WIDTH
/2-1 - (((LCD_WIDTH
-2) * left
) >> 16), y
);
671 rb
->lcd_drawpixel(LCD_WIDTH
/2+1 + (((LCD_WIDTH
-2) * right
) >> 16), y
);
676 last_left
= cur_left
;
677 last_right
= cur_right
;
681 last_pos
-= font_height
- 1;
682 rb
->lcd_putsxy(0, last_pos
, message
);
695 #if LCD_DEPTH > 1 /* cursor bar */
696 rb
->lcd_set_foreground(CURSOR_COLOR
);
697 rb
->lcd_hline(0, LCD_WIDTH
-1, cur_y
+ 1);
698 rb
->lcd_set_foreground(GRAPH_COLOR
);
700 rb
->lcd_set_drawmode(DRMODE_COMPLEMENT
);
701 rb
->lcd_hline(0, LCD_WIDTH
-1, cur_y
+ 1);
702 rb
->lcd_set_drawmode(DRMODE_SOLID
);
705 if (cur_y
> last_pos
)
707 rb
->lcd_update_rect(0, last_pos
, LCD_WIDTH
, cur_y
- last_pos
+ 2);
711 rb
->lcd_update_rect(0, last_pos
, LCD_WIDTH
, LCD_HEIGHT
- last_pos
);
712 rb
->lcd_update_rect(0, 0, LCD_WIDTH
, cur_y
+ 2);
718 void cleanup(void *parameter
)
722 rb
->lcd_set_foreground(LCD_DEFAULT_FG
);
723 rb
->lcd_set_background(LCD_DEFAULT_BG
);
725 /* Turn on backlight timeout (revert to settings) */
726 backlight_use_settings(); /* backlight control in lib/helper.c */
729 enum plugin_status
plugin_start(const void* parameter
)
732 int lastbutton
= BUTTON_NONE
;
739 configfile_load(cfg_filename
, disk_config
,
740 sizeof(disk_config
) / sizeof(disk_config
[0]),
742 rb
->memcpy(&osc
, &osc_disk
, sizeof(osc
)); /* copy to running config */
745 rb
->lcd_set_foreground(GRAPH_COLOR
);
746 rb
->lcd_set_background(BACKG_COLOR
);
747 rb
->lcd_set_backdrop(NULL
);
748 rb
->lcd_clear_display();
752 /* Turn off backlight timeout */
753 backlight_force_on(); /* backlight control in lib/helper.c */
755 rb
->lcd_getstringsize("A", NULL
, &font_height
);
763 rb
->sleep(MAX(last_tick
+ osc
.delay
- *rb
->current_tick
- 1, 0));
765 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
766 left
= rb
->mas_codec_readreg(0xC);
767 right
= rb
->mas_codec_readreg(0xD);
768 #elif (CONFIG_CODEC == SWCODEC)
769 rb
->pcm_calculate_peaks(&left
, &right
);
771 if (osc
.orientation
== OSC_HORIZ
)
772 anim_horizontal(left
, right
);
774 anim_vertical(left
, right
);
778 button
= rb
->button_get(paused
);
781 #ifdef OSCILLOSCOPE_RC_QUIT
782 case OSCILLOSCOPE_RC_QUIT
:
784 case OSCILLOSCOPE_QUIT
:
788 case OSCILLOSCOPE_ADVMODE
:
789 if (++osc
.advance
>= MAX_ADV
)
793 case OSCILLOSCOPE_DRAWMODE
:
794 #ifdef OSCILLOSCOPE_DRAWMODE_PRE
795 if (lastbutton
!= OSCILLOSCOPE_DRAWMODE_PRE
)
798 if (++osc
.draw
>= MAX_DRAW
)
802 case OSCILLOSCOPE_ORIENTATION
:
803 #ifdef OSCILLOSCOPE_ORIENTATION_PRE
804 if (lastbutton
!= OSCILLOSCOPE_ORIENTATION_PRE
)
807 if (++osc
.orientation
>= MAX_OSC
)
812 rb
->lcd_clear_display();
816 case OSCILLOSCOPE_PAUSE
:
821 case OSCILLOSCOPE_SPEED_UP
:
822 case OSCILLOSCOPE_SPEED_UP
| BUTTON_REPEAT
:
830 case OSCILLOSCOPE_SPEED_DOWN
:
831 case OSCILLOSCOPE_SPEED_DOWN
| BUTTON_REPEAT
:
836 case OSCILLOSCOPE_VOL_UP
:
837 case OSCILLOSCOPE_VOL_UP
| BUTTON_REPEAT
:
838 vol
= rb
->global_settings
->volume
;
839 if (vol
< rb
->sound_max(SOUND_VOLUME
))
842 rb
->sound_set(SOUND_VOLUME
, vol
);
843 rb
->global_settings
->volume
= vol
;
847 case OSCILLOSCOPE_VOL_DOWN
:
848 case OSCILLOSCOPE_VOL_DOWN
| BUTTON_REPEAT
:
849 vol
= rb
->global_settings
->volume
;
850 if (vol
> rb
->sound_min(SOUND_VOLUME
))
853 rb
->sound_set(SOUND_VOLUME
, vol
);
854 rb
->global_settings
->volume
= vol
;
859 if (rb
->default_event_handler_ex(button
, cleanup
, NULL
)
860 == SYS_USB_CONNECTED
)
861 return PLUGIN_USB_CONNECTED
;
864 if (button
!= BUTTON_NONE
)
869 rb
->snprintf(message
, sizeof(message
), "%s%d",
870 (osc
.orientation
== OSC_VERT
) ? "Speed: " : "",
876 if (rb
->memcmp(&osc
, &osc_disk
, sizeof(osc
))) /* save settings if changed */
878 rb
->memcpy(&osc_disk
, &osc
, sizeof(osc
));
879 configfile_save(cfg_filename
, disk_config
,
880 sizeof(disk_config
) / sizeof(disk_config
[0]),
885 #endif /* HAVE_LCD_BITMAP */