diff options
Diffstat (limited to 'apps/plugins/vu_meter.c')
-rw-r--r-- | apps/plugins/vu_meter.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c new file mode 100644 index 0000000000..e7e8d33ad8 --- /dev/null +++ b/apps/plugins/vu_meter.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2003 Lee Pilgrim | ||
10 | * | ||
11 | * All files in this archive are subject to the GNU General Public License. | ||
12 | * See the file COPYING in the source tree root for full license agreement. | ||
13 | * | ||
14 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
15 | * KIND, either express or implied. | ||
16 | * | ||
17 | **************************************************************************/ | ||
18 | #ifndef SIMULATOR /* The simulator dosen't have a MAS */ | ||
19 | #include "plugin.h" | ||
20 | |||
21 | #ifdef HAVE_LCD_BITMAP | ||
22 | |||
23 | static struct plugin_api* rb; | ||
24 | |||
25 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | ||
26 | { | ||
27 | TEST_PLUGIN_API(api); | ||
28 | (void) parameter; | ||
29 | rb = api; | ||
30 | |||
31 | /* | ||
32 | I hope to make (left/right)_needle_top_y change some day (because it looks | ||
33 | like it is stretching) so that is why it is a int and not a #define. | ||
34 | */ | ||
35 | #define LEFT_NEEDLE_BOTTOM_X 28 | ||
36 | #define LEFT_NEEDLE_BOTTOM_Y 53 | ||
37 | int left_needle_top_x; | ||
38 | int left_needle_top_y = 18; | ||
39 | |||
40 | #define RIGHT_NEEDLE_BOTTOM_X 84 | ||
41 | #define RIGHT_NEEDLE_BOTTOM_Y 53 | ||
42 | int right_needle_top_x; | ||
43 | int right_needle_top_y = 18; | ||
44 | |||
45 | while (!PLUGIN_OK) | ||
46 | { | ||
47 | /* These are to define how far the tip of the needles can go to the | ||
48 | left and right. The names are a bit confusing. The LEFT/RIGHT tells | ||
49 | which needle it is for, and the L/R at the end tells which side | ||
50 | of the needle. */ | ||
51 | #define MAX_LEFT_L 2 | ||
52 | #define MAX_LEFT_R 55 | ||
53 | #define MAX_RIGHT_L 57 | ||
54 | #define MAX_RIGHT_R 111 | ||
55 | |||
56 | #define MAX_PEAK 0x8FFF | ||
57 | |||
58 | left_needle_top_x = | ||
59 | (rb->mas_codec_readreg(0xC) * | ||
60 | (MAX_LEFT_R - MAX_LEFT_L) / MAX_PEAK) + MAX_LEFT_L; | ||
61 | |||
62 | right_needle_top_x = | ||
63 | (rb->mas_codec_readreg(0xD) * | ||
64 | (MAX_RIGHT_R - MAX_RIGHT_L) / MAX_PEAK) + MAX_RIGHT_L; | ||
65 | |||
66 | /* Time to draw all of the display stuff! | ||
67 | Could I move some of these out of the loop so they don't have to | ||
68 | be re-drawn everytime, but still be displayed, or would that | ||
69 | improve performance any at all? */ | ||
70 | rb->lcd_clear_display(); | ||
71 | |||
72 | rb->lcd_drawline(LEFT_NEEDLE_BOTTOM_X, LEFT_NEEDLE_BOTTOM_Y, | ||
73 | left_needle_top_x, left_needle_top_y); | ||
74 | rb->lcd_drawline(RIGHT_NEEDLE_BOTTOM_X, RIGHT_NEEDLE_BOTTOM_Y, | ||
75 | right_needle_top_x, right_needle_top_y); | ||
76 | |||
77 | rb->lcd_setfont(FONT_SYSFIXED); | ||
78 | rb->lcd_putsxy(30, 1, "VU Meter"); | ||
79 | |||
80 | /* The first is the line under "VU Meter" and the second is under | ||
81 | the needles. */ | ||
82 | rb->lcd_drawline(30, 9, 77, 9); | ||
83 | rb->lcd_drawline(1, 53, 112, 53); | ||
84 | |||
85 | /* These are the needle "covers" - we're going for that | ||
86 | "old fasioned" look */ | ||
87 | |||
88 | /* The left needle cover - organized from the top line to the bottom */ | ||
89 | rb->lcd_drawline(27, 48, 29, 48); | ||
90 | rb->lcd_drawline(25, 49, 31, 49); | ||
91 | rb->lcd_drawline(23, 50, 33, 50); | ||
92 | rb->lcd_drawline(22, 51, 34, 51); | ||
93 | rb->lcd_drawline(22, 52, 34, 52); | ||
94 | |||
95 | /* The right needle cover - organized from the top line to | ||
96 | the bottom */ | ||
97 | rb->lcd_drawline(83, 48, 85, 48); | ||
98 | rb->lcd_drawline(81, 49, 87, 49); | ||
99 | rb->lcd_drawline(79, 50, 89, 50); | ||
100 | rb->lcd_drawline(78, 51, 90, 51); | ||
101 | rb->lcd_drawline(78, 52, 90, 52); | ||
102 | |||
103 | rb->lcd_update(); | ||
104 | |||
105 | switch (rb->button_get(false)) | ||
106 | { | ||
107 | case BUTTON_OFF: | ||
108 | return false; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | #endif /* HAVE_LCD_BITMAP */ | ||
113 | #endif /* #ifndef SIMULATOR */ | ||