diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/vu_meter.c | 391 |
1 files changed, 348 insertions, 43 deletions
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c index 685d2f65d8..a9d74da794 100644 --- a/apps/plugins/vu_meter.c +++ b/apps/plugins/vu_meter.c | |||
@@ -15,20 +15,30 @@ | |||
15 | * KIND, either express or implied. | 15 | * KIND, either express or implied. |
16 | * | 16 | * |
17 | **************************************************************************/ | 17 | **************************************************************************/ |
18 | |||
19 | /****************************************************** | ||
20 | * Quick note: throughout this code you'll see | ||
21 | * comments like this one, inside of a box. They are | ||
22 | * used to indicate new functions, not because I | ||
23 | * think you're blind. Only here to help. | ||
24 | ******************************************************/ | ||
25 | |||
18 | #include "plugin.h" | 26 | #include "plugin.h" |
19 | 27 | ||
20 | #ifndef SIMULATOR | ||
21 | #ifdef HAVE_LCD_BITMAP | 28 | #ifdef HAVE_LCD_BITMAP |
22 | 29 | ||
23 | static struct plugin_api* rb; | 30 | static struct plugin_api* rb; |
24 | 31 | ||
25 | /* This table is used to define x positions on a logarithmic (dBfs) scale. | 32 | /* This table is used to define x positions on a logarithmic (dBfs) scale. |
26 | The formula I used to figure these out was log(x+1)*31.89293, | 33 | There are 112 of them, one for each pixel. |
34 | The formula I used to figure these out was log(x)*32.09, | ||
27 | where x was the original x position. */ | 35 | where x was the original x position. */ |
28 | static unsigned char db_scale[] = {0,9.6,15.2,19.2,22.3,24.8,27,28.8,30.4,31.9,33.2,34.4,35.5,36.6,37.5,38.4, | 36 | static unsigned char db_scale[] = {0,0,10,15,19,22,25,27,29,31,32,33,35,36,37,38,39,39,40,41,42,42, |
29 | 39.2,40,40.8,41.5,52.2,42.8,43.4,44,44.6,45.1,45.7,46.2,46.6,47.1,47.6,48, | 37 | 43,44,44,45,45,46,46,47,47,48,48,49,49,50,50,50,51,51,51,52,52, |
30 | 48.4,48.8,49.2,49.6,50,50.4,50.7,51.1,51.4,51.8,52.1,52.4,52.7,53,53.3,53.6, | 38 | 52,53,53,53,54,54,54,55,55,55,55,56,56,56,56,56,66, 71,75,78,81, |
31 | 53.9,54.2,54.5,54.7,55,55.3,55.5,55.8,56}; | 39 | 83,85,87,88,89,91,92,93,94,95,95,96,97,98,98,99,100,100,101,101, |
40 | 102,102,103,103,104,104,105,105,106,106,106,107,107,107,108,108, | ||
41 | 108,109,109,109,110,110,110,111,111,111,111,112,112,112}; | ||
32 | 42 | ||
33 | /* Define's y positions, and makes it look like an arch, like a real needle would. */ | 43 | /* Define's y positions, and makes it look like an arch, like a real needle would. */ |
34 | static unsigned char y_values[] = {32,31,30,29,28,27,26,25,24,24,23,22,22,21,21,20,19,19,18,18,18,18,18,17,17,17,17,17, | 44 | static unsigned char y_values[] = {32,31,30,29,28,27,26,25,24,24,23,22,22,21,21,20,19,19,18,18,18,18,18,17,17,17,17,17, |
@@ -36,81 +46,328 @@ static unsigned char y_values[] = {32,31,30,29,28,27,26,25,24,24,23,22,22,21,21, | |||
36 | 32,31,30,29,28,27,26,25,24,24,23,22,22,21,21,20,19,19,18,18,18,18,18,17,17,17,17,17, | 46 | 32,31,30,29,28,27,26,25,24,24,23,22,22,21,21,20,19,19,18,18,18,18,18,17,17,17,17,17, |
37 | 17,17,17,17,17,18,18,18,18,18,19,19,20,21,21,22,22,23,24,24,25,26,27,28,29,30,31,32}; | 47 | 17,17,17,17,17,18,18,18,18,18,19,19,20,21,21,22,22,23,24,24,25,26,27,28,29,30,31,32}; |
38 | 48 | ||
49 | /*************************************************** | ||
50 | * LCD Bitmaps/Icons | ||
51 | ***************************************************/ | ||
52 | |||
39 | /* Linear mode bitmap icon. */ | 53 | /* Linear mode bitmap icon. */ |
40 | static unsigned char mode_linear[] = {0xDF,0x10,0xD0,0x00,0xDF,0x00,0xDF,0x02,0xC4,0x08,0xDF, | 54 | unsigned char mode_linear[] = {0xDF,0x10,0xD0,0x00,0xDF,0x00,0xDF,0x02,0xC4,0x08,0xDF, |
41 | 0x00,0xDF,0x15,0xD1,0x00,0xDE,0x05,0xDE,0x00,0xDF,0x05, | 55 | 0x00,0xDF,0x15,0xD1,0x00,0xDE,0x05,0xDE,0x00,0xDF,0x05, |
42 | 0xDA}; | 56 | 0xDA}; |
43 | 57 | ||
44 | /* Logarithmic (dBfs) mode bitmap icon. */ | 58 | /* Logarithmic (dBfs) mode bitmap icon. */ |
45 | static unsigned char mode_dbfs[] = {0xC8,0x14,0x14,0x1F,0x00,0xDF,0x15,0x15,0x0A,0xC0,0x1E, | 59 | unsigned char mode_dbfs[] = {0xC8,0x14,0x14,0x1F,0x00,0xDF,0x15,0x15,0x0A,0xC0,0x1E, |
46 | 0x05,0x05,0xC0,0x16,0x15,0xD5,0x09,0xC0,0x00,0xF0,0x00, | 60 | 0x05,0x05,0xC0,0x16,0x15,0xD5,0x09,0xC0,0x00,0xF0,0x00, |
47 | 0xFE}; | 61 | 0xFE}; |
62 | |||
63 | /* Channel indicator - no level [4x8] */ | ||
64 | static unsigned char sound_speaker[] = {0x18,0x24,0x42,0xFF}; | ||
65 | |||
66 | /* Channel indicator - low level [2x8] */ | ||
67 | static unsigned char sound_low_level[] = {0x24,0x18}; | ||
68 | |||
69 | /* Channel indicator - medium level [2x8] */ | ||
70 | static unsigned char sound_med_level[] = {0x42,0x3C}; | ||
71 | |||
72 | /* Channel indicator - high level [2x8] */ | ||
73 | static unsigned char sound_high_level[] = {0x81,0x7E}; | ||
74 | |||
75 | /* Channel indicator - maxed out [3x8] */ | ||
76 | static unsigned char sound_max_level[] = {0x0E,0xDF,0x0E}; | ||
77 | |||
78 | /* Volume level icon [4x7] */ | ||
79 | static unsigned char volume_indicator[] = {0x1C,0x1C,0x22,0x7F}; | ||
48 | 80 | ||
81 | /* RIGHT ARROW icon (from icons.c) [7x8] */ | ||
82 | static unsigned char right_arrow[] = {0x7F,0x3E,0x1C,0x7F,0x3E,0x1C,0x08}; | ||
49 | 83 | ||
84 | /* LEFT ARROW icon (from icons.c) [7x8] */ | ||
85 | static unsigned char left_arrow[] = {0x08,0x1C,0x3E,0x7F,0x1C,0x3E,0x7F}; | ||
86 | |||
87 | /************************* | ||
88 | * DEFINES | ||
89 | *************************/ | ||
50 | #define MAX_PEAK 0x7FFF | 90 | #define MAX_PEAK 0x7FFF |
51 | #define NEEDLE_BOTTOM_Y 54 | 91 | #define NEEDLE_BOTTOM_Y 54 |
52 | 92 | ||
93 | /****************************** | ||
94 | * LEFT NEEDLE ints | ||
95 | ******************************/ | ||
53 | #define LEFT_NEEDLE_BOTTOM_X 28 | 96 | #define LEFT_NEEDLE_BOTTOM_X 28 |
54 | int left_needle_top_y; | 97 | int left_needle_top_y; |
55 | int left_needle_top_x; | 98 | int left_needle_top_x; |
56 | int old_left_needle_top_x = 0; | 99 | int old_left_needle_top_x = 0; |
57 | int left_needle_top_x_no_log; | 100 | int left_needle_top_x_no_log; |
58 | 101 | ||
102 | /******************************* | ||
103 | * RIGHT NEEDLE ints | ||
104 | *******************************/ | ||
59 | #define RIGHT_NEEDLE_BOTTOM_X 84 | 105 | #define RIGHT_NEEDLE_BOTTOM_X 84 |
60 | int right_needle_top_y; | 106 | int right_needle_top_y; |
61 | int right_needle_top_x; | 107 | int right_needle_top_x; |
62 | int old_right_needle_top_x = 56; | 108 | int old_right_needle_top_x = 56; |
63 | int right_needle_top_x_no_log; | 109 | int right_needle_top_x_no_log; |
64 | 110 | ||
65 | bool show_arch = true; | 111 | /********************* |
112 | * LEFT MINIMETER ints | ||
113 | *********************/ | ||
114 | int mini_left_low; | ||
115 | int mini_left_med; | ||
116 | int mini_left_high; | ||
117 | int mini_left_clip; | ||
118 | |||
119 | /********************** | ||
120 | * RIGHT MINIMETER ints | ||
121 | **********************/ | ||
122 | int mini_right_low; | ||
123 | int mini_right_med; | ||
124 | int mini_right_high; | ||
125 | int mini_right_clip; | ||
126 | |||
127 | /************************ | ||
128 | * GENERAL ints | ||
129 | ************************/ | ||
130 | char curr_vol[3]; /* CURRENT VOLUME */ | ||
131 | int vol; /* CURENNT VOLUME int */ | ||
132 | int on = 1; /* MINIMETER OPTIONS int */ | ||
133 | int needle_cover_mode = 1; /* NEEDLE COVER int (defaults to "rounded") */ | ||
134 | int arch = 1; /* ARCH int (defaults to "solid") */ | ||
135 | int decay = 3; /* DECAY int (defaults to "medium") */ | ||
136 | |||
137 | /************************* | ||
138 | * GENERAL bools | ||
139 | *************************/ | ||
140 | bool quit = false; | ||
66 | bool use_log_scale = true; | 141 | bool use_log_scale = true; |
67 | int needle_cover_mode = 1; | 142 | bool use_minimeters = true; |
143 | |||
144 | /******************************************** | ||
145 | * Change the volume - derived from VIDEO.C | ||
146 | ********************************************/ | ||
147 | void ChangeVolume(int delta) | ||
148 | { | ||
149 | vol = rb->global_settings->volume + delta; | ||
68 | 150 | ||
69 | /* This draws everthing but the needles, needle covers, and the visible arch. */ | 151 | if (vol > 100) vol = 100; |
152 | else if (vol < 0) vol = 0; | ||
153 | if (vol != rb->global_settings->volume) | ||
154 | { | ||
155 | rb->mpeg_sound_set(SOUND_VOLUME, vol); | ||
156 | rb->global_settings->volume = vol; | ||
157 | rb->snprintf(curr_vol, sizeof(curr_vol), "%d", vol); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | /***************************************************** | ||
162 | * Draw the status bar | ||
163 | *****************************************************/ | ||
70 | void draw_status_bar(void) | 164 | void draw_status_bar(void) |
71 | { | 165 | { |
72 | rb->lcd_setfont(FONT_SYSFIXED); | 166 | rb->lcd_setfont(FONT_SYSFIXED); |
73 | rb->lcd_clear_display(); | ||
74 | 167 | ||
75 | rb->lcd_drawline(0, 10, 111, 10); | 168 | rb->lcd_drawline(0, 10, 112, 10); |
76 | rb->lcd_putsxy(1, 1, "VU Meter"); | 169 | rb->lcd_putsxy(1, 1, "VU Meter"); |
170 | rb->lcd_drawline(52, 1, 52, 8); | ||
171 | rb->lcd_bitmap(volume_indicator, 60, 1, 4, 7, true); | ||
172 | rb->lcd_putsxy(65, 1, curr_vol); | ||
173 | rb->lcd_drawline(85, 1, 85, 8); | ||
77 | 174 | ||
78 | if(use_log_scale) | 175 | if(use_log_scale) |
79 | rb->lcd_bitmap(mode_dbfs, 88, 1, 23, 8, true); | 176 | rb->lcd_bitmap(mode_dbfs, 88, 1, 23, 8, true); |
80 | else | 177 | else |
81 | rb->lcd_bitmap(mode_linear, 88, 1, 23, 8, true); | 178 | rb->lcd_bitmap(mode_linear, 88, 1, 23, 8, true); |
82 | 179 | ||
83 | rb->lcd_putsxy(25, 56, "L"); | ||
84 | rb->lcd_putsxy(81, 56, "R"); | ||
85 | |||
86 | /* The last line under the needle covers. */ | 180 | /* The last line under the needle covers. */ |
87 | rb->lcd_drawline(0, 54, 111, 54); | 181 | rb->lcd_drawline(0, 54, 111, 54); |
88 | 182 | ||
89 | rb->lcd_update(); | 183 | rb->lcd_update_rect(0, 0, 112, 10); |
184 | } | ||
185 | |||
186 | /****************************** | ||
187 | * DRAW left MiniMeters | ||
188 | ******************************/ | ||
189 | |||
190 | void draw_left_minimeters(void) | ||
191 | { | ||
192 | rb->lcd_bitmap(sound_speaker, 22, 56, 4, 8, true); | ||
193 | |||
194 | if(5<left_needle_top_x_no_log) | ||
195 | rb->lcd_bitmap(sound_low_level, 27, 56, 2, 8, false); | ||
196 | if(12<left_needle_top_x_no_log) | ||
197 | rb->lcd_bitmap(sound_med_level, 30, 56, 2, 8, false); | ||
198 | if(24<left_needle_top_x_no_log) | ||
199 | rb->lcd_bitmap(sound_high_level, 33, 56, 2, 8, false); | ||
200 | if(40<left_needle_top_x_no_log) | ||
201 | rb->lcd_bitmap(sound_max_level, 36, 56, 3, 8, false); | ||
202 | } | ||
203 | |||
204 | /******************************* | ||
205 | * DRAW right MiniMeters | ||
206 | *******************************/ | ||
207 | void draw_right_minimeters(void) | ||
208 | { | ||
209 | rb->lcd_bitmap(sound_speaker, 79, 56, 4, 8, true); | ||
210 | |||
211 | if(5<(right_needle_top_x_no_log-56)) | ||
212 | rb->lcd_bitmap(sound_low_level, 84, 56, 2, 8, false); | ||
213 | if(12<(right_needle_top_x_no_log-56)) | ||
214 | rb->lcd_bitmap(sound_med_level, 87, 56, 2, 8, false); | ||
215 | if(24<(right_needle_top_x_no_log-56)) | ||
216 | rb->lcd_bitmap(sound_high_level, 90, 56, 2, 8, false); | ||
217 | if(40<(right_needle_top_x_no_log-56)) | ||
218 | rb->lcd_bitmap(sound_max_level, 93, 56, 3, 8, false); | ||
219 | } | ||
220 | |||
221 | /*************************************** | ||
222 | * GENERAL SETTINGS - F1 | ||
223 | ***************************************/ | ||
224 | void general_settings(void) | ||
225 | { | ||
226 | char buf[15]; | ||
227 | int w, h; | ||
228 | |||
229 | while(!quit) | ||
230 | { | ||
231 | rb->lcd_clear_display(); | ||
232 | |||
233 | /* Left hand side (needle covers) */ | ||
234 | rb->lcd_putsxy(0, 15, "Needle"); | ||
235 | rb->lcd_putsxy(0, 23, "Covers:"); | ||
236 | if(needle_cover_mode == 1) | ||
237 | rb->lcd_putsxy(0, 32, "Rounded"); | ||
238 | else | ||
239 | rb->lcd_putsxy(0, 32, "Pyramid"); | ||
240 | rb->lcd_bitmap(left_arrow, 43, 23, 7, 8, true); | ||
241 | |||
242 | /* Right hand side (visible arch) */ | ||
243 | rb->snprintf(buf, sizeof(buf), "Visible"); | ||
244 | rb->lcd_getstringsize(buf, &w, &h); | ||
245 | rb->lcd_putsxy(LCD_WIDTH-w, 15, buf); | ||
246 | rb->snprintf(buf, sizeof(buf), "Arch:"); | ||
247 | rb->lcd_getstringsize(buf, &w, &h); | ||
248 | rb->lcd_putsxy(LCD_WIDTH-w, 23, buf); | ||
249 | rb->lcd_bitmap(right_arrow, 62, 23, 7, 8, true); | ||
250 | if(arch == 1) | ||
251 | { | ||
252 | rb->snprintf(buf, sizeof(buf), "Solid"); | ||
253 | rb->lcd_getstringsize(buf, &w, &h); | ||
254 | rb->lcd_putsxy(LCD_WIDTH-w, 32, buf); | ||
255 | } | ||
256 | else if(arch == 2) | ||
257 | { | ||
258 | rb->snprintf(buf, sizeof(buf), "Dotted"); | ||
259 | rb->lcd_getstringsize(buf, &w, &h); | ||
260 | rb->lcd_putsxy(LCD_WIDTH-w, 32, buf); | ||
261 | } | ||
262 | else | ||
263 | { | ||
264 | rb->snprintf(buf, sizeof(buf), "Off"); | ||
265 | rb->lcd_getstringsize(buf, &w, &h); | ||
266 | rb->lcd_putsxy(LCD_WIDTH-w, 32, buf); | ||
267 | } | ||
268 | |||
269 | rb->lcd_update(); | ||
270 | |||
271 | switch(rb->button_get_w_tmo(HZ/4)) | ||
272 | { | ||
273 | case BUTTON_F1: | ||
274 | case BUTTON_OFF: | ||
275 | quit = true; | ||
276 | break; | ||
277 | |||
278 | case BUTTON_RIGHT: | ||
279 | arch==3 ? arch=1 : arch++; | ||
280 | break; | ||
281 | |||
282 | case BUTTON_LEFT: | ||
283 | needle_cover_mode==2 ? needle_cover_mode=1 : needle_cover_mode++; | ||
284 | break; | ||
285 | } | ||
286 | } | ||
90 | } | 287 | } |
91 | 288 | ||
289 | /***************************** | ||
290 | * User Decay settings | ||
291 | *****************************/ | ||
292 | void user_decay_settings(void) | ||
293 | { | ||
294 | while(!quit) | ||
295 | { | ||
296 | rb->lcd_clear_display(); | ||
297 | |||
298 | rb->lcd_putsxy(2, 0, "User Decay Options"); | ||
299 | rb->lcd_putsxy(5, 15, "Release Speed:"); | ||
300 | |||
301 | switch(decay) | ||
302 | { | ||
303 | case 0: rb->lcd_putsxy(5, 23, "No Decay"); break; | ||
304 | case 1: rb->lcd_putsxy(5, 23, "Very Fast"); break; | ||
305 | case 2: rb->lcd_putsxy(5, 23, "Fast"); break; | ||
306 | case 3: rb->lcd_putsxy(5, 23, "Medium"); break; | ||
307 | case 4: rb->lcd_putsxy(5, 23, "Medium-Slow"); break; | ||
308 | case 5: rb->lcd_putsxy(5, 23, "Slow"); break; | ||
309 | case 6: rb->lcd_putsxy(5, 23, "Very Slow"); break; | ||
310 | default: break; | ||
311 | } | ||
312 | |||
313 | rb->lcd_putsxy(2, 48, "UP/DOWN: Change"); | ||
314 | rb->lcd_putsxy(2, 56, "OFF/F2: Back to VU"); | ||
315 | |||
316 | rb->lcd_update(); | ||
317 | |||
318 | switch(rb->button_get_w_tmo(HZ/4)) | ||
319 | { | ||
320 | case BUTTON_F2: | ||
321 | case BUTTON_OFF: | ||
322 | quit = true; | ||
323 | break; | ||
324 | |||
325 | case BUTTON_DOWN: | ||
326 | decay == 6 ? decay = 0 : decay++; | ||
327 | break; | ||
328 | |||
329 | case BUTTON_UP: | ||
330 | decay == 0 ? decay = 6 : decay--; | ||
331 | break; | ||
332 | } | ||
333 | } | ||
334 | } | ||
335 | |||
336 | /*********************************************************************** | ||
337 | * PLUGIN STARTS HERE | ||
338 | ***********************************************************************/ | ||
92 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 339 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
93 | { | 340 | { |
94 | TEST_PLUGIN_API(api); | 341 | TEST_PLUGIN_API(api); |
95 | (void) parameter; | 342 | (void) parameter; |
96 | rb = api; | 343 | rb = api; |
97 | 344 | ||
98 | draw_status_bar(); | 345 | /* Calculate the volume right away */ |
346 | vol = rb->global_settings->volume; | ||
347 | rb->snprintf(curr_vol, sizeof(curr_vol), "%d", vol); | ||
99 | 348 | ||
349 | rb->splash(HZ*2, true, "Press [ON] for help"); | ||
100 | while (!PLUGIN_OK) | 350 | while (!PLUGIN_OK) |
101 | { | 351 | { |
352 | quit = false; | ||
353 | |||
354 | #ifdef SIMULATOR | ||
355 | left_needle_top_x_no_log = rb->rand()%56; | ||
356 | right_needle_top_x_no_log = (rb->rand()%56)+56; | ||
357 | #else | ||
102 | left_needle_top_x_no_log = | 358 | left_needle_top_x_no_log = |
103 | (rb->mas_codec_readreg(0xC) * 56 / MAX_PEAK); | 359 | (rb->mas_codec_readreg(0xC) * 56 / MAX_PEAK); |
104 | 360 | ||
105 | right_needle_top_x_no_log = | 361 | right_needle_top_x_no_log = |
106 | (rb->mas_codec_readreg(0xD) * 56 / MAX_PEAK) + 56; | 362 | (rb->mas_codec_readreg(0xD) * 56 / MAX_PEAK) + 56; |
363 | #endif | ||
107 | 364 | ||
108 | rb->lcd_clear_display(); | 365 | rb->lcd_clear_display(); |
109 | 366 | ||
110 | if (use_log_scale) | 367 | if (use_log_scale) |
111 | { | 368 | { |
112 | left_needle_top_x = db_scale[left_needle_top_x_no_log]; | 369 | left_needle_top_x = db_scale[left_needle_top_x_no_log]; |
113 | right_needle_top_x = db_scale[right_needle_top_x_no_log-56]+56; | 370 | right_needle_top_x = db_scale[right_needle_top_x_no_log]; |
114 | } | 371 | } |
115 | 372 | ||
116 | else | 373 | else |
@@ -119,9 +376,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
119 | right_needle_top_x = right_needle_top_x_no_log; | 376 | right_needle_top_x = right_needle_top_x_no_log; |
120 | } | 377 | } |
121 | 378 | ||
122 | /* Makes a decay on the needle. Todo: Make a user custom decay. */ | 379 | /* Makes a decay on the needle (Custom Decay is at F2) */ |
123 | left_needle_top_x = (left_needle_top_x+old_left_needle_top_x*2)/3; | 380 | left_needle_top_x = (left_needle_top_x+old_left_needle_top_x*decay)/(decay+1); |
124 | right_needle_top_x = (right_needle_top_x+old_right_needle_top_x*2)/3; | 381 | right_needle_top_x = (right_needle_top_x+old_right_needle_top_x*decay)/(decay+1); |
125 | 382 | ||
126 | old_left_needle_top_x = left_needle_top_x; | 383 | old_left_needle_top_x = left_needle_top_x; |
127 | old_right_needle_top_x = right_needle_top_x; | 384 | old_right_needle_top_x = right_needle_top_x; |
@@ -136,6 +393,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
136 | rb->lcd_drawline(RIGHT_NEEDLE_BOTTOM_X, NEEDLE_BOTTOM_Y, | 393 | rb->lcd_drawline(RIGHT_NEEDLE_BOTTOM_X, NEEDLE_BOTTOM_Y, |
137 | right_needle_top_x, right_needle_top_y); | 394 | right_needle_top_x, right_needle_top_y); |
138 | 395 | ||
396 | /* We've got four needle cover modes... */ | ||
139 | if(needle_cover_mode == 1) /* Rounded needle cover. */ | 397 | if(needle_cover_mode == 1) /* Rounded needle cover. */ |
140 | { | 398 | { |
141 | /* Left needle cover, top to bottom */ | 399 | /* Left needle cover, top to bottom */ |
@@ -170,47 +428,95 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
170 | rb->lcd_drawline(80, 53, 88, 53); | 428 | rb->lcd_drawline(80, 53, 88, 53); |
171 | } | 429 | } |
172 | 430 | ||
173 | if(show_arch) | 431 | if(arch == 1) /* Solid */ |
174 | { | 432 | { |
175 | int i; | 433 | int i; |
176 | for(i=0;i<=112;i++) | 434 | for(i=0; i<=112; i++) |
177 | rb->lcd_drawpixel(i, (y_values[i])-2 ); | 435 | rb->lcd_drawpixel(i, (y_values[i])-2 ); |
178 | } | 436 | } |
437 | else if(arch == 2) /* Dotted */ | ||
438 | { | ||
439 | int i; | ||
440 | for(i=0; i<=112; i+=2) | ||
441 | rb->lcd_drawpixel(i, y_values[i]); | ||
442 | } | ||
443 | |||
444 | if(use_minimeters) | ||
445 | { | ||
446 | draw_left_minimeters(); | ||
447 | draw_right_minimeters(); | ||
448 | } | ||
179 | 449 | ||
180 | rb->lcd_update_rect(0,15,112,39); | 450 | draw_status_bar(); |
181 | 451 | ||
182 | switch (rb->button_get_w_tmo(1)) | 452 | rb->lcd_update(); |
453 | |||
454 | /* Using a faster timeout like "1" makes the | ||
455 | * minimeters flicker, HZ/35 looks good. */ | ||
456 | switch (rb->button_get_w_tmo(HZ/35)) | ||
183 | { | 457 | { |
458 | /* EXIT */ | ||
184 | case BUTTON_OFF: | 459 | case BUTTON_OFF: |
185 | return PLUGIN_OK; | 460 | return PLUGIN_OK; |
186 | break; | 461 | break; |
187 | 462 | ||
463 | /* INFO */ | ||
188 | case BUTTON_ON: | 464 | case BUTTON_ON: |
189 | rb->lcd_clear_display(); | 465 | rb->lcd_clear_display(); |
190 | rb->lcd_putsxy(1, 1, "Information:"); | 466 | while(!quit) |
191 | rb->lcd_putsxy(2, 15, "OFF: Exit"); | 467 | { |
192 | rb->lcd_putsxy(2, 25, "ON: This Info"); | 468 | rb->lcd_puts(0, 0, "OFF: Exit Plugin"); |
193 | rb->lcd_putsxy(2, 35, "PLAY: Change Scale"); | 469 | rb->lcd_puts(0, 1, "PLAY: Change Scale"); |
194 | rb->lcd_putsxy(2, 45, "F1: Needle Covers"); | 470 | rb->lcd_puts(0, 2, "F1: Settings"); |
195 | rb->lcd_putsxy(2, 55, "F2: Visible Arch"); | 471 | rb->lcd_puts(0, 3, "F2: Custom Decay"); |
196 | rb->lcd_update(); | 472 | rb->lcd_puts(0, 4, "F3: Mini-Meters"); |
197 | rb->sleep(HZ*3); | 473 | rb->lcd_puts(0, 5, "UP/DOWN: Volume"); |
198 | draw_status_bar(); | 474 | rb->lcd_puts(0, 7, "ON to exit..."); |
475 | |||
476 | rb->lcd_update(); | ||
477 | |||
478 | switch(rb->button_get_w_tmo(HZ/4)) | ||
479 | { | ||
480 | case BUTTON_ON: | ||
481 | quit = true; | ||
482 | break; | ||
483 | } | ||
484 | } | ||
199 | break; | 485 | break; |
200 | 486 | ||
487 | /* SCALE switch */ | ||
201 | case BUTTON_PLAY: | 488 | case BUTTON_PLAY: |
202 | use_log_scale = !use_log_scale; | 489 | use_log_scale = !use_log_scale; |
203 | draw_status_bar(); | ||
204 | break; | 490 | break; |
205 | 491 | ||
492 | /* GENERAL SETTINGS screen */ | ||
206 | case BUTTON_F1: | 493 | case BUTTON_F1: |
207 | needle_cover_mode==2 ? needle_cover_mode=1 : needle_cover_mode++; | 494 | general_settings(); |
208 | break; | 495 | break; |
209 | 496 | ||
497 | /* DECAY SETTINGS screen */ | ||
210 | case BUTTON_F2: | 498 | case BUTTON_F2: |
211 | show_arch = !show_arch; | 499 | user_decay_settings(); |
500 | break; | ||
501 | |||
502 | /* MINIMETER SETTINGS screen */ | ||
503 | case BUTTON_F3: | ||
504 | use_minimeters = !use_minimeters; | ||
505 | break; | ||
506 | |||
507 | /* VOLUME UP */ | ||
508 | case BUTTON_UP: | ||
509 | case BUTTON_UP | BUTTON_REPEAT: | ||
510 | ChangeVolume(1); | ||
511 | break; | ||
512 | |||
513 | /* VOLUME DOWN */ | ||
514 | case BUTTON_DOWN: | ||
515 | case BUTTON_DOWN | BUTTON_REPEAT: | ||
516 | ChangeVolume(-1); | ||
212 | break; | 517 | break; |
213 | 518 | ||
519 | /* USB CONNECTED */ | ||
214 | case SYS_USB_CONNECTED: | 520 | case SYS_USB_CONNECTED: |
215 | rb->usb_screen(); | 521 | rb->usb_screen(); |
216 | return PLUGIN_USB_CONNECTED; | 522 | return PLUGIN_USB_CONNECTED; |
@@ -219,4 +525,3 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
219 | } | 525 | } |
220 | } | 526 | } |
221 | #endif /* #ifdef HAVE_LCD_BITMAP */ | 527 | #endif /* #ifdef HAVE_LCD_BITMAP */ |
222 | #endif /* #ifndef SIMULATOR */ | ||