summaryrefslogtreecommitdiff
path: root/apps/recorder
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder')
-rw-r--r--apps/recorder/icons.c169
-rw-r--r--apps/recorder/icons.h55
-rw-r--r--apps/recorder/widgets.c161
-rw-r--r--apps/recorder/widgets.h36
4 files changed, 417 insertions, 4 deletions
diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c
index 50475eb8c9..482c764b52 100644
--- a/apps/recorder/icons.c
+++ b/apps/recorder/icons.c
@@ -19,6 +19,12 @@
19#include <lcd.h> 19#include <lcd.h>
20 20
21#include "icons.h" 21#include "icons.h"
22#ifndef SIMULATOR
23#include "sprintf.h"
24#endif
25#ifdef HAVE_RTC
26#include "rtc.h"
27#endif
22 28
23#ifdef HAVE_LCD_BITMAP 29#ifdef HAVE_LCD_BITMAP
24 30
@@ -34,6 +40,12 @@ unsigned char slider_bar[] =
34 0x7c, 0x28, 0x28, 0x28, 0x28, 0x38 40 0x7c, 0x28, 0x28, 0x28, 0x28, 0x38
35}; 41};
36 42
43static unsigned char bitmap_icon_5x8[][5] =
44{
45 /* Lock */
46 {0x78,0x7f,0x49,0x7f,0x78}
47};
48
37unsigned char bitmap_icons_6x8[LastIcon][6] = 49unsigned char bitmap_icons_6x8[LastIcon][6] =
38{ 50{
39 /* Box_Filled */ 51 /* Box_Filled */
@@ -58,6 +70,36 @@ unsigned char bitmap_icons_6x8[LastIcon][6] =
58 { 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x00 }, 70 { 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x00 },
59}; 71};
60 72
73static unsigned char bitmap_icon_7x8[][7] =
74{
75 /* Power plug */
76 {0x08,0x1c,0x1c,0x3e,0x3e,0x14,0x14},
77 /* Speaker */
78 {0x00,0x1c,0x1c,0x3e,0x7f,0x00,0x00},
79 /* Speaker mute */
80 {0x01,0x1e,0x1c,0x3e,0x7f,0x20,0x40},
81 /* Play */
82 {0x00,0x7f,0x7f,0x3e,0x1c,0x08,0x00},
83 /* Stop */
84 {0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f},
85 /* Pause */
86 {0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00},
87 /* Fast forward */
88 {0x7f,0x3e,0x1c,0x7f,0x3e,0x1c,0x08},
89 /* Fast backward */
90 {0x08,0x1c,0x3e,0x7f,0x1c,0x3e,0x7f},
91 /* Record */
92 {0x1c,0x3e,0x7f,0x7f,0x7f,0x3e,0x1c},
93 /* Record pause */
94 {0x1c,0x3e,0x7f,0x00,0x7f,0x3e,0x1c},
95 /* Normal playmode */
96 {0x08,0x08,0x08,0x08,0x3e,0x1c,0x08},
97 /* Repeat playmode */
98 {0x38,0x44,0x44,0x4e,0x5f,0x44,0x38},
99 /* Shuffle playmode (dice) */
100 {0x3e,0x41,0x51,0x41,0x45,0x41,0x3e}
101};
102
61unsigned char rockbox112x37[]={ 103unsigned char rockbox112x37[]={
62 0x00, 0x00, 0x02, 0xff, 0x02, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 104 0x00, 0x00, 0x02, 0xff, 0x02, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa,
63 0xf8, 0xf8, 0xf0, 0xe0, 0x80, 0x00, 0x00, 0x80, 0xe0, 0xf0, 0xf8, 0xf8, 0xfc, 105 0xf8, 0xf8, 0xf0, 0xe0, 0x80, 0x00, 0x00, 0x80, 0xe0, 0xf0, 0xf8, 0xf8, 0xfc,
@@ -111,4 +153,131 @@ unsigned char rockbox112x37[]={
111 153
112}; 154};
113 155
156/*
157 * Wipe statusbar
158 */
159void statusbar_wipe(void)
160{
161 int x;
162
163 for (x = 0; x < LCD_WIDTH; x++)
164 lcd_framebuffer[x][STATUSBAR_Y_POS/8]=0x00;
165}
166
167/*
168 * Print battery icon to status bar
169 */
170void statusbar_icon_battery(int percent, bool charging)
171{
172 int i,j;
173 int fill;
174
175 /* draw battery */
176 for(i=0;i<17;i++) {
177 DRAW_PIXEL((ICON_BATTERY_X_POS+i),STATUSBAR_Y_POS);
178 DRAW_PIXEL((ICON_BATTERY_X_POS+i),(STATUSBAR_Y_POS+6));
179 }
180 for(i=1;i<6;i++) {
181 DRAW_PIXEL(ICON_BATTERY_X_POS,(STATUSBAR_Y_POS+i));
182 DRAW_PIXEL((ICON_BATTERY_X_POS+16),(STATUSBAR_Y_POS+i));
183 }
184 for(i=2;i<5;i++)
185 DRAW_PIXEL((ICON_BATTERY_X_POS+17),(STATUSBAR_Y_POS+i));
186
187 /* fill battery */
188 fill=percent;
189 if(fill<0)
190 fill=0;
191 if(fill>100)
192 fill=100;
193 fill=fill*15/100;
194
195 for(i=1;i<=fill;i++)
196 for(j=1;j<6;j++)
197 DRAW_PIXEL((ICON_BATTERY_X_POS+i),(STATUSBAR_Y_POS+j));
198
199 if(charging)
200 lcd_bitmap(bitmap_icon_7x8[Icon_Plug], ICON_PLUG_X_POS, STATUSBAR_Y_POS, ICON_PLUG_WIDTH, STATUSBAR_HEIGHT, false);
201};
202
203/*
204 * Print volume gauge to status bar
205 */
206void statusbar_icon_volume(int percent)
207{
208 int i,j;
209 int volume;
210 int step=0;
211
212 volume=percent;
213 if(volume<0)
214 volume=0;
215 if(volume>100)
216 volume=100;
217
218 if(volume==0)
219 lcd_bitmap(bitmap_icon_7x8[Icon_Mute], ICON_VOLUME_X_POS+ICON_VOLUME_WIDTH/2-4, STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT, false);
220 else {
221 volume=volume*14/100;
222 for(i=0;i<volume;i++) {
223 if(i%2 == 0)
224 step++;
225 for(j=1;j<=step;j++)
226 DRAW_PIXEL((ICON_VOLUME_X_POS+i),(STATUSBAR_Y_POS+7-j));
227 }
228 }
229}
230
231/*
232 * Print play state to status bar
233 */
234void statusbar_icon_play_state(int state)
235{
236 lcd_bitmap(bitmap_icon_7x8[state], ICON_PLAY_STATE_X_POS, STATUSBAR_Y_POS, ICON_PLAY_STATE_WIDTH, STATUSBAR_HEIGHT, false);
237}
238
239/*
240 * Print play mode to status bar
241 */
242void statusbar_icon_play_mode(int mode)
243{
244 lcd_bitmap(bitmap_icon_7x8[mode], ICON_PLAY_MODE_X_POS, STATUSBAR_Y_POS, ICON_PLAY_MODE_WIDTH, STATUSBAR_HEIGHT, false);
245}
246
247/*
248 * Print shuffle mode to status bar
249 */
250void statusbar_icon_shuffle(void)
251{
252 lcd_bitmap(bitmap_icon_7x8[Icon_Shuffle], ICON_SHUFFLE_X_POS, STATUSBAR_Y_POS, ICON_SHUFFLE_WIDTH, STATUSBAR_HEIGHT, false);
253}
254
255/*
256 * Print lock when keys are locked
257 */
258void statusbar_icon_lock(void)
259{
260 lcd_bitmap(bitmap_icon_5x8[Icon_Lock], LOCK_X_POS, STATUSBAR_Y_POS, 5, 8, false);
261}
262
263#ifdef HAVE_RTC
264/*
265 * Print time to status bar
266 */
267void statusbar_time(void)
268{
269 int hour,minute;
270 unsigned char buffer[6];
271
272 hour = rtc_read(0x03);
273 minute = rtc_read(0x02);
274
275 snprintf(buffer, sizeof(buffer), "%d%d:%d%d",
276 (hour & 0x30) >> 4,
277 hour & 0x0f,
278 (minute & 0xf0) >> 4,
279 minute & 0x0f);
280 lcd_putsxy(TIME_X_POS, STATUSBAR_Y_POS, buffer, 0);
281}
282#endif
114#endif 283#endif
diff --git a/apps/recorder/icons.h b/apps/recorder/icons.h
index 866e4888f2..da94c2269a 100644
--- a/apps/recorder/icons.h
+++ b/apps/recorder/icons.h
@@ -36,9 +36,56 @@ extern unsigned char rockbox112x37[];
36 36
37extern unsigned char slider_bar[]; 37extern unsigned char slider_bar[];
38 38
39#endif /* End HAVE_LCD_BITMAP */ 39#define STATUSBAR_X_POS 0
40 40#define STATUSBAR_Y_POS 0 // MUST be a multiple of 8
41 41#define STATUSBAR_HEIGHT 8
42 42#define STATUSBAR_WIDTH LCD_WIDTH
43#define ICON_BATTERY_X_POS 0
44#define ICON_BATTERY_WIDTH 18
45#define ICON_PLUG_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+2
46#define ICON_PLUG_WIDTH 7
47#define ICON_VOLUME_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+2+2
48#define ICON_VOLUME_WIDTH 14
49#define ICON_PLAY_STATE_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+ICON_VOLUME_WIDTH+2+2+2
50#define ICON_PLAY_STATE_WIDTH 7
51#define ICON_PLAY_MODE_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+ICON_VOLUME_WIDTH+ICON_PLAY_STATE_WIDTH+2+2+2+2
52#define ICON_PLAY_MODE_WIDTH 7
53#define ICON_SHUFFLE_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+ICON_VOLUME_WIDTH+ICON_PLAY_STATE_WIDTH+ICON_PLAY_MODE_WIDTH+2+2+2+2+2
54#define ICON_SHUFFLE_WIDTH 7
55#define LOCK_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+ICON_VOLUME_WIDTH+ICON_PLAY_STATE_WIDTH+ICON_PLAY_MODE_WIDTH+ICON_SHUFFLE_WIDTH+2+2+2+2+2+2
56#define LOCK_WIDTH 5
57#define TIME_X_POS STATUSBAR_WIDTH-5*6-1
43 58
59/* Symbolic names for icons */
60enum
61{
62 Icon_Lock = 0
63};
64enum
65{
66 Icon_Plug = 0,
67 Icon_Speaker,
68 Icon_Mute,
69 Icon_Play,
70 Icon_Stop,
71 Icon_Pause,
72 Icon_FastForward,
73 Icon_FastBackward,
74 Icon_Record,
75 Icon_RecPause,
76 Icon_Normal,
77 Icon_Repeat,
78 Icon_Shuffle
79};
44 80
81extern void statusbar_wipe(void);
82extern void statusbar_icon_battery(int percent, bool charging);
83extern void statusbar_icon_volume(int percent);
84extern void statusbar_icon_play_state(int state);
85extern void statusbar_icon_play_mode(int mode);
86extern void statusbar_icon_shuffle(void);
87extern void statusbar_icon_lock(void);
88#ifdef HAVE_RTC
89extern void statusbar_time(void);
90#endif
91#endif /* End HAVE_LCD_BITMAP */
diff --git a/apps/recorder/widgets.c b/apps/recorder/widgets.c
new file mode 100644
index 0000000000..1c3f0b1a10
--- /dev/null
+++ b/apps/recorder/widgets.c
@@ -0,0 +1,161 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: not checked in
9 *
10 * Copyright (C) 2002 Markus Braun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include <lcd.h>
20
21#include "widgets.h"
22
23#ifdef HAVE_LCD_BITMAP
24/*
25 * Print a progress bar
26 */
27void progressbar(int x, int y, int width, int height, int percent, int direction)
28{
29 int pos;
30 int i,j;
31
32 /* draw horizontal lines */
33 for(i=x+1;i<=x+width-2;i++) {
34 DRAW_PIXEL(i,y);
35 DRAW_PIXEL(i,(y+height-1));
36 }
37
38 /* draw vertical lines */
39 for(i=1;i<height;i++) {
40 DRAW_PIXEL(x,(y+i));
41 DRAW_PIXEL((x+width-1),(y+i));
42 }
43
44 /* clear edge pixels */
45 CLEAR_PIXEL(x,y);
46 CLEAR_PIXEL((x+width-1),y);
47 CLEAR_PIXEL(x,(y+height-1));
48 CLEAR_PIXEL((x+width-1),(y+height-1));
49
50 /* clear pixels in progress bar */
51 for(i=1;i<=width-2;i++) {
52 for(j=1;j<=height-2;j++) {
53 CLEAR_PIXEL((x+i),(y+j));
54 CLEAR_PIXEL((x+i),(y+j));
55 }
56 }
57
58 /* draw bar */
59 pos=percent;
60 if(pos<0)
61 pos=0;
62 if(pos>100)
63 pos=100;
64
65 switch (direction)
66 {
67 case Grow_Right:
68 pos=(width-2)*pos/100;
69 for(i=1;i<=pos;i++)
70 for(j=1;j<height-1;j++)
71 DRAW_PIXEL((x+i),(y+j));
72 break;
73 case Grow_Left:
74 pos=(width-2)*(100-pos)/100;
75 for(i=pos+1;i<=width-2;i++)
76 for(j=1;j<height-1;j++)
77 DRAW_PIXEL((x+i),(y+j));
78 break;
79 case Grow_Down:
80 pos=(height-2)*pos/100;
81 for(i=1;i<=pos;i++)
82 for(j=1;j<width-1;j++)
83 DRAW_PIXEL((x+j),(y+i));
84 break;
85 case Grow_Up:
86 pos=(height-2)*(100-pos)/100;
87 for(i=pos+1;i<=height-2;i++)
88 for(j=1;j<width-1;j++)
89 DRAW_PIXEL((x+j),(y+i));
90 break;
91 }
92
93}
94
95
96/*
97 * Print a slidebar bar
98 */
99void slidebar(int x, int y, int width, int height, int percent, int direction)
100{
101 int pos;
102 int i,j;
103
104 /* draw horizontal lines */
105 for(i=x+1;i<=x+width-2;i++) {
106 DRAW_PIXEL(i,y);
107 DRAW_PIXEL(i,(y+height-1));
108 }
109
110 /* draw vertical lines */
111 for(i=1;i<height;i++) {
112 DRAW_PIXEL(x,(y+i));
113 DRAW_PIXEL((x+width-1),(y+i));
114 }
115
116 /* clear edge pixels */
117 CLEAR_PIXEL(x,y);
118 CLEAR_PIXEL((x+width-1),y);
119 CLEAR_PIXEL(x,(y+height-1));
120 CLEAR_PIXEL((x+width-1),(y+height-1));
121
122 /* clear pixels in progress bar */
123 for(i=1;i<=width-2;i++)
124 for(j=1;j<=height-2;j++) {
125 CLEAR_PIXEL((x+i),(y+j));
126 CLEAR_PIXEL((x+i),(y+j));
127 }
128
129 /* draw point */
130 pos=percent;
131 if(pos<0)
132 pos=0;
133 if(pos>100)
134 pos=100;
135
136 switch (direction)
137 {
138 case Grow_Right:
139 pos=(width-height-1)*pos/100;
140 break;
141 case Grow_Left:
142 pos=(width-height-1)*(100-pos)/100;
143 break;
144 case Grow_Down:
145 pos=(height-width-1)*pos/100;
146 break;
147 case Grow_Up:
148 pos=(height-width-1)*(100-pos)/100;
149 break;
150 }
151
152 if(direction == Grow_Left || direction == Grow_Right)
153 for(i=1;i<height;i++)
154 for(j=1;j<height;j++)
155 DRAW_PIXEL((x+pos+i),(y+j));
156 else
157 for(i=1;i<width;i++)
158 for(j=1;j<width;j++)
159 DRAW_PIXEL((x+i),(y+pos+j));
160}
161#endif
diff --git a/apps/recorder/widgets.h b/apps/recorder/widgets.h
new file mode 100644
index 0000000000..bae9f391de
--- /dev/null
+++ b/apps/recorder/widgets.h
@@ -0,0 +1,36 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: not checked in
9 *
10 * Copyright (C) 2002 Markus Braun
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef __WIDGETS_H__
20#define __WIDGETS_H__
21#include <lcd.h>
22
23#ifdef HAVE_LCD_BITMAP
24/* Directions for progressbar and scrollbar */
25enum
26{
27 Grow_Right = 0,
28 Grow_Left,
29 Grow_Down,
30 Grow_Up
31};
32
33extern void progressbar(int x, int y, int width, int height, int percent, int direction);
34extern void slidebar(int x, int y, int width, int height, int percent, int direction);
35#endif /* HAVE_LCD_BITMAP */
36#endif /* __WIDGETS_H__ */