blob: 76ff5f5744196d1e195b6606dfc34f94f4ef54b9 [file] [log] [blame]
Jens Arnolddb14d8e2004-11-07 10:31:39 +00001/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
Jens Arnoldf9765d32006-03-11 01:13:51 +000010* Oscilloscope, with many different modes of operation.
Jens Arnolddb14d8e2004-11-07 10:31:39 +000011*
Jens Arnoldb318b3e2006-03-09 07:52:26 +000012* Copyright (C) 2004-2006 Jens Arnold
Jens Arnolddb14d8e2004-11-07 10:31:39 +000013*
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000014* 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.
Jens Arnolddb14d8e2004-11-07 10:31:39 +000018*
19* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20* KIND, either express or implied.
21*
22****************************************************************************/
23
Jens Arnolddb14d8e2004-11-07 10:31:39 +000024#include "plugin.h"
Peter D'Hoyecb53e3c2007-08-15 12:42:09 +000025#include "helper.h"
Jens Arnolddb14d8e2004-11-07 10:31:39 +000026
Jens Arnoldb318b3e2006-03-09 07:52:26 +000027#ifdef HAVE_LCD_BITMAP
Jens Arnold19b45a42006-03-08 01:14:46 +000028#include "xlcd.h"
Jens Arnoldf9765d32006-03-11 01:13:51 +000029#include "configfile.h"
Jens Arnolddb14d8e2004-11-07 10:31:39 +000030
Jens Arnolda36b1d42006-01-15 18:20:18 +000031PLUGIN_HEADER
32
Jens Arnolddb14d8e2004-11-07 10:31:39 +000033/* variable button definitions */
34#if CONFIG_KEYPAD == RECORDER_PAD
Jens Arnoldf9765d32006-03-11 01:13:51 +000035#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
Jens Arnolddb14d8e2004-11-07 10:31:39 +000044
Dave Chapmand64e6262007-01-14 13:48:09 +000045#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
55
Jens Arnolddb14d8e2004-11-07 10:31:39 +000056#elif CONFIG_KEYPAD == ONDIO_PAD
Jens Arnoldf9765d32006-03-11 01:13:51 +000057#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
Jens Arnoldb318b3e2006-03-09 07:52:26 +000067
68#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
Jens Arnoldf9765d32006-03-11 01:13:51 +000069#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
Kevin Ferrare0e027bd2006-06-30 16:43:47 +000078#define OSCILLOSCOPE_RC_QUIT BUTTON_RC_STOP
Jens Arnold61e798f2007-04-09 17:03:48 +000079
Jens Arnoldb7013222007-07-27 09:57:27 +000080#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
81 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
Jens Arnoldf9765d32006-03-11 01:13:51 +000082#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
Jens Arnoldb318b3e2006-03-09 07:52:26 +000091
92#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
Jens Arnoldf9765d32006-03-11 01:13:51 +000093#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
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000102
Barry Wardell24f4a2a2006-10-26 13:38:09 +0000103#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
Jonathan Gordon81ba1462008-01-10 08:08:31 +0000111#define OSCILLOSCOPE_VOL_UP BUTTON_SCROLL_FWD
112#define OSCILLOSCOPE_VOL_DOWN BUTTON_SCROLL_BACK
Barry Wardell24f4a2a2006-10-26 13:38:09 +0000113
Marianne Arnold12ddb8e2007-09-20 10:49:48 +0000114#elif (CONFIG_KEYPAD == SANSA_C200_PAD)
115#define OSCILLOSCOPE_QUIT BUTTON_POWER
116#define OSCILLOSCOPE_DRAWMODE BUTTON_SELECT
117#define OSCILLOSCOPE_ADVMODE BUTTON_DOWN
118#define OSCILLOSCOPE_ORIENTATION BUTTON_UP
119#define OSCILLOSCOPE_PAUSE BUTTON_REC
120#define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
121#define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
122#define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
123#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
124
Jens Arnold85a226d2007-03-16 23:02:39 +0000125#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
Jens Arnoldf9765d32006-03-11 01:13:51 +0000126#define OSCILLOSCOPE_QUIT BUTTON_POWER
127#define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_SELECT
128#define OSCILLOSCOPE_DRAWMODE (BUTTON_SELECT | BUTTON_REL)
129#define OSCILLOSCOPE_ADVMODE BUTTON_REC
Jens Arnold61e798f2007-04-09 17:03:48 +0000130#define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_SELECT
Jens Arnoldf9765d32006-03-11 01:13:51 +0000131#define OSCILLOSCOPE_ORIENTATION (BUTTON_SELECT | BUTTON_REPEAT)
132#define OSCILLOSCOPE_PAUSE BUTTON_PLAY
133#define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
134#define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
135#define OSCILLOSCOPE_VOL_UP BUTTON_UP
136#define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000137
Daniel Stenberg1e88be52006-08-03 20:17:25 +0000138#elif CONFIG_KEYPAD == IRIVER_H10_PAD
139#define OSCILLOSCOPE_QUIT BUTTON_POWER
140#define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_REW
141#define OSCILLOSCOPE_DRAWMODE (BUTTON_REW | BUTTON_REL)
142#define OSCILLOSCOPE_ADVMODE BUTTON_FF
Jens Arnold61e798f2007-04-09 17:03:48 +0000143#define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_REW
Daniel Stenberg1e88be52006-08-03 20:17:25 +0000144#define OSCILLOSCOPE_ORIENTATION (BUTTON_REW | BUTTON_REPEAT)
145#define OSCILLOSCOPE_PAUSE BUTTON_PLAY
146#define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
147#define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
148#define OSCILLOSCOPE_VOL_UP BUTTON_SCROLL_UP
149#define OSCILLOSCOPE_VOL_DOWN BUTTON_SCROLL_DOWN
150
Will Robertson8215b342008-02-17 12:23:02 +0000151#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
152#define OSCILLOSCOPE_QUIT BUTTON_BACK
153#define OSCILLOSCOPE_DRAWMODE BUTTON_PREV
154#define OSCILLOSCOPE_ADVMODE BUTTON_NEXT
155#define OSCILLOSCOPE_ORIENTATION BUTTON_MENU
156#define OSCILLOSCOPE_PAUSE BUTTON_PLAY
157#define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
158#define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
159#define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
160#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
161
Robert Kuklad6c8b572008-03-01 22:55:09 +0000162#elif (CONFIG_KEYPAD == MROBE100_PAD)
163#define OSCILLOSCOPE_QUIT BUTTON_POWER
164#define OSCILLOSCOPE_DRAWMODE BUTTON_SELECT
165#define OSCILLOSCOPE_ADVMODE BUTTON_MENU
166#define OSCILLOSCOPE_ORIENTATION BUTTON_PLAY
167#define OSCILLOSCOPE_PAUSE BUTTON_DISPLAY
168#define OSCILLOSCOPE_SPEED_UP BUTTON_RIGHT
169#define OSCILLOSCOPE_SPEED_DOWN BUTTON_LEFT
170#define OSCILLOSCOPE_VOL_UP BUTTON_UP
171#define OSCILLOSCOPE_VOL_DOWN BUTTON_DOWN
Will Robertson8215b342008-02-17 12:23:02 +0000172
Jens Arnold29361ab2008-03-22 10:24:28 +0000173#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
174#define OSCILLOSCOPE_QUIT BUTTON_RC_REC
175#define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_RC_MODE
176#define OSCILLOSCOPE_DRAWMODE (BUTTON_RC_MODE|BUTTON_REL)
177#define OSCILLOSCOPE_ADVMODE BUTTON_RC_MENU
178#define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_RC_MODE
179#define OSCILLOSCOPE_ORIENTATION (BUTTON_RC_MODE|BUTTON_REPEAT)
180#define OSCILLOSCOPE_PAUSE BUTTON_RC_PLAY
181#define OSCILLOSCOPE_SPEED_UP BUTTON_RC_FF
182#define OSCILLOSCOPE_SPEED_DOWN BUTTON_RC_REW
183#define OSCILLOSCOPE_VOL_UP BUTTON_RC_VOL_UP
184#define OSCILLOSCOPE_VOL_DOWN BUTTON_RC_VOL_DOWN
185
Rob Purchase554d7ed2008-03-22 22:03:34 +0000186#elif CONFIG_KEYPAD == COWOND2_PAD
187#define OSCILLOSCOPE_QUIT BUTTON_POWER
Rob Purchase554d7ed2008-03-22 22:03:34 +0000188#define OSCILLOSCOPE_VOL_UP BUTTON_PLUS
189#define OSCILLOSCOPE_VOL_DOWN BUTTON_MINUS
190
Robert Kuklad6c8b572008-03-01 22:55:09 +0000191#else
192#error No keymap defined!
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000193#endif
194
Rob Purchase297e0502008-04-27 15:30:19 +0000195#ifdef HAVE_TOUCHPAD
196#ifndef OSCILLOSCOPE_QUIT
197#define OSCILLOSCOPE_QUIT BUTTON_TOPLEFT
198#endif
199#ifndef OSCILLOSCOPE_DRAWMODE
200#define OSCILLOSCOPE_DRAWMODE BUTTON_TOPMIDDLE
201#endif
202#ifndef OSCILLOSCOPE_ADVMODE
203#define OSCILLOSCOPE_ADVMODE BUTTON_BOTTOMMIDDLE
204#endif
205#ifndef OSCILLOSCOPE_ORIENTATION
206#define OSCILLOSCOPE_ORIENTATION BUTTON_BOTTOMLEFT
207#endif
208#ifndef OSCILLOSCOPE_PAUSE
209#define OSCILLOSCOPE_PAUSE BUTTON_CENTER
210#endif
211#ifndef OSCILLOSCOPE_SPEED_UP
212#define OSCILLOSCOPE_SPEED_UP BUTTON_MIDRIGHT
213#endif
214#ifndef OSCILLOSCOPE_SPEED_DOWN
215#define OSCILLOSCOPE_SPEED_DOWN BUTTON_MIDLEFT
216#endif
217#ifndef OSCILLOSCOPE_VOL_UP
218#define OSCILLOSCOPE_VOL_UP BUTTON_TOPRIGHT
219#endif
220#ifndef OSCILLOSCOPE_VOL_DOWN
221#define OSCILLOSCOPE_VOL_DOWN BUTTON_BOTTOMRIGHT
222#endif
223#endif
224
Jens Arnoldf9765d32006-03-11 01:13:51 +0000225/* colours */
226#if LCD_DEPTH > 1
227#ifdef HAVE_LCD_COLOR
228#define BACKG_COLOR LCD_BLACK
229#define GRAPH_COLOR LCD_RGBPACK(128, 255, 0)
230#define CURSOR_COLOR LCD_RGBPACK(255, 0, 0)
231#else
232#define BACKG_COLOR LCD_WHITE
233#define GRAPH_COLOR LCD_BLACK
234#define CURSOR_COLOR LCD_DARKGRAY
235#endif
236#endif
237
238enum { DRAW_FILLED, DRAW_LINE, DRAW_PIXEL, MAX_DRAW };
239enum { ADV_SCROLL, ADV_WRAP, MAX_ADV };
240enum { OSC_HORIZ, OSC_VERT, MAX_OSC };
241
242#define CFGFILE_VERSION 0 /* Current config file version */
243#define CFGFILE_MINVERSION 0 /* Minimum config file version to accept */
244
245
246#define MAX_PEAK 0x8000
247
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000248#if defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
249#define mas_codec_readreg(x) rand()%MAX_PEAK
250#endif
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000251
252/* global variables */
253
Steve Bavin65265772008-05-13 09:57:56 +0000254const struct plugin_api* rb; /* global api struct pointer */
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000255
Jens Arnoldf9765d32006-03-11 01:13:51 +0000256/* settings */
Jens Arnold37f529c2006-03-11 08:35:45 +0000257struct osc_config {
258 int delay; /* in ticks */
259 int draw;
260 int advance;
261 int orientation;
262};
263
264struct osc_config osc_disk = { 2, DRAW_FILLED, ADV_SCROLL, OSC_HORIZ };
265struct osc_config osc; /* running config */
Jens Arnoldf9765d32006-03-11 01:13:51 +0000266
267static const char cfg_filename[] = "oscilloscope.cfg";
268static char *draw_str[3] = { "filled", "line", "pixel" };
269static char *advance_str[2] = { "scroll", "wrap" };
270static char *orientation_str[2] = { "horizontal", "vertical" };
271
Jens Arnold37f529c2006-03-11 08:35:45 +0000272struct configdata disk_config[] = {
273 { TYPE_INT, 1, 99, &osc_disk.delay, "delay", NULL, NULL },
274 { TYPE_ENUM, 0, MAX_DRAW, &osc_disk.draw, "draw", draw_str, NULL },
275 { TYPE_ENUM, 0, MAX_ADV, &osc_disk.advance, "advance", advance_str, NULL },
276 { TYPE_ENUM, 0, MAX_OSC, &osc_disk.orientation, "orientation", orientation_str, NULL }
Jens Arnoldf9765d32006-03-11 01:13:51 +0000277};
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000278
Jens Arnold37f529c2006-03-11 08:35:45 +0000279
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000280long last_tick = 0; /* time of last drawing */
281int last_pos = 0; /* last x or y drawing position. Reset for aspect switch. */
282int last_left; /* last channel values */
283int last_right;
284
285unsigned char message[16]; /* message to display */
286bool displaymsg = false;
287int font_height = 8;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000288
289/* implementation */
290
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000291void anim_horizontal(int cur_left, int cur_right)
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000292{
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000293 int cur_x, x;
294 int left, right, dl, dr;
295 long cur_tick = *rb->current_tick;
Jens Arnold37f529c2006-03-11 08:35:45 +0000296 long d = (cur_tick - last_tick) / osc.delay;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000297 bool full_update = false;
298
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000299 if (d == 0) /* too early, bail out */
300 return;
301
302 last_tick = cur_tick;
303
304 if (d > HZ) /* first call or too much delay, (re)start */
305 {
306 last_left = cur_left;
307 last_right = cur_right;
308 return;
309 }
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000310 cur_x = last_pos + d;
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000311
312 if (cur_x >= LCD_WIDTH)
313 {
Jens Arnold37f529c2006-03-11 08:35:45 +0000314 if (osc.advance == ADV_SCROLL)
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000315 {
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000316 int shift = cur_x - (LCD_WIDTH-1);
317 xlcd_scroll_left(shift);
318 full_update = true;
319 cur_x -= shift;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000320 last_pos -= shift;
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000321 }
Jens Arnoldf9765d32006-03-11 01:13:51 +0000322 else
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000323 {
324 cur_x -= LCD_WIDTH;
325 }
326 }
327 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
328
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000329 if (cur_x > last_pos)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000330 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000331 rb->lcd_fillrect(last_pos + 1, 0, d, LCD_HEIGHT);
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000332 }
333 else
334 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000335 rb->lcd_fillrect(last_pos + 1, 0, LCD_WIDTH - last_pos, LCD_HEIGHT);
336 rb->lcd_fillrect(0, 0, cur_x + 1, LCD_HEIGHT);
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000337 }
338 rb->lcd_set_drawmode(DRMODE_SOLID);
339
Jens Arnold37f529c2006-03-11 08:35:45 +0000340 switch (osc.draw)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000341 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000342 case DRAW_FILLED:
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000343 left = last_left;
344 right = last_right;
345 dl = (cur_left - left) / d;
346 dr = (cur_right - right) / d;
347
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000348 for (x = last_pos + 1; d > 0; x++, d--)
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000349 {
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000350 if (x == LCD_WIDTH)
351 x = 0;
352
353 left += dl;
354 right += dr;
355
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000356 rb->lcd_vline(x, LCD_HEIGHT/2-1,
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000357 LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * left) >> 16));
358 rb->lcd_vline(x, LCD_HEIGHT/2+1,
359 LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * right) >> 16));
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000360 }
361 break;
362
Jens Arnoldf9765d32006-03-11 01:13:51 +0000363 case DRAW_LINE:
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000364 if (cur_x > last_pos)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000365 {
366 rb->lcd_drawline(
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000367 last_pos, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * last_left) >> 16),
368 cur_x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * cur_left) >> 16)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000369 );
370 rb->lcd_drawline(
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000371 last_pos, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * last_right) >> 16),
372 cur_x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * cur_right) >> 16)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000373 );
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000374 }
375 else
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000376 {
377 left = last_left
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000378 + (LCD_WIDTH - last_pos) * (last_left - cur_left) / d;
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000379 right = last_right
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000380 + (LCD_WIDTH - last_pos) * (last_right - cur_right) / d;
Jens Arnold19b45a42006-03-08 01:14:46 +0000381
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000382 rb->lcd_drawline(
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000383 last_pos, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * last_left) >> 16),
384 LCD_WIDTH, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * left) >> 16)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000385 );
386 rb->lcd_drawline(
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000387 last_pos, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * last_right) >> 16),
388 LCD_WIDTH, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * right) >> 16)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000389 );
Jens Arnoldf9765d32006-03-11 01:13:51 +0000390 if (cur_x > 0)
391 {
392 rb->lcd_drawline(
393 0, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * left) >> 16),
394 cur_x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * cur_left) >> 16)
395 );
396 rb->lcd_drawline(
397 0, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * right) >> 16),
398 cur_x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * cur_right) >> 16)
399 );
400 }
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000401 }
402 break;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000403
Jens Arnoldf9765d32006-03-11 01:13:51 +0000404 case DRAW_PIXEL:
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000405 left = last_left;
406 right = last_right;
407 dl = (cur_left - left) / d;
408 dr = (cur_right - right) / d;
409
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000410 for (x = last_pos + 1; d > 0; x++, d--)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000411 {
412 if (x == LCD_WIDTH)
413 x = 0;
414
415 left += dl;
416 right += dr;
417
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000418 rb->lcd_drawpixel(x, LCD_HEIGHT/2-1 - (((LCD_HEIGHT-2) * left) >> 16));
419 rb->lcd_drawpixel(x, LCD_HEIGHT/2+1 + (((LCD_HEIGHT-2) * right) >> 16));
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000420 }
421 break;
422
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000423 }
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000424 last_left = cur_left;
425 last_right = cur_right;
Jens Arnoldf9765d32006-03-11 01:13:51 +0000426
Jens Arnoldc91623b2006-03-12 13:44:51 +0000427 if (displaymsg)
428 {
429 int width;
430
431 rb->lcd_getstringsize(message, &width, NULL);
432 last_pos -= width - 1;
433 rb->lcd_putsxy(last_pos, 0, message);
434 displaymsg = false;
435
436 if (last_pos < 0)
437 last_pos = 0;
438 }
439
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000440 if (full_update)
441 {
442 rb->lcd_update();
443 }
444 else
445 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000446#if LCD_DEPTH > 1 /* cursor bar */
447 rb->lcd_set_foreground(CURSOR_COLOR);
448 rb->lcd_vline(cur_x + 1, 0, LCD_HEIGHT-1);
449 rb->lcd_set_foreground(GRAPH_COLOR);
450#else
451 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
452 rb->lcd_vline(cur_x + 1, 0, LCD_HEIGHT-1);
453 rb->lcd_set_drawmode(DRMODE_SOLID);
454#endif
455
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000456 if (cur_x > last_pos)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000457 {
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000458 rb->lcd_update_rect(last_pos, 0, cur_x - last_pos + 2, LCD_HEIGHT);
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000459 }
460 else
461 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000462 rb->lcd_update_rect(last_pos, 0, LCD_WIDTH - last_pos, LCD_HEIGHT);
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000463 rb->lcd_update_rect(0, 0, cur_x + 2, LCD_HEIGHT);
464 }
465 }
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000466 last_pos = cur_x;
467}
468
469void anim_vertical(int cur_left, int cur_right)
470{
471 int cur_y, y;
472 int left, right, dl, dr;
473 long cur_tick = *rb->current_tick;
Jens Arnold37f529c2006-03-11 08:35:45 +0000474 long d = (cur_tick - last_tick) / osc.delay;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000475 bool full_update = false;
476
477 if (d == 0) /* too early, bail out */
478 return;
479
480 last_tick = cur_tick;
481
482 if (d > HZ) /* first call or too much delay, (re)start */
483 {
484 last_left = cur_left;
485 last_right = cur_right;
486 return;
487 }
488 cur_y = last_pos + d;
489
490 if (cur_y >= LCD_HEIGHT)
491 {
Jens Arnold37f529c2006-03-11 08:35:45 +0000492 if (osc.advance == ADV_SCROLL)
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000493 {
494 int shift = cur_y - (LCD_HEIGHT-1);
495 xlcd_scroll_up(shift);
496 full_update = true;
497 cur_y -= shift;
498 last_pos -= shift;
499 }
Jens Arnoldf9765d32006-03-11 01:13:51 +0000500 else
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000501 {
502 cur_y -= LCD_HEIGHT;
503 }
504 }
505 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
506
507 if (cur_y > last_pos)
508 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000509 rb->lcd_fillrect(0, last_pos + 1, LCD_WIDTH, d);
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000510 }
511 else
512 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000513 rb->lcd_fillrect(0, last_pos + 1, LCD_WIDTH, LCD_HEIGHT - last_pos);
514 rb->lcd_fillrect(0, 0, LCD_WIDTH, cur_y + 1);
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000515 }
516 rb->lcd_set_drawmode(DRMODE_SOLID);
517
Jens Arnold37f529c2006-03-11 08:35:45 +0000518 switch (osc.draw)
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000519 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000520 case DRAW_FILLED:
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000521 left = last_left;
522 right = last_right;
523 dl = (cur_left - left) / d;
524 dr = (cur_right - right) / d;
525
526 for (y = last_pos + 1; d > 0; y++, d--)
527 {
528 if (y == LCD_HEIGHT)
529 y = 0;
530
531 left += dl;
532 right += dr;
533
534 rb->lcd_hline(LCD_WIDTH/2-1,
535 LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * left) >> 16), y);
536 rb->lcd_hline(LCD_WIDTH/2+1,
537 LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * right) >> 16), y);
538 }
539 break;
540
Jens Arnoldf9765d32006-03-11 01:13:51 +0000541 case DRAW_LINE:
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000542 if (cur_y > last_pos)
543 {
544 rb->lcd_drawline(
545 LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * last_left) >> 16), last_pos,
546 LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * cur_left) >> 16), cur_y
547 );
548 rb->lcd_drawline(
549 LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * last_right) >> 16), last_pos,
550 LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * cur_right) >> 16), cur_y
551 );
552 }
553 else
554 {
555 left = last_left
556 + (LCD_HEIGHT - last_pos) * (last_left - cur_left) / d;
557 right = last_right
558 + (LCD_HEIGHT - last_pos) * (last_right - cur_right) / d;
559
560 rb->lcd_drawline(
561 LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * last_left) >> 16), last_pos,
562 LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * left) >> 16), LCD_HEIGHT
563 );
564 rb->lcd_drawline(
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000565 LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * last_right) >> 16), last_pos,
566 LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * right) >> 16), LCD_HEIGHT
567 );
Jens Arnoldf9765d32006-03-11 01:13:51 +0000568 if (cur_y > 0)
569 {
570 rb->lcd_drawline(
571 LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * left) >> 16), 0,
572 LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * cur_left) >> 16), cur_y
573 );
574 rb->lcd_drawline(
575 LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * right) >> 16), 0,
576 LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * cur_right) >> 16), cur_y
577 );
578 }
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000579 }
580 break;
581
Jens Arnoldf9765d32006-03-11 01:13:51 +0000582 case DRAW_PIXEL:
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000583 left = last_left;
584 right = last_right;
585 dl = (cur_left - left) / d;
586 dr = (cur_right - right) / d;
587
588 for (y = last_pos + 1; d > 0; y++, d--)
589 {
590 if (y == LCD_HEIGHT)
591 y = 0;
592
593 left += dl;
594 right += dr;
595
596 rb->lcd_drawpixel(LCD_WIDTH/2-1 - (((LCD_WIDTH-2) * left) >> 16), y);
597 rb->lcd_drawpixel(LCD_WIDTH/2+1 + (((LCD_WIDTH-2) * right) >> 16), y);
598 }
599 break;
600
601 }
602 last_left = cur_left;
603 last_right = cur_right;
604
605 if (displaymsg)
606 {
607 last_pos -= font_height - 1;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000608 rb->lcd_putsxy(0, last_pos, message);
609 displaymsg = false;
Jens Arnoldc91623b2006-03-12 13:44:51 +0000610
611 if (last_pos < 0)
612 last_pos = 0;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000613 }
614
615 if (full_update)
616 {
617 rb->lcd_update();
618 }
619 else
620 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000621#if LCD_DEPTH > 1 /* cursor bar */
622 rb->lcd_set_foreground(CURSOR_COLOR);
623 rb->lcd_hline(0, LCD_WIDTH-1, cur_y + 1);
624 rb->lcd_set_foreground(GRAPH_COLOR);
625#else
626 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
627 rb->lcd_hline(0, LCD_WIDTH-1, cur_y + 1);
628 rb->lcd_set_drawmode(DRMODE_SOLID);
629#endif
630
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000631 if (cur_y > last_pos)
632 {
633 rb->lcd_update_rect(0, last_pos, LCD_WIDTH, cur_y - last_pos + 2);
634 }
635 else
636 {
Jens Arnoldf9765d32006-03-11 01:13:51 +0000637 rb->lcd_update_rect(0, last_pos, LCD_WIDTH, LCD_HEIGHT - last_pos);
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000638 rb->lcd_update_rect(0, 0, LCD_WIDTH, cur_y + 2);
639 }
640 }
641 last_pos = cur_y;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000642}
643
644void cleanup(void *parameter)
645{
646 (void)parameter;
Jens Arnoldf9765d32006-03-11 01:13:51 +0000647#if LCD_DEPTH > 1
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000648 rb->lcd_set_foreground(LCD_DEFAULT_FG);
649 rb->lcd_set_background(LCD_DEFAULT_BG);
Jens Arnoldf9765d32006-03-11 01:13:51 +0000650#endif
Peter D'Hoyecb53e3c2007-08-15 12:42:09 +0000651 /* Turn on backlight timeout (revert to settings) */
Peter D'Hoye767c0ec2007-08-16 23:01:18 +0000652 backlight_use_settings(rb); /* backlight control in lib/helper.c */
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000653}
654
Steve Bavin65265772008-05-13 09:57:56 +0000655enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000656{
657 int button, vol;
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000658 int lastbutton = BUTTON_NONE;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000659 bool exit = false;
660 bool paused = false;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000661 bool tell_speed;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000662
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000663 (void)parameter;
664 rb = api;
Jens Arnold19b45a42006-03-08 01:14:46 +0000665
666 xlcd_init(rb);
Jens Arnoldf9765d32006-03-11 01:13:51 +0000667 configfile_init(rb);
668
Jens Arnold37f529c2006-03-11 08:35:45 +0000669 configfile_load(cfg_filename, disk_config,
670 sizeof(disk_config) / sizeof(disk_config[0]),
Jens Arnoldf9765d32006-03-11 01:13:51 +0000671 CFGFILE_MINVERSION);
Jens Arnold37f529c2006-03-11 08:35:45 +0000672 rb->memcpy(&osc, &osc_disk, sizeof(osc)); /* copy to running config */
Jens Arnoldf9765d32006-03-11 01:13:51 +0000673
674#if LCD_DEPTH > 1
675 rb->lcd_set_foreground(GRAPH_COLOR);
676 rb->lcd_set_background(BACKG_COLOR);
Karl Kurbjund6b0c972006-11-15 06:14:27 +0000677 rb->lcd_set_backdrop(NULL);
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000678 rb->lcd_clear_display();
679 rb->lcd_update();
Jens Arnoldf9765d32006-03-11 01:13:51 +0000680#endif
Peter D'Hoyecb53e3c2007-08-15 12:42:09 +0000681
682 /* Turn off backlight timeout */
Peter D'Hoye767c0ec2007-08-16 23:01:18 +0000683 backlight_force_on(rb); /* backlight control in lib/helper.c */
Peter D'Hoyecb53e3c2007-08-15 12:42:09 +0000684
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000685 rb->lcd_getstringsize("A", NULL, &font_height);
686
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000687 while (!exit)
688 {
689 if (!paused)
690 {
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000691 int left, right;
692
Jens Arnold37f529c2006-03-11 08:35:45 +0000693 rb->sleep(MAX(last_tick + osc.delay - *rb->current_tick - 1, 0));
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000694
695#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
696 left = rb->mas_codec_readreg(0xC);
697 right = rb->mas_codec_readreg(0xD);
698#elif (CONFIG_CODEC == SWCODEC)
699 rb->pcm_calculate_peaks(&left, &right);
700#endif
Jens Arnold37f529c2006-03-11 08:35:45 +0000701 if (osc.orientation == OSC_HORIZ)
Jens Arnoldf9765d32006-03-11 01:13:51 +0000702 anim_horizontal(left, right);
703 else
704 anim_vertical(left, right);
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000705 }
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000706
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000707 tell_speed = false;
Jens Arnold0ee36f82004-11-12 21:40:57 +0000708 button = rb->button_get(paused);
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000709 switch (button)
710 {
Kevin Ferrare0e027bd2006-06-30 16:43:47 +0000711#ifdef OSCILLOSCOPE_RC_QUIT
712 case OSCILLOSCOPE_RC_QUIT:
713#endif
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000714 case OSCILLOSCOPE_QUIT:
715 exit = true;
716 break;
717
Jens Arnoldf9765d32006-03-11 01:13:51 +0000718 case OSCILLOSCOPE_ADVMODE:
Jens Arnold37f529c2006-03-11 08:35:45 +0000719 if (++osc.advance >= MAX_ADV)
720 osc.advance = 0;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000721 break;
722
Jens Arnoldf9765d32006-03-11 01:13:51 +0000723 case OSCILLOSCOPE_DRAWMODE:
724#ifdef OSCILLOSCOPE_DRAWMODE_PRE
725 if (lastbutton != OSCILLOSCOPE_DRAWMODE_PRE)
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000726 break;
727#endif
Jens Arnold37f529c2006-03-11 08:35:45 +0000728 if (++osc.draw >= MAX_DRAW)
729 osc.draw = 0;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000730 break;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000731
732 case OSCILLOSCOPE_ORIENTATION:
Jens Arnold61e798f2007-04-09 17:03:48 +0000733#ifdef OSCILLOSCOPE_ORIENTATION_PRE
734 if (lastbutton != OSCILLOSCOPE_ORIENTATION_PRE)
735 break;
736#endif
Jens Arnold37f529c2006-03-11 08:35:45 +0000737 if (++osc.orientation >= MAX_OSC)
738 osc.orientation = 0;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000739 last_pos = 0;
Jens Arnoldf9765d32006-03-11 01:13:51 +0000740 last_tick = 0;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000741 displaymsg = false;
742 rb->lcd_clear_display();
743 rb->lcd_update();
744 break;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000745
746 case OSCILLOSCOPE_PAUSE:
747 paused = !paused;
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000748 last_tick = 0;
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000749 break;
750
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000751 case OSCILLOSCOPE_SPEED_UP:
752 case OSCILLOSCOPE_SPEED_UP | BUTTON_REPEAT:
Jens Arnold37f529c2006-03-11 08:35:45 +0000753 if (osc.delay > 1)
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000754 {
Jens Arnold37f529c2006-03-11 08:35:45 +0000755 osc.delay--;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000756 tell_speed = true;
757 }
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000758 break;
759
760 case OSCILLOSCOPE_SPEED_DOWN:
761 case OSCILLOSCOPE_SPEED_DOWN | BUTTON_REPEAT:
Jens Arnold37f529c2006-03-11 08:35:45 +0000762 osc.delay++;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000763 tell_speed = true;
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000764 break;
765
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000766 case OSCILLOSCOPE_VOL_UP:
767 case OSCILLOSCOPE_VOL_UP | BUTTON_REPEAT:
768 vol = rb->global_settings->volume;
Jens Arnoldc80e0c12005-12-17 21:13:30 +0000769 if (vol < rb->sound_max(SOUND_VOLUME))
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000770 {
771 vol++;
Linus Nielsen Feltzing674eaca2005-04-01 13:41:03 +0000772 rb->sound_set(SOUND_VOLUME, vol);
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000773 rb->global_settings->volume = vol;
774 }
775 break;
776
777 case OSCILLOSCOPE_VOL_DOWN:
778 case OSCILLOSCOPE_VOL_DOWN | BUTTON_REPEAT:
779 vol = rb->global_settings->volume;
Jens Arnoldc80e0c12005-12-17 21:13:30 +0000780 if (vol > rb->sound_min(SOUND_VOLUME))
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000781 {
782 vol--;
Linus Nielsen Feltzing674eaca2005-04-01 13:41:03 +0000783 rb->sound_set(SOUND_VOLUME, vol);
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000784 rb->global_settings->volume = vol;
785 }
786 break;
787
788 default:
789 if (rb->default_event_handler_ex(button, cleanup, NULL)
790 == SYS_USB_CONNECTED)
791 return PLUGIN_USB_CONNECTED;
792 break;
793 }
Jens Arnoldb318b3e2006-03-09 07:52:26 +0000794 if (button != BUTTON_NONE)
795 lastbutton = button;
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000796
797 if (tell_speed)
798 {
Jens Arnoldc91623b2006-03-12 13:44:51 +0000799 rb->snprintf(message, sizeof(message), "%s%d",
800 (osc.orientation == OSC_VERT) ? "Speed: " : "",
801 100 / osc.delay);
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000802 displaymsg = true;
803 }
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000804 }
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000805 cleanup(NULL);
Jens Arnold37f529c2006-03-11 08:35:45 +0000806 if (rb->memcmp(&osc, &osc_disk, sizeof(osc))) /* save settings if changed */
807 {
808 rb->memcpy(&osc_disk, &osc, sizeof(osc));
809 configfile_save(cfg_filename, disk_config,
810 sizeof(disk_config) / sizeof(disk_config[0]),
811 CFGFILE_VERSION);
812 }
Jens Arnolddb14d8e2004-11-07 10:31:39 +0000813 return PLUGIN_OK;
814}
Jens Arnold78e4f4d2006-03-10 00:18:58 +0000815#endif /* HAVE_LCD_BITMAP */