diff options
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/icons.c | 169 | ||||
-rw-r--r-- | apps/recorder/icons.h | 55 | ||||
-rw-r--r-- | apps/recorder/widgets.c | 161 | ||||
-rw-r--r-- | apps/recorder/widgets.h | 36 |
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 @@ #include <lcd.h> #include "icons.h" +#ifndef SIMULATOR +#include "sprintf.h" +#endif +#ifdef HAVE_RTC +#include "rtc.h" +#endif #ifdef HAVE_LCD_BITMAP @@ -34,6 +40,12 @@ unsigned char slider_bar[] = 0x7c, 0x28, 0x28, 0x28, 0x28, 0x38 }; +static unsigned char bitmap_icon_5x8[][5] = +{ + /* Lock */ + {0x78,0x7f,0x49,0x7f,0x78} +}; + unsigned char bitmap_icons_6x8[LastIcon][6] = { /* Box_Filled */ @@ -58,6 +70,36 @@ unsigned char bitmap_icons_6x8[LastIcon][6] = { 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x00 }, }; +static unsigned char bitmap_icon_7x8[][7] = +{ + /* Power plug */ + {0x08,0x1c,0x1c,0x3e,0x3e,0x14,0x14}, + /* Speaker */ + {0x00,0x1c,0x1c,0x3e,0x7f,0x00,0x00}, + /* Speaker mute */ + {0x01,0x1e,0x1c,0x3e,0x7f,0x20,0x40}, + /* Play */ + {0x00,0x7f,0x7f,0x3e,0x1c,0x08,0x00}, + /* Stop */ + {0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f}, + /* Pause */ + {0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00}, + /* Fast forward */ + {0x7f,0x3e,0x1c,0x7f,0x3e,0x1c,0x08}, + /* Fast backward */ + {0x08,0x1c,0x3e,0x7f,0x1c,0x3e,0x7f}, + /* Record */ + {0x1c,0x3e,0x7f,0x7f,0x7f,0x3e,0x1c}, + /* Record pause */ + {0x1c,0x3e,0x7f,0x00,0x7f,0x3e,0x1c}, + /* Normal playmode */ + {0x08,0x08,0x08,0x08,0x3e,0x1c,0x08}, + /* Repeat playmode */ + {0x38,0x44,0x44,0x4e,0x5f,0x44,0x38}, + /* Shuffle playmode (dice) */ + {0x3e,0x41,0x51,0x41,0x45,0x41,0x3e} +}; + unsigned char rockbox112x37[]={ 0x00, 0x00, 0x02, 0xff, 0x02, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xf8, 0xf8, 0xf0, 0xe0, 0x80, 0x00, 0x00, 0x80, 0xe0, 0xf0, 0xf8, 0xf8, 0xfc, @@ -111,4 +153,131 @@ unsigned char rockbox112x37[]={ }; +/* + * Wipe statusbar + */ +void statusbar_wipe(void) +{ + int x; + + for (x = 0; x < LCD_WIDTH; x++) + lcd_framebuffer[x][STATUSBAR_Y_POS/8]=0x00; +} + +/* + * Print battery icon to status bar + */ +void statusbar_icon_battery(int percent, bool charging) +{ + int i,j; + int fill; + + /* draw battery */ + for(i=0;i<17;i++) { + DRAW_PIXEL((ICON_BATTERY_X_POS+i),STATUSBAR_Y_POS); + DRAW_PIXEL((ICON_BATTERY_X_POS+i),(STATUSBAR_Y_POS+6)); + } + for(i=1;i<6;i++) { + DRAW_PIXEL(ICON_BATTERY_X_POS,(STATUSBAR_Y_POS+i)); + DRAW_PIXEL((ICON_BATTERY_X_POS+16),(STATUSBAR_Y_POS+i)); + } + for(i=2;i<5;i++) + DRAW_PIXEL((ICON_BATTERY_X_POS+17),(STATUSBAR_Y_POS+i)); + + /* fill battery */ + fill=percent; + if(fill<0) + fill=0; + if(fill>100) + fill=100; + fill=fill*15/100; + + for(i=1;i<=fill;i++) + for(j=1;j<6;j++) + DRAW_PIXEL((ICON_BATTERY_X_POS+i),(STATUSBAR_Y_POS+j)); + + if(charging) + lcd_bitmap(bitmap_icon_7x8[Icon_Plug], ICON_PLUG_X_POS, STATUSBAR_Y_POS, ICON_PLUG_WIDTH, STATUSBAR_HEIGHT, false); +}; + +/* + * Print volume gauge to status bar + */ +void statusbar_icon_volume(int percent) +{ + int i,j; + int volume; + int step=0; + + volume=percent; + if(volume<0) + volume=0; + if(volume>100) + volume=100; + + if(volume==0) + lcd_bitmap(bitmap_icon_7x8[Icon_Mute], ICON_VOLUME_X_POS+ICON_VOLUME_WIDTH/2-4, STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT, false); + else { + volume=volume*14/100; + for(i=0;i<volume;i++) { + if(i%2 == 0) + step++; + for(j=1;j<=step;j++) + DRAW_PIXEL((ICON_VOLUME_X_POS+i),(STATUSBAR_Y_POS+7-j)); + } + } +} + +/* + * Print play state to status bar + */ +void statusbar_icon_play_state(int state) +{ + lcd_bitmap(bitmap_icon_7x8[state], ICON_PLAY_STATE_X_POS, STATUSBAR_Y_POS, ICON_PLAY_STATE_WIDTH, STATUSBAR_HEIGHT, false); +} + +/* + * Print play mode to status bar + */ +void statusbar_icon_play_mode(int mode) +{ + lcd_bitmap(bitmap_icon_7x8[mode], ICON_PLAY_MODE_X_POS, STATUSBAR_Y_POS, ICON_PLAY_MODE_WIDTH, STATUSBAR_HEIGHT, false); +} + +/* + * Print shuffle mode to status bar + */ +void statusbar_icon_shuffle(void) +{ + lcd_bitmap(bitmap_icon_7x8[Icon_Shuffle], ICON_SHUFFLE_X_POS, STATUSBAR_Y_POS, ICON_SHUFFLE_WIDTH, STATUSBAR_HEIGHT, false); +} + +/* + * Print lock when keys are locked + */ +void statusbar_icon_lock(void) +{ + lcd_bitmap(bitmap_icon_5x8[Icon_Lock], LOCK_X_POS, STATUSBAR_Y_POS, 5, 8, false); +} + +#ifdef HAVE_RTC +/* + * Print time to status bar + */ +void statusbar_time(void) +{ + int hour,minute; + unsigned char buffer[6]; + + hour = rtc_read(0x03); + minute = rtc_read(0x02); + + snprintf(buffer, sizeof(buffer), "%d%d:%d%d", + (hour & 0x30) >> 4, + hour & 0x0f, + (minute & 0xf0) >> 4, + minute & 0x0f); + lcd_putsxy(TIME_X_POS, STATUSBAR_Y_POS, buffer, 0); +} +#endif #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[]; extern unsigned char slider_bar[]; -#endif /* End HAVE_LCD_BITMAP */ - - - +#define STATUSBAR_X_POS 0 +#define STATUSBAR_Y_POS 0 // MUST be a multiple of 8 +#define STATUSBAR_HEIGHT 8 +#define STATUSBAR_WIDTH LCD_WIDTH +#define ICON_BATTERY_X_POS 0 +#define ICON_BATTERY_WIDTH 18 +#define ICON_PLUG_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+2 +#define ICON_PLUG_WIDTH 7 +#define ICON_VOLUME_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+2+2 +#define ICON_VOLUME_WIDTH 14 +#define ICON_PLAY_STATE_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+ICON_VOLUME_WIDTH+2+2+2 +#define ICON_PLAY_STATE_WIDTH 7 +#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 +#define ICON_PLAY_MODE_WIDTH 7 +#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 +#define ICON_SHUFFLE_WIDTH 7 +#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 +#define LOCK_WIDTH 5 +#define TIME_X_POS STATUSBAR_WIDTH-5*6-1 +/* Symbolic names for icons */ +enum +{ + Icon_Lock = 0 +}; +enum +{ + Icon_Plug = 0, + Icon_Speaker, + Icon_Mute, + Icon_Play, + Icon_Stop, + Icon_Pause, + Icon_FastForward, + Icon_FastBackward, + Icon_Record, + Icon_RecPause, + Icon_Normal, + Icon_Repeat, + Icon_Shuffle +}; +extern void statusbar_wipe(void); +extern void statusbar_icon_battery(int percent, bool charging); +extern void statusbar_icon_volume(int percent); +extern void statusbar_icon_play_state(int state); +extern void statusbar_icon_play_mode(int mode); +extern void statusbar_icon_shuffle(void); +extern void statusbar_icon_lock(void); +#ifdef HAVE_RTC +extern void statusbar_time(void); +#endif +#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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: not checked in + * + * Copyright (C) 2002 Markus Braun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include <lcd.h> + +#include "widgets.h" + +#ifdef HAVE_LCD_BITMAP +/* + * Print a progress bar + */ +void progressbar(int x, int y, int width, int height, int percent, int direction) +{ + int pos; + int i,j; + + /* draw horizontal lines */ + for(i=x+1;i<=x+width-2;i++) { + DRAW_PIXEL(i,y); + DRAW_PIXEL(i,(y+height-1)); + } + + /* draw vertical lines */ + for(i=1;i<height;i++) { + DRAW_PIXEL(x,(y+i)); + DRAW_PIXEL((x+width-1),(y+i)); + } + + /* clear edge pixels */ + CLEAR_PIXEL(x,y); + CLEAR_PIXEL((x+width-1),y); + CLEAR_PIXEL(x,(y+height-1)); + CLEAR_PIXEL((x+width-1),(y+height-1)); + + /* clear pixels in progress bar */ + for(i=1;i<=width-2;i++) { + for(j=1;j<=height-2;j++) { + CLEAR_PIXEL((x+i),(y+j)); + CLEAR_PIXEL((x+i),(y+j)); + } + } + + /* draw bar */ + pos=percent; + if(pos<0) + pos=0; + if(pos>100) + pos=100; + + switch (direction) + { + case Grow_Right: + pos=(width-2)*pos/100; + for(i=1;i<=pos;i++) + for(j=1;j<height-1;j++) + DRAW_PIXEL((x+i),(y+j)); + break; + case Grow_Left: + pos=(width-2)*(100-pos)/100; + for(i=pos+1;i<=width-2;i++) + for(j=1;j<height-1;j++) + DRAW_PIXEL((x+i),(y+j)); + break; + case Grow_Down: + pos=(height-2)*pos/100; + for(i=1;i<=pos;i++) + for(j=1;j<width-1;j++) + DRAW_PIXEL((x+j),(y+i)); + break; + case Grow_Up: + pos=(height-2)*(100-pos)/100; + for(i=pos+1;i<=height-2;i++) + for(j=1;j<width-1;j++) + DRAW_PIXEL((x+j),(y+i)); + break; + } + +} + + +/* + * Print a slidebar bar + */ +void slidebar(int x, int y, int width, int height, int percent, int direction) +{ + int pos; + int i,j; + + /* draw horizontal lines */ + for(i=x+1;i<=x+width-2;i++) { + DRAW_PIXEL(i,y); + DRAW_PIXEL(i,(y+height-1)); + } + + /* draw vertical lines */ + for(i=1;i<height;i++) { + DRAW_PIXEL(x,(y+i)); + DRAW_PIXEL((x+width-1),(y+i)); + } + + /* clear edge pixels */ + CLEAR_PIXEL(x,y); + CLEAR_PIXEL((x+width-1),y); + CLEAR_PIXEL(x,(y+height-1)); + CLEAR_PIXEL((x+width-1),(y+height-1)); + + /* clear pixels in progress bar */ + for(i=1;i<=width-2;i++) + for(j=1;j<=height-2;j++) { + CLEAR_PIXEL((x+i),(y+j)); + CLEAR_PIXEL((x+i),(y+j)); + } + + /* draw point */ + pos=percent; + if(pos<0) + pos=0; + if(pos>100) + pos=100; + + switch (direction) + { + case Grow_Right: + pos=(width-height-1)*pos/100; + break; + case Grow_Left: + pos=(width-height-1)*(100-pos)/100; + break; + case Grow_Down: + pos=(height-width-1)*pos/100; + break; + case Grow_Up: + pos=(height-width-1)*(100-pos)/100; + break; + } + + if(direction == Grow_Left || direction == Grow_Right) + for(i=1;i<height;i++) + for(j=1;j<height;j++) + DRAW_PIXEL((x+pos+i),(y+j)); + else + for(i=1;i<width;i++) + for(j=1;j<width;j++) + DRAW_PIXEL((x+i),(y+pos+j)); +} +#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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: not checked in + * + * Copyright (C) 2002 Markus Braun + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef __WIDGETS_H__ +#define __WIDGETS_H__ +#include <lcd.h> + +#ifdef HAVE_LCD_BITMAP +/* Directions for progressbar and scrollbar */ +enum +{ + Grow_Right = 0, + Grow_Left, + Grow_Down, + Grow_Up +}; + +extern void progressbar(int x, int y, int width, int height, int percent, int direction); +extern void slidebar(int x, int y, int width, int height, int percent, int direction); +#endif /* HAVE_LCD_BITMAP */ +#endif /* __WIDGETS_H__ */ |