Moved on_screen, f2_screen, f3_screen and handle_usb (renamed usb_screen) to a new file: screens.c.

typedef Menu replaced with a bool.
All code now calls usb_screen() for usb handling.
Nearly all code now deals with USB connect/disconnect properly.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2401 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-09-24 17:22:12 +00:00
parent c909b4b42e
commit b1b8bd4dd1
29 changed files with 695 additions and 645 deletions

View file

@ -46,7 +46,7 @@ extern char *thread_name[];
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* Test code!!! */ /* Test code!!! */
Menu dbg_os(void) bool dbg_os(void)
{ {
char buf[32]; char buf[32];
int button; int button;
@ -77,13 +77,13 @@ Menu dbg_os(void)
{ {
case BUTTON_OFF: case BUTTON_OFF:
case BUTTON_LEFT: case BUTTON_LEFT:
return MENU_OK; return false;
} }
} }
return MENU_OK; return false;
} }
#else #else
Menu dbg_os(void) bool dbg_os(void)
{ {
char buf[32]; char buf[32];
int button; int button;
@ -110,7 +110,7 @@ Menu dbg_os(void)
switch(button) switch(button)
{ {
case BUTTON_STOP: case BUTTON_STOP:
return MENU_OK; return false;
case BUTTON_LEFT: case BUTTON_LEFT:
currval--; currval--;
@ -125,13 +125,13 @@ Menu dbg_os(void)
break; break;
} }
} }
return MENU_OK; return false;
} }
#endif #endif
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* Test code!!! */ /* Test code!!! */
Menu dbg_ports(void) bool dbg_ports(void)
{ {
unsigned short porta; unsigned short porta;
unsigned short portb; unsigned short portb;
@ -186,13 +186,13 @@ Menu dbg_ports(void)
switch(button) switch(button)
{ {
case BUTTON_OFF: case BUTTON_OFF:
return MENU_OK; return false;
} }
} }
return MENU_OK; return false;
} }
#else #else
Menu dbg_ports(void) bool dbg_ports(void)
{ {
unsigned short porta; unsigned short porta;
unsigned short portb; unsigned short portb;
@ -268,7 +268,7 @@ Menu dbg_ports(void)
switch(button) switch(button)
{ {
case BUTTON_STOP: case BUTTON_STOP:
return MENU_OK; return false;
case BUTTON_LEFT: case BUTTON_LEFT:
currval--; currval--;
@ -283,13 +283,13 @@ Menu dbg_ports(void)
break; break;
} }
} }
return MENU_OK; return false;
} }
#endif #endif
#ifdef HAVE_RTC #ifdef HAVE_RTC
/* Read RTC RAM contents and display them */ /* Read RTC RAM contents and display them */
Menu dbg_rtc(void) bool dbg_rtc(void)
{ {
char buf[32]; char buf[32];
unsigned char addr = 0, r, c; unsigned char addr = 0, r, c;
@ -333,15 +333,15 @@ Menu dbg_rtc(void)
break; break;
case BUTTON_OFF: case BUTTON_OFF:
case BUTTON_LEFT: case BUTTON_LEFT:
return MENU_OK; return false;
} }
} }
return MENU_OK; return false;
} }
#else #else
Menu dbg_rtc(void) bool dbg_rtc(void)
{ {
return MENU_OK; return false;
} }
#endif #endif
@ -351,7 +351,7 @@ Menu dbg_rtc(void)
#define NUMROWS 4 #define NUMROWS 4
#endif #endif
/* Read MAS registers and display them */ /* Read MAS registers and display them */
Menu dbg_mas(void) bool dbg_mas(void)
{ {
char buf[32]; char buf[32];
unsigned int addr = 0, r, i; unsigned int addr = 0, r, i;
@ -395,14 +395,14 @@ Menu dbg_mas(void)
#else #else
case BUTTON_DOWN: case BUTTON_DOWN:
#endif #endif
return MENU_OK; return false;
} }
} }
return MENU_OK; return false;
} }
#ifdef HAVE_MAS3587F #ifdef HAVE_MAS3587F
Menu dbg_mas_codec(void) bool dbg_mas_codec(void)
{ {
char buf[32]; char buf[32];
unsigned int addr = 0, r, i; unsigned int addr = 0, r, i;
@ -433,10 +433,10 @@ Menu dbg_mas_codec(void)
if (addr) { addr -= 4; } if (addr) { addr -= 4; }
break; break;
case BUTTON_LEFT: case BUTTON_LEFT:
return MENU_OK; return false;
} }
} }
return MENU_OK; return false;
} }
#endif #endif
@ -450,7 +450,7 @@ Menu dbg_mas_codec(void)
#define BAT_FIRST_VAL MAX(POWER_HISTORY_LEN - LCD_WIDTH - 1, 0) #define BAT_FIRST_VAL MAX(POWER_HISTORY_LEN - LCD_WIDTH - 1, 0)
#define BAT_YSPACE (LCD_HEIGHT - 20) #define BAT_YSPACE (LCD_HEIGHT - 20)
Menu view_battery(void) bool view_battery(void)
{ {
int view = 0; int view = 0;
int i, x, y; int i, x, y;
@ -571,16 +571,16 @@ Menu view_battery(void)
case BUTTON_LEFT: case BUTTON_LEFT:
case BUTTON_OFF: case BUTTON_OFF:
return MENU_OK; return false;
} }
} }
return MENU_OK; return false;
} }
#endif #endif
#ifdef HAVE_MAS3507D #ifdef HAVE_MAS3507D
Menu dbg_mas_info(void) bool dbg_mas_info(void)
{ {
int button; int button;
char buf[32]; char buf[32];
@ -714,7 +714,7 @@ Menu dbg_mas_info(void)
switch(button) switch(button)
{ {
case BUTTON_STOP: case BUTTON_STOP:
return MENU_OK; return false;
case BUTTON_LEFT: case BUTTON_LEFT:
currval--; currval--;
@ -750,14 +750,14 @@ Menu dbg_mas_info(void)
break; break;
} }
} }
return MENU_OK; return false;
} }
#endif #endif
Menu debug_menu(void) bool debug_menu(void)
{ {
int m; int m;
Menu result; bool result;
struct menu_items items[] = { struct menu_items items[] = {
{ "View I/O ports", dbg_ports }, { "View I/O ports", dbg_ports },

View file

@ -19,12 +19,12 @@
#ifndef _DEBUG_MENU_H #ifndef _DEBUG_MENU_H
#define _DEBUG_MENU_H #define _DEBUG_MENU_H
Menu debug_menu(void); bool debug_menu(void);
#ifndef SIMULATOR #ifndef SIMULATOR
extern Menu dbg_ports(void); extern bool dbg_ports(void);
#ifdef HAVE_RTC #ifdef HAVE_RTC
extern Menu dbg_rtc(void); extern bool dbg_rtc(void);
#endif #endif
#endif #endif

View file

@ -33,14 +33,14 @@
#include "lang.h" #include "lang.h"
extern Menu bounce(void); extern bool bounce(void);
extern Menu snow(void); extern bool snow(void);
extern Menu oscillograph(void); extern bool oscillograph(void);
Menu demo_menu(void) bool demo_menu(void)
{ {
int m; int m;
Menu result; bool result;
struct menu_items items[] = { struct menu_items items[] = {
{ str(LANG_BOUNCE), bounce }, { str(LANG_BOUNCE), bounce },

View file

@ -19,7 +19,7 @@
#ifndef _DEMOS_MENU_H #ifndef _DEMOS_MENU_H
#define _DEMOS_MENU_H #define _DEMOS_MENU_H
Menu demo_menu(void); bool demo_menu(void);
#endif #endif

View file

@ -36,13 +36,13 @@
#include "wormlet.h" #include "wormlet.h"
#include "lang.h" #include "lang.h"
extern Menu tetris(void); extern bool tetris(void);
extern Menu snake(void); extern bool snake(void);
Menu games_menu(void) bool games_menu(void)
{ {
int m; int m;
Menu result; bool result;
struct menu_items items[] = { struct menu_items items[] = {
{ str(LANG_TETRIS), tetris }, { str(LANG_TETRIS), tetris },

View file

@ -21,6 +21,6 @@
#include "menu.h" #include "menu.h"
Menu games_menu(void); bool games_menu(void);
#endif #endif

View file

@ -117,7 +117,7 @@ int show_logo( void )
return 0; return 0;
} }
Menu show_credits(void) bool show_credits(void)
{ {
int j = 0; int j = 0;
int btn; int btn;
@ -132,23 +132,23 @@ Menu show_credits(void)
btn = button_get(false); btn = button_get(false);
if (btn != BUTTON_NONE && !(btn & BUTTON_REL)) if (btn != BUTTON_NONE && !(btn & BUTTON_REL))
return MENU_OK; return false;
} }
roll_credits(); roll_credits();
return MENU_OK; return false;
} }
#ifdef SIMULATOR #ifdef SIMULATOR
#define mp3buf 0 #define mp3buf 0
#define mp3end 0 #define mp3end 0
extern Menu simulate_usb(void); extern bool simulate_usb(void);
#else #else
/* defined in linker script */ /* defined in linker script */
extern unsigned char mp3buf[]; extern unsigned char mp3buf[];
extern unsigned char mp3end[]; extern unsigned char mp3end[];
#endif #endif
Menu show_info(void) bool show_info(void)
{ {
char s[32]; char s[32];
int buflen = ((mp3end - mp3buf) * 100) / 0x100000; int buflen = ((mp3end - mp3buf) * 100) / 0x100000;
@ -199,13 +199,13 @@ Menu show_info(void)
done = true; done = true;
} }
return MENU_OK; return false;
} }
Menu main_menu(void) bool main_menu(void)
{ {
int m; int m;
Menu result; bool result;
/* main menu */ /* main menu */
struct menu_items items[] = { struct menu_items items[] = {

View file

@ -22,6 +22,6 @@
#include "menu.h" #include "menu.h"
extern int show_logo(void); extern int show_logo(void);
extern Menu main_menu(void); extern bool main_menu(void);
#endif #endif

View file

@ -33,7 +33,7 @@
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#include "icons.h" #include "icons.h"
#include "widgets.h" #include "widgets.h"
#include "wps.h" #include "screens.h"
#endif #endif
struct menu { struct menu {
@ -242,13 +242,13 @@ void menu_exit(int m)
inuse[m] = false; inuse[m] = false;
} }
Menu menu_run(int m) bool menu_run(int m)
{ {
Menu result = MENU_OK; bool exit = false;
menu_draw(m); menu_draw(m);
while(1) { while (!exit) {
switch( button_get_w_tmo(HZ/2) ) { switch( button_get_w_tmo(HZ/2) ) {
#ifdef HAVE_RECORDER_KEYPAD #ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP: case BUTTON_UP:
@ -303,12 +303,12 @@ Menu menu_run(int m)
are gonna clear the screen anyway */ are gonna clear the screen anyway */
lcd_clear_display(); lcd_clear_display();
/* if a child returns that the contents is changed, we /* if a child returns that USB was used,
must remember this, even if we perhaps invoke other we return immediately */
children too before returning back */ if (menus[m].items[menus[m].cursor].function()) {
if(MENU_DISK_CHANGED == lcd_scroll_pause(); /* just in case */
menus[m].items[menus[m].cursor].function()) return true;
result = MENU_DISK_CHANGED; }
/* Return to previous display state */ /* Return to previous display state */
menu_draw(m); menu_draw(m);
@ -321,39 +321,29 @@ Menu menu_run(int m)
case BUTTON_STOP: case BUTTON_STOP:
case BUTTON_MENU: case BUTTON_MENU:
#endif #endif
lcd_stop_scroll(); lcd_scroll_pause();
while (button_get(false)); /* clear button queue */ exit = true;
return result; break;
#ifdef HAVE_RECORDER_KEYPAD #ifdef HAVE_RECORDER_KEYPAD
case BUTTON_F3: case BUTTON_F3:
if (f3_screen()) if (f3_screen())
return SYS_USB_CONNECTED; return true;
menu_draw(m); menu_draw(m);
break; break;
#endif #endif
#ifndef SIMULATOR
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
backlight_time(4); usb_screen();
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_wait_for_disconnect(&button_queue);
backlight_time(global_settings.backlight);
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
lcd_icon(ICON_PARAM, true); lcd_icon(ICON_PARAM, false);
#endif #endif
menu_draw(m); return true;
result = MENU_DISK_CHANGED;
break;
#endif
default:
break;
} }
status_draw(); status_draw();
lcd_update(); lcd_update();
} }
return result; return false;
} }

View file

@ -22,16 +22,9 @@
#include <stdbool.h> #include <stdbool.h>
typedef enum {
MENU_OK,
MENU_DISK_CHANGED, /* any file/directory contents need to be re-read */
MENU_LAST /* don't use as return code, only for number of return codes
available */
} Menu;
struct menu_items { struct menu_items {
unsigned char *desc; unsigned char *desc;
Menu (*function) (void); bool (*function) (void); /* return true if USB was connected */
}; };
int menu_init(struct menu_items* items, int count); int menu_init(struct menu_items* items, int count);
@ -39,6 +32,6 @@ void menu_exit(int menu);
void put_cursorxy(int x, int y, bool on); void put_cursorxy(int x, int y, bool on);
Menu menu_run(int menu); bool menu_run(int menu);
#endif /* End __MENU_H__ */ #endif /* End __MENU_H__ */

View file

@ -257,10 +257,10 @@ void game_init(void) {
} }
Menu snake(void) { bool snake(void) {
game_init(); game_init();
lcd_clear_display(); lcd_clear_display();
game(); game();
return MENU_OK; return false;
} }

View file

@ -27,6 +27,7 @@
#include "button.h" #include "button.h"
#include "kernel.h" #include "kernel.h"
#include "menu.h" #include "menu.h"
#include "screens.h"
#ifdef SIMULATOR #ifdef SIMULATOR
#include <stdio.h> #include <stdio.h>
@ -37,6 +38,10 @@
#define SOKOBAN_TITLE_FONT 2 #define SOKOBAN_TITLE_FONT 2
#define NUM_LEVELS sizeof(levels)/320 #define NUM_LEVELS sizeof(levels)/320
static void load_level(int);
static void update_screen(void);
static bool sokoban_loop(void);
static char board[16][20]; static char board[16][20];
static int current_level=0; static int current_level=0;
static int moves=0; static int moves=0;
@ -1766,7 +1771,7 @@ static const char levels[][320] = {
}; };
void load_level (int level_to_load) { static void load_level (int level_to_load) {
int a = 0; int a = 0;
int b = 0; int b = 0;
int c = 0; int c = 0;
@ -1790,7 +1795,7 @@ void load_level (int level_to_load) {
return; return;
} }
void update_screen(void) { static void update_screen(void) {
int b = 0; int b = 0;
int c = 0; int c = 0;
char s[25]; char s[25];
@ -1855,7 +1860,8 @@ void update_screen(void) {
void sokoban_loop(void) { static bool sokoban_loop(void)
{
int ii = 0; int ii = 0;
moves = 0; moves = 0;
current_level = 0; current_level = 0;
@ -1868,7 +1874,7 @@ void sokoban_loop(void) {
case BUTTON_OFF: case BUTTON_OFF:
/* get out of here */ /* get out of here */
return; return false;
case BUTTON_F3: case BUTTON_F3:
/* increase level */ /* increase level */
@ -2170,6 +2176,10 @@ void sokoban_loop(void) {
row++; row++;
break; break;
case SYS_USB_CONNECTED:
usb_screen();
return true;
default: default:
idle = true; idle = true;
break; break;
@ -2192,20 +2202,23 @@ void sokoban_loop(void) {
lcd_invertrect(0,0,111,63); lcd_invertrect(0,0,111,63);
lcd_update(); lcd_update();
if ( button_get(false) ) if ( button_get(false) )
return; return false;
} }
return; return false;
} }
load_level(current_level); load_level(current_level);
lcd_clear_display(); lcd_clear_display();
update_screen(); update_screen();
} }
} }
return false;
} }
Menu sokoban(void) bool sokoban(void)
{ {
bool result;
int w, h; int w, h;
int len = strlen(SOKOBAN_TITLE); int len = strlen(SOKOBAN_TITLE);
@ -2240,9 +2253,9 @@ Menu sokoban(void)
lcd_update(); lcd_update();
sleep(HZ*2); sleep(HZ*2);
lcd_clear_display(); lcd_clear_display();
sokoban_loop(); result = sokoban_loop();
return MENU_OK; return result;
} }
#endif #endif

View file

@ -22,10 +22,7 @@
#include "menu.h" #include "menu.h"
void load_level(int); bool sokoban(void);
void update_screen(void);
void sokoban_loop(void);
Menu sokoban(void);
#endif /*__SOKOBAN__ */ #endif /*__SOKOBAN__ */

View file

@ -30,6 +30,7 @@
#include "kernel.h" #include "kernel.h"
#include <string.h> #include <string.h>
#include "menu.h" #include "menu.h"
#include "screens.h"
#ifdef SIMULATOR #ifdef SIMULATOR
#include <stdio.h> #include <stdio.h>
@ -106,12 +107,12 @@ static const char block_data[7][4][2][4] =
} }
}; };
int t_rand(int range) static int t_rand(int range)
{ {
return current_tick % range; return current_tick % range;
} }
void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y) static void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y)
{ {
lcd_drawline(fstart_x, fstart_y, fstop_x, fstart_y); lcd_drawline(fstart_x, fstart_y, fstop_x, fstart_y);
lcd_drawline(fstart_x, fstop_y, fstop_x, fstop_y); lcd_drawline(fstart_x, fstop_y, fstop_x, fstop_y);
@ -123,7 +124,7 @@ void draw_frame(int fstart_x,int fstop_x,int fstart_y,int fstop_y)
lcd_drawline(fstart_x - 1, fstop_y + 1, fstop_x - 1, fstop_y + 1); lcd_drawline(fstart_x - 1, fstop_y + 1, fstop_x - 1, fstop_y + 1);
} }
void draw_block(int x, int y, int block, int frame, bool clear) static void draw_block(int x, int y, int block, int frame, bool clear)
{ {
int i, a, b; int i, a, b;
for(i=0;i < 4;i++) { for(i=0;i < 4;i++) {
@ -144,7 +145,7 @@ void draw_block(int x, int y, int block, int frame, bool clear)
} }
} }
void to_virtual(void) static void to_virtual(void)
{ {
int i,a,b; int i,a,b;
@ -156,7 +157,7 @@ void to_virtual(void)
current_x + block_data[current_b][current_f][1][i] * 4 - b) = current_b + 1; current_x + block_data[current_b][current_f][1][i] * 4 - b) = current_b + 1;
} }
bool block_touch (int x, int y) static bool block_touch (int x, int y)
{ {
int a,b; int a,b;
for (a = 0; a < 4; a++) for (a = 0; a < 4; a++)
@ -166,7 +167,7 @@ bool block_touch (int x, int y)
return false; return false;
} }
bool gameover(void) static bool gameover(void)
{ {
int i; int i;
int frame, block, y, x; int frame, block, y, x;
@ -191,7 +192,7 @@ bool gameover(void)
return false; return false;
} }
bool valid_position(int x, int y, int block, int frame) static bool valid_position(int x, int y, int block, int frame)
{ {
int i; int i;
for(i=0;i < 4;i++) for(i=0;i < 4;i++)
@ -204,7 +205,7 @@ bool valid_position(int x, int y, int block, int frame)
return true; return true;
} }
void from_virtual(void) static void from_virtual(void)
{ {
int x,y; int x,y;
for(y = 0; y < max_y; y++) for(y = 0; y < max_y; y++)
@ -215,7 +216,7 @@ void from_virtual(void)
lcd_clearpixel(start_x + x, start_y + y); lcd_clearpixel(start_x + x, start_y + y);
} }
void move_block(int x,int y,int f) static void move_block(int x,int y,int f)
{ {
int last_frame = current_f; int last_frame = current_f;
if(f != 0) if(f != 0)
@ -239,7 +240,7 @@ void move_block(int x,int y,int f)
current_f = last_frame; current_f = last_frame;
} }
void new_block(void) static void new_block(void)
{ {
current_b = next_b; current_b = next_b;
current_f = next_f; current_f = next_f;
@ -266,7 +267,7 @@ void new_block(void)
draw_block(current_x, current_y, current_b, current_f, false); draw_block(current_x, current_y, current_b, current_f, false);
} }
int check_lines(void) static int check_lines(void)
{ {
int x,y,i,j; int x,y,i,j;
bool line; bool line;
@ -298,7 +299,7 @@ int check_lines(void)
return lines / 4; return lines / 4;
} }
void move_down(void) static void move_down(void)
{ {
int l; int l;
char s[25]; char s[25];
@ -327,7 +328,7 @@ void move_down(void)
move_block(-4,0,0); move_block(-4,0,0);
} }
void game_loop(void) static bool game_loop(void)
{ {
while(1) while(1)
{ {
@ -336,28 +337,32 @@ void game_loop(void)
{ {
switch(button_get_w_tmo(HZ/10)) switch(button_get_w_tmo(HZ/10))
{ {
case BUTTON_OFF: case BUTTON_OFF:
return; return false;
case BUTTON_UP: case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT: case BUTTON_UP | BUTTON_REPEAT:
move_block(0,-3,0); move_block(0,-3,0);
break; break;
case BUTTON_DOWN: case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT: case BUTTON_DOWN | BUTTON_REPEAT:
move_block(0,3,0); move_block(0,3,0);
break; break;
case BUTTON_RIGHT: case BUTTON_RIGHT:
case BUTTON_RIGHT | BUTTON_REPEAT: case BUTTON_RIGHT | BUTTON_REPEAT:
move_block(0,0,1); move_block(0,0,1);
break; break;
case BUTTON_LEFT: case BUTTON_LEFT:
case BUTTON_LEFT | BUTTON_REPEAT: case BUTTON_LEFT | BUTTON_REPEAT:
move_down(); move_down();
break; break;
case SYS_USB_CONNECTED:
usb_screen();
return true;
} }
count++; count++;
@ -369,14 +374,16 @@ void game_loop(void)
lcd_putsxy (2, 52, str(LANG_TETRIS_LOSE), 0); lcd_putsxy (2, 52, str(LANG_TETRIS_LOSE), 0);
lcd_update(); lcd_update();
sleep(HZ * 3); sleep(HZ * 3);
return; return false;
} }
move_down(); move_down();
} }
return false;
} }
void init_tetris(void) static void init_tetris(void)
{ {
memset(&virtual, 0, sizeof(virtual)); memset(&virtual, 0, sizeof(virtual));
@ -391,7 +398,7 @@ void init_tetris(void)
next_f = 0; next_f = 0;
} }
Menu tetris(void) bool tetris(void)
{ {
init_tetris(); init_tetris();
@ -402,9 +409,7 @@ Menu tetris(void)
next_b = t_rand(blocks); next_b = t_rand(blocks);
next_f = t_rand(block_frames[next_b]); next_f = t_rand(block_frames[next_b]);
new_block(); new_block();
game_loop(); return game_loop();
return MENU_OK;
} }
#endif #endif

View file

@ -34,6 +34,7 @@
#include "menu.h" #include "menu.h"
#include "rtc.h" #include "rtc.h"
#include "lang.h" #include "lang.h"
#include "screens.h"
/* size of the field the worm lives in */ /* size of the field the worm lives in */
#define FIELD_RECT_X 1 #define FIELD_RECT_X 1
@ -1888,7 +1889,7 @@ extern bool use_old_rect;
/** /**
* Main entry point from the menu to start the game control. * Main entry point from the menu to start the game control.
*/ */
Menu wormlet(void) bool wormlet(void)
{ {
bool wormDead = false; bool wormDead = false;
int button; int button;
@ -1974,6 +1975,10 @@ Menu wormlet(void)
use_remote = true; use_remote = true;
} }
break; break;
case SYS_USB_CONNECTED:
usb_screen();
return true;
} }
} while (button != BUTTON_PLAY && } while (button != BUTTON_PLAY &&
button != BUTTON_OFF && button != BUTTON_ON); button != BUTTON_OFF && button != BUTTON_ON);
@ -2007,7 +2012,7 @@ Menu wormlet(void)
} }
while (button != BUTTON_OFF); while (button != BUTTON_OFF);
return MENU_OK; return false;
} }

View file

@ -22,7 +22,7 @@
#include "menu.h" #include "menu.h"
Menu wormlet(void); bool wormlet(void);
#endif /*__WORMLET__ */ #endif /*__WORMLET__ */

292
apps/screens.c Normal file
View file

@ -0,0 +1,292 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 Björn Stenberg
*
* 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 <stdbool.h>
#include <string.h>
#include <stdio.h>
#include "backlight.h"
#include "button.h"
#include "lcd.h"
#include "lang.h"
#include "icons.h"
#include "font.h"
#include "mpeg.h"
#include "usb.h"
#include "settings.h"
#include "playlist.h"
void usb_screen(void)
{
#ifndef SIMULATOR
backlight_on();
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_wait_for_disconnect(&button_queue);
backlight_on();
#endif
}
#ifdef HAVE_RECORDER_KEYPAD
/* returns:
0 if no key was pressed
1 if a key was pressed (or if ON was held down long enough to repeat)
2 if USB was connected */
int on_screen(void)
{
static int pitch = 100;
bool exit = false;
bool used = false;
while (!exit) {
if ( used ) {
char* ptr;
char buf[32];
int w, h;
lcd_scroll_pause();
lcd_clear_display();
ptr = str(LANG_PITCH_UP);
lcd_getstringsize(ptr,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr, FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_UpArrow],
LCD_WIDTH/2 - 3, h*2, 7, 8, true);
snprintf(buf, sizeof buf, "%d%%", pitch);
lcd_getstringsize(buf,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-w)/2, h, buf, FONT_UI);
ptr = str(LANG_PITCH_DOWN);
lcd_getstringsize(ptr,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr, FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
ptr = str(LANG_PAUSE);
lcd_getstringsize(ptr,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-(w/2))/2, LCD_HEIGHT/2 - h/2, ptr, FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_Pause],
(LCD_WIDTH-(w/2))/2-10, LCD_HEIGHT/2 - h/2, 7, 8, true);
lcd_update();
}
/* use lastbutton, so the main loop can decide whether to
exit to browser or not */
switch (button_get(true)) {
case BUTTON_UP:
case BUTTON_ON | BUTTON_UP:
case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT:
used = true;
pitch++;
if ( pitch > 200 )
pitch = 200;
#ifdef HAVE_MAS3587F
mpeg_set_pitch(pitch);
#endif
break;
case BUTTON_DOWN:
case BUTTON_ON | BUTTON_DOWN:
case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT:
used = true;
pitch--;
if ( pitch < 50 )
pitch = 50;
#ifdef HAVE_MAS3587F
mpeg_set_pitch(pitch);
#endif
break;
case BUTTON_ON | BUTTON_PLAY:
mpeg_pause();
used = true;
break;
case BUTTON_PLAY | BUTTON_REL:
mpeg_resume();
used = true;
break;
case BUTTON_ON | BUTTON_PLAY | BUTTON_REL:
mpeg_resume();
exit = true;
break;
#ifdef SIMULATOR
case BUTTON_ON:
#else
case BUTTON_ON | BUTTON_REL:
case BUTTON_ON | BUTTON_UP | BUTTON_REL:
case BUTTON_ON | BUTTON_DOWN | BUTTON_REL:
#endif
exit = true;
break;
case BUTTON_ON | BUTTON_REPEAT:
used = true;
break;
case SYS_USB_CONNECTED:
usb_screen();
return 2;
}
}
if ( used )
return 1;
else
return 0;
}
bool f2_screen(void)
{
bool exit = false;
bool used = false;
int w, h;
char buf[32];
/* Get the font height */
lcd_getstringsize("A",FONT_UI,&w,&h);
lcd_stop_scroll();
while (!exit) {
lcd_clear_display();
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE), FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE), FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2,
global_settings.playlist_shuffle ?
str(LANG_ON) : str(LANG_OFF), FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
snprintf(buf, sizeof buf, str(LANG_DIR_FILTER),
global_settings.mp3filter ? str(LANG_ON) : str(LANG_OFF));
/* Get the string width and height */
lcd_getstringsize(buf,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf, FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
lcd_update();
switch (button_get(true)) {
case BUTTON_LEFT:
case BUTTON_F2 | BUTTON_LEFT:
global_settings.playlist_shuffle =
!global_settings.playlist_shuffle;
if (global_settings.playlist_shuffle)
randomise_playlist(current_tick);
else
sort_playlist(true);
used = true;
break;
case BUTTON_DOWN:
case BUTTON_F2 | BUTTON_DOWN:
global_settings.mp3filter = !global_settings.mp3filter;
used = true;
break;
case BUTTON_F2 | BUTTON_REL:
if ( used )
exit = true;
used = true;
break;
case SYS_USB_CONNECTED:
usb_screen();
return true;
}
}
settings_save();
return false;
}
bool f3_screen(void)
{
bool exit = false;
bool used = false;
lcd_stop_scroll();
while (!exit) {
int w,h;
char* ptr;
ptr = str(LANG_F3_STATUS);
lcd_getstringsize(ptr,FONT_UI,&w,&h);
lcd_clear_display();
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_F3_SCROLL), FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2,
global_settings.scrollbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr, FONT_UI);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2,
global_settings.statusbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_FastForward],
LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true);
lcd_update();
switch (button_get(true)) {
case BUTTON_LEFT:
case BUTTON_F3 | BUTTON_LEFT:
global_settings.scrollbar = !global_settings.scrollbar;
used = true;
break;
case BUTTON_RIGHT:
case BUTTON_F3 | BUTTON_RIGHT:
global_settings.statusbar = !global_settings.statusbar;
used = true;
break;
case BUTTON_F3 | BUTTON_REL:
if ( used )
exit = true;
used = true;
break;
case SYS_USB_CONNECTED:
usb_screen();
return true;
}
}
settings_save();
if (global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
return false;
}
#endif

30
apps/screens.h Normal file
View file

@ -0,0 +1,30 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 Björn Stenberg
*
* 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 _SCREENS_H_
#define _SCREENS_H_
void usb_screen(void);
#ifdef HAVE_RECORDER_KEYPAD
int on_screen(void);
bool f2_screen(void);
bool f3_screen(void);
#endif
#endif

View file

@ -38,6 +38,7 @@
#include "powermgmt.h" #include "powermgmt.h"
#include "status.h" #include "status.h"
#include "atoi.h" #include "atoi.h"
#include "screens.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#include "icons.h" #include "icons.h"
#include "font.h" #include "font.h"
@ -476,84 +477,84 @@ bool settings_load_eq(char* file)
if (!strcasecmp(buf_set,"volume")) { if (!strcasecmp(buf_set,"volume")) {
global_settings.volume = (atoi(buf_val)/2); global_settings.volume = (atoi(buf_val)/2);
if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME) || if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME) ||
global_settings.volume < mpeg_sound_min(SOUND_VOLUME)) { global_settings.volume < mpeg_sound_min(SOUND_VOLUME)) {
global_settings.volume = mpeg_sound_default(SOUND_VOLUME); global_settings.volume = mpeg_sound_default(SOUND_VOLUME);
syntax_error = true; syntax_error = true;
} }
mpeg_sound_set(SOUND_VOLUME, global_settings.volume); mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
} else } else
if (!strcasecmp(buf_set,"bass")) { if (!strcasecmp(buf_set,"bass")) {
if (buf_val[0] == '-') if (buf_val[0] == '-')
global_settings.bass = ((mpeg_sound_max(SOUND_BASS)/2)-atoi(buf_val+1)); global_settings.bass = ((mpeg_sound_max(SOUND_BASS)/2)-atoi(buf_val+1));
else else
global_settings.bass = (atoi(buf_val)+(mpeg_sound_max(SOUND_BASS)/2)); global_settings.bass = (atoi(buf_val)+(mpeg_sound_max(SOUND_BASS)/2));
if (global_settings.bass > mpeg_sound_max(SOUND_BASS) || if (global_settings.bass > mpeg_sound_max(SOUND_BASS) ||
global_settings.bass < mpeg_sound_min(SOUND_BASS)) { global_settings.bass < mpeg_sound_min(SOUND_BASS)) {
global_settings.bass = mpeg_sound_default(SOUND_BASS); global_settings.bass = mpeg_sound_default(SOUND_BASS);
syntax_error = true; syntax_error = true;
} }
mpeg_sound_set(SOUND_BASS, global_settings.bass); mpeg_sound_set(SOUND_BASS, global_settings.bass);
} else } else
if (!strcasecmp(buf_set,"treble")) { if (!strcasecmp(buf_set,"treble")) {
if (buf_val[0] == '-') if (buf_val[0] == '-')
global_settings.treble = ((mpeg_sound_max(SOUND_TREBLE)/2)-atoi(buf_val+1)); global_settings.treble = ((mpeg_sound_max(SOUND_TREBLE)/2)-atoi(buf_val+1));
else else
global_settings.treble = (atoi(buf_val)+(mpeg_sound_max(SOUND_TREBLE)/2)); global_settings.treble = (atoi(buf_val)+(mpeg_sound_max(SOUND_TREBLE)/2));
if (global_settings.treble > mpeg_sound_max(SOUND_TREBLE) || if (global_settings.treble > mpeg_sound_max(SOUND_TREBLE) ||
global_settings.treble < mpeg_sound_min(SOUND_TREBLE)) { global_settings.treble < mpeg_sound_min(SOUND_TREBLE)) {
global_settings.treble = mpeg_sound_default(SOUND_TREBLE); global_settings.treble = mpeg_sound_default(SOUND_TREBLE);
syntax_error = true; syntax_error = true;
} }
mpeg_sound_set(SOUND_TREBLE, global_settings.treble); mpeg_sound_set(SOUND_TREBLE, global_settings.treble);
} else } else
if (!strcasecmp(buf_set,"balance")) { if (!strcasecmp(buf_set,"balance")) {
if (buf_val[0] == '-') if (buf_val[0] == '-')
global_settings.balance = -(atoi(buf_val+1)/2); global_settings.balance = -(atoi(buf_val+1)/2);
else else
global_settings.balance = ((atoi(buf_val)/2)); global_settings.balance = ((atoi(buf_val)/2));
if (global_settings.balance > mpeg_sound_max(SOUND_BALANCE) || if (global_settings.balance > mpeg_sound_max(SOUND_BALANCE) ||
global_settings.balance < mpeg_sound_min(SOUND_BALANCE)) { global_settings.balance < mpeg_sound_min(SOUND_BALANCE)) {
global_settings.balance = mpeg_sound_default(SOUND_BALANCE); global_settings.balance = mpeg_sound_default(SOUND_BALANCE);
syntax_error = true; syntax_error = true;
} }
mpeg_sound_set(SOUND_BALANCE, global_settings.balance); mpeg_sound_set(SOUND_BALANCE, global_settings.balance);
} else } else
if (!strcasecmp(buf_set,"channels")) { if (!strcasecmp(buf_set,"channels")) {
global_settings.channel_config = atoi(buf_val); global_settings.channel_config = atoi(buf_val);
if (global_settings.channel_config > mpeg_sound_max(SOUND_CHANNELS) || if (global_settings.channel_config > mpeg_sound_max(SOUND_CHANNELS) ||
global_settings.channel_config < mpeg_sound_min(SOUND_CHANNELS)) { global_settings.channel_config < mpeg_sound_min(SOUND_CHANNELS)) {
global_settings.channel_config = mpeg_sound_default(SOUND_CHANNELS); global_settings.channel_config = mpeg_sound_default(SOUND_CHANNELS);
syntax_error = true; syntax_error = true;
} }
mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config); mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config);
} else } else
if (!strcasecmp(buf_set,"loudness")) { if (!strcasecmp(buf_set,"loudness")) {
global_settings.loudness = atoi(buf_val); global_settings.loudness = atoi(buf_val);
if(global_settings.loudness > mpeg_sound_max(SOUND_LOUDNESS) || if(global_settings.loudness > mpeg_sound_max(SOUND_LOUDNESS) ||
global_settings.loudness < mpeg_sound_min(SOUND_LOUDNESS)) { global_settings.loudness < mpeg_sound_min(SOUND_LOUDNESS)) {
global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS); global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS);
syntax_error = true; syntax_error = true;
} }
mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness); mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness);
} else } else
if (!strcasecmp(buf_set,"bass boost")) { if (!strcasecmp(buf_set,"bass boost")) {
global_settings.bass_boost = (atoi(buf_val)/10); global_settings.bass_boost = (atoi(buf_val)/10);
if(global_settings.bass_boost > mpeg_sound_max(SOUND_SUPERBASS) || if(global_settings.bass_boost > mpeg_sound_max(SOUND_SUPERBASS) ||
global_settings.bass_boost < mpeg_sound_min(SOUND_SUPERBASS)) { global_settings.bass_boost < mpeg_sound_min(SOUND_SUPERBASS)) {
global_settings.bass_boost = mpeg_sound_default(SOUND_SUPERBASS); global_settings.bass_boost = mpeg_sound_default(SOUND_SUPERBASS);
syntax_error = true; syntax_error = true;
} }
mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost); mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost);
} else if (!strcasecmp(buf_set,"auto volume")) { } else if (!strcasecmp(buf_set,"auto volume")) {
global_settings.avc = atoi(buf_val); global_settings.avc = atoi(buf_val);
if (global_settings.avc > mpeg_sound_max(SOUND_AVC) || if (global_settings.avc > mpeg_sound_max(SOUND_AVC) ||
global_settings.avc < mpeg_sound_min(SOUND_AVC)) { global_settings.avc < mpeg_sound_min(SOUND_AVC)) {
global_settings.avc = mpeg_sound_default(SOUND_AVC); global_settings.avc = mpeg_sound_default(SOUND_AVC);
syntax_error = true; syntax_error = true;
} }
mpeg_sound_set(SOUND_AVC, global_settings.avc); mpeg_sound_set(SOUND_AVC, global_settings.avc);
} }
if (syntax_error) { if (syntax_error) {
lcd_clear_display(); lcd_clear_display();
lcd_puts(0,1,"SyntaxError"); lcd_puts(0,1,"SyntaxError");
@ -636,20 +637,24 @@ void settings_display(void)
#endif #endif
} }
void set_bool(char* string, bool* variable ) bool set_bool(char* string, bool* variable )
{ {
set_bool_options(string, variable, "yes", "no "); return set_bool_options(string, variable, "yes", "no ");
} }
void set_bool_options(char* string, bool* variable, char* yes_str, char* no_str ) bool set_bool_options(char* string, bool* variable,
char* yes_str, char* no_str )
{ {
char* names[] = { yes_str, no_str }; char* names[] = { yes_str, no_str };
int value = !*variable; int value = !*variable;
set_option(string, &value, names, 2, NULL); bool result;
result = set_option(string, &value, names, 2, NULL);
*variable = !value; *variable = !value;
return result;
} }
void set_int(char* string, bool set_int(char* string,
char* unit, char* unit,
int* variable, int* variable,
void (*function)(int), void (*function)(int),
@ -713,14 +718,20 @@ void set_int(char* string,
#endif #endif
done = true; done = true;
break; break;
case SYS_USB_CONNECTED:
usb_screen();
return true;
} }
if ( function && button != BUTTON_NONE) if ( function && button != BUTTON_NONE)
function(*variable); function(*variable);
} }
lcd_stop_scroll(); lcd_stop_scroll();
return false;
} }
void set_option(char* string, int* variable, char* options[], bool set_option(char* string, int* variable, char* options[],
int numoptions, void (*function)(int)) int numoptions, void (*function)(int))
{ {
bool done = false; bool done = false;
@ -778,12 +789,17 @@ void set_option(char* string, int* variable, char* options[],
#endif #endif
done = true; done = true;
break; break;
case SYS_USB_CONNECTED:
usb_screen();
return true;
} }
if ( function && button != BUTTON_NONE) if ( function && button != BUTTON_NONE)
function(*variable); function(*variable);
} }
lcd_stop_scroll(); lcd_stop_scroll();
return false;
} }
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
@ -797,7 +813,7 @@ char cursor[][3] = {{ 0, 8, 12}, {18, 8, 12}, {36, 8, 12},
{24, 16, 24}, {54, 16, 18}, {78, 16, 12}}; {24, 16, 24}, {54, 16, 18}, {78, 16, 12}};
char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void set_time(char* string, int timedate[]) bool set_time(char* string, int timedate[])
{ {
bool done = false; bool done = false;
int button; int button;
@ -999,9 +1015,13 @@ void set_time(char* string, int timedate[])
#endif #endif
break; break;
#endif #endif
default:
break; case SYS_USB_CONNECTED:
usb_screen();
return true;
} }
} }
return false;
} }
#endif #endif

View file

@ -112,19 +112,20 @@ void settings_reset(void);
void settings_display(void); void settings_display(void);
bool settings_load_eq(char* file); bool settings_load_eq(char* file);
void set_bool_options(char* string, bool* variable, char* yes_str, char* no_str ); bool set_bool_options(char* string, bool* variable,
char* yes_str, char* no_str );
void set_bool(char* string, bool* variable ); bool set_bool(char* string, bool* variable );
void set_option(char* string, int* variable, char* options[], bool set_option(char* string, int* variable, char* options[],
int numoptions, void (*function)(int)); int numoptions, void (*function)(int));
void set_int(char* string, bool set_int(char* string,
char* unit, char* unit,
int* variable, int* variable,
void (*function)(int), void (*function)(int),
int step, int step,
int min, int min,
int max ); int max );
void set_time(char* string, int timedate[]); bool set_time(char* string, int timedate[]);
/* global settings */ /* global settings */
extern struct user_settings global_settings; extern struct user_settings global_settings;

View file

@ -38,99 +38,94 @@
#include "ata.h" #include "ata.h"
#include "lang.h" #include "lang.h"
static Menu show_hidden_files(void) static bool show_hidden_files(void)
{ {
set_bool_options( str(LANG_HIDDEN), &global_settings.show_hidden_files, return set_bool_options( str(LANG_HIDDEN),
str(LANG_HIDDEN_SHOW), str(LANG_HIDDEN_HIDE) ); &global_settings.show_hidden_files,
return MENU_OK; str(LANG_HIDDEN_SHOW),
str(LANG_HIDDEN_HIDE) );
} }
static Menu contrast(void) static bool contrast(void)
{ {
set_int( str(LANG_CONTRAST), "", &global_settings.contrast, return set_int( str(LANG_CONTRAST), "", &global_settings.contrast,
lcd_set_contrast, 1, 0, MAX_CONTRAST_SETTING ); lcd_set_contrast, 1, 0, MAX_CONTRAST_SETTING );
return MENU_OK;
} }
#ifndef HAVE_RECORDER_KEYPAD #ifndef HAVE_RECORDER_KEYPAD
static Menu shuffle(void) static bool shuffle(void)
{ {
set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle ); return set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle );
return MENU_OK;
} }
#endif #endif
static Menu play_selected(void) static bool play_selected(void)
{ {
set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected ); return set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected );
return MENU_OK;
} }
static Menu mp3_filter(void) static bool mp3_filter(void)
{ {
set_bool( str(LANG_MP3FILTER), &global_settings.mp3filter ); return set_bool( str(LANG_MP3FILTER), &global_settings.mp3filter );
return MENU_OK;
} }
static Menu sort_case(void) static bool sort_case(void)
{ {
set_bool( str(LANG_SORT_CASE), &global_settings.sort_case ); return set_bool( str(LANG_SORT_CASE), &global_settings.sort_case );
return MENU_OK;
} }
static Menu resume(void) static bool resume(void)
{ {
char* names[] = { str(LANG_OFF), char* names[] = { str(LANG_OFF),
str(LANG_RESUME_SETTING_ASK), str(LANG_RESUME_SETTING_ASK),
str(LANG_ON) }; str(LANG_ON) };
set_option( str(LANG_RESUME), &global_settings.resume, names, 3, NULL ); return set_option( str(LANG_RESUME), &global_settings.resume,
return MENU_OK; names, 3, NULL );
} }
static Menu backlight_timer(void) static bool backlight_timer(void)
{ {
char* names[] = { str(LANG_OFF), str(LANG_ON), char* names[] = { str(LANG_OFF), str(LANG_ON),
"1s ", "2s ", "3s ", "4s ", "5s ", "1s ", "2s ", "3s ", "4s ", "5s ",
"6s ", "7s ", "8s ", "9s ", "10s", "6s ", "7s ", "8s ", "9s ", "10s",
"15s", "20s", "25s", "30s", "45s", "15s", "20s", "25s", "30s", "45s",
"60s", "90s"}; "60s", "90s"};
set_option(str(LANG_BACKLIGHT), &global_settings.backlight, names, 19, return set_option(str(LANG_BACKLIGHT), &global_settings.backlight,
backlight_time ); names, 19, backlight_time );
return MENU_OK;
} }
static Menu poweroff_idle_timer(void) static bool poweroff_idle_timer(void)
{ {
char* names[] = { str(LANG_OFF), char* names[] = { str(LANG_OFF),
"1m ", "2m ", "3m ", "4m ", "5m ", "1m ", "2m ", "3m ", "4m ", "5m ",
"6m ", "7m ", "8m ", "9m ", "10m", "6m ", "7m ", "8m ", "9m ", "10m",
"15m", "30m", "45m", "60m"}; "15m", "30m", "45m", "60m"};
set_option(str(LANG_POWEROFF_IDLE), &global_settings.poweroff, names, return set_option(str(LANG_POWEROFF_IDLE), &global_settings.poweroff,
15, set_poweroff_timeout); names, 15, set_poweroff_timeout);
return MENU_OK;
} }
static Menu scroll_speed(void) static bool scroll_speed(void)
{ {
set_int(str(LANG_SCROLL), "", &global_settings.scroll_speed, return set_int(str(LANG_SCROLL), "", &global_settings.scroll_speed,
&lcd_scroll_speed, 1, 1, 30 ); &lcd_scroll_speed, 1, 1, 30 );
return MENU_OK;
} }
#ifdef HAVE_CHARGE_CTRL #ifdef HAVE_CHARGE_CTRL
static Menu deep_discharge(void) static bool deep_discharge(void)
{ {
set_bool( str(LANG_DISCHARGE), &global_settings.discharge ); bool result;
result = set_bool( str(LANG_DISCHARGE), &global_settings.discharge );
charge_restart_level = global_settings.discharge ? charge_restart_level = global_settings.discharge ?
CHARGE_RESTART_LO : CHARGE_RESTART_HI; CHARGE_RESTART_LO : CHARGE_RESTART_HI;
return MENU_OK; return result;
} }
#endif #endif
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
static Menu timedate_set(void) static bool timedate_set(void)
{ {
int timedate[7]; /* hour,minute,second,year,month,day,dayofweek */ int timedate[7]; /* hour,minute,second,year,month,day,dayofweek */
bool result;
#ifdef HAVE_RTC #ifdef HAVE_RTC
timedate[0] = rtc_read(0x03); /* hour */ timedate[0] = rtc_read(0x03); /* hour */
@ -167,7 +162,7 @@ static Menu timedate_set(void)
timedate[5] = 1; timedate[5] = 1;
#endif #endif
set_time(str(LANG_TIME),timedate); result = set_time(str(LANG_TIME),timedate);
#ifdef HAVE_RTC #ifdef HAVE_RTC
if(timedate[0] != -1) { if(timedate[0] != -1) {
@ -194,49 +189,45 @@ static Menu timedate_set(void)
rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */ rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
} }
#endif #endif
return MENU_OK; return result;
} }
#endif #endif
static Menu spindown(void) static bool spindown(void)
{ {
set_int(str(LANG_SPINDOWN), "s", &global_settings.disk_spindown, return set_int(str(LANG_SPINDOWN), "s", &global_settings.disk_spindown,
ata_spindown, 1, 3, 254 ); ata_spindown, 1, 3, 254 );
return MENU_OK;
} }
static Menu ff_rewind_min_step(void) static bool ff_rewind_min_step(void)
{ {
char* names[] = { "1s", "2s", "3s", "4s", char* names[] = { "1s", "2s", "3s", "4s",
"5s", "6s", "8s", "10s", "5s", "6s", "8s", "10s",
"15s", "20s", "25s", "30s", "15s", "20s", "25s", "30s",
"45s", "60s" }; "45s", "60s" };
set_option(str(LANG_FFRW_STEP), &global_settings.ff_rewind_min_step, return set_option(str(LANG_FFRW_STEP), &global_settings.ff_rewind_min_step,
names, 14, NULL ); names, 14, NULL );
return MENU_OK;
} }
static Menu ff_rewind_accel(void) static bool ff_rewind_accel(void)
{ {
char* names[] = { str(LANG_OFF), "2x/1s", "2x/2s", "2x/3s", char* names[] = { str(LANG_OFF), "2x/1s", "2x/2s", "2x/3s",
"2x/4s", "2x/5s", "2x/6s", "2x/7s", "2x/4s", "2x/5s", "2x/6s", "2x/7s",
"2x/8s", "2x/9s", "2x/10s", "2x/11s", "2x/8s", "2x/9s", "2x/10s", "2x/11s",
"2x/12s", "2x/13s", "2x/14s", "2x/15s", }; "2x/12s", "2x/13s", "2x/14s", "2x/15s", };
set_option(str(LANG_FFRW_ACCEL), &global_settings.ff_rewind_accel, return set_option(str(LANG_FFRW_ACCEL), &global_settings.ff_rewind_accel,
names, 16, NULL ); names, 16, NULL );
return MENU_OK;
} }
static Menu browse_current(void) static bool browse_current(void)
{ {
set_bool( str(LANG_FOLLOW), &global_settings.browse_current ); return set_bool( str(LANG_FOLLOW), &global_settings.browse_current );
return MENU_OK;
} }
Menu playback_settings_menu(void) static bool playback_settings_menu(void)
{ {
int m; int m;
Menu result; bool result;
struct menu_items items[] = { struct menu_items items[] = {
#ifndef HAVE_RECORDER_KEYPAD #ifndef HAVE_RECORDER_KEYPAD
@ -268,7 +259,7 @@ Menu playback_settings_menu(void)
return result; return result;
} }
static Menu reset_settings(void) static bool reset_settings(void)
{ {
int button = 0; int button = 0;
@ -300,10 +291,10 @@ static Menu reset_settings(void)
} }
} }
static Menu fileview_settings_menu(void) static bool fileview_settings_menu(void)
{ {
int m; int m;
Menu result; bool result;
struct menu_items items[] = { struct menu_items items[] = {
{ str(LANG_CASE_MENU), sort_case }, { str(LANG_CASE_MENU), sort_case },
@ -312,16 +303,16 @@ static Menu fileview_settings_menu(void)
{ str(LANG_FOLLOW), browse_current }, { str(LANG_FOLLOW), browse_current },
}; };
m=menu_init( items, sizeof items / sizeof(struct menu_items) ); m = menu_init( items, sizeof items / sizeof(struct menu_items) );
result = menu_run(m); result = menu_run(m);
menu_exit(m); menu_exit(m);
return result; return result;
} }
static Menu display_settings_menu(void) static bool display_settings_menu(void)
{ {
int m; int m;
Menu result; bool result;
struct menu_items items[] = { struct menu_items items[] = {
{ str(LANG_SCROLL_MENU), scroll_speed }, { str(LANG_SCROLL_MENU), scroll_speed },
@ -335,10 +326,10 @@ static Menu display_settings_menu(void)
return result; return result;
} }
static Menu system_settings_menu(void) static bool system_settings_menu(void)
{ {
int m; int m;
Menu result; bool result;
struct menu_items items[] = { struct menu_items items[] = {
{ str(LANG_SPINDOWN), spindown }, { str(LANG_SPINDOWN), spindown },
@ -358,10 +349,10 @@ static Menu system_settings_menu(void)
return result; return result;
} }
Menu settings_menu(void) bool settings_menu(void)
{ {
int m; int m;
Menu result; bool result;
struct menu_items items[] = { struct menu_items items[] = {
{ str(LANG_PLAYBACK), playback_settings_menu }, { str(LANG_PLAYBACK), playback_settings_menu },
@ -370,7 +361,7 @@ Menu settings_menu(void)
{ str(LANG_SYSTEM), system_settings_menu }, { str(LANG_SYSTEM), system_settings_menu },
}; };
m=menu_init( items, sizeof items / sizeof(struct menu_items) ); m = menu_init( items, sizeof items / sizeof(struct menu_items) );
result = menu_run(m); result = menu_run(m);
menu_exit(m); menu_exit(m);
return result; return result;

View file

@ -21,6 +21,6 @@
#include "menu.h" #include "menu.h"
Menu settings_menu(void); bool settings_menu(void);
#endif #endif

View file

@ -26,6 +26,7 @@
#include "mpeg.h" #include "mpeg.h"
#include "settings.h" #include "settings.h"
#include "status.h" #include "status.h"
#include "screens.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#include "icons.h" #include "icons.h"
#endif #endif
@ -38,7 +39,7 @@ static char *fmt[] =
"%d.%02d %s " /* 2 decimals */ "%d.%02d %s " /* 2 decimals */
}; };
void set_sound(char* string, bool set_sound(char* string,
int* variable, int* variable,
int setting) int setting)
{ {
@ -120,20 +121,10 @@ void set_sound(char* string,
#endif #endif
done = true; done = true;
break; break;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_F3: case SYS_USB_CONNECTED:
#ifdef HAVE_LCD_BITMAP usb_screen();
global_settings.statusbar = !global_settings.statusbar; return true;
settings_save();
if(global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
lcd_clear_display();
lcd_puts_scroll(0, 0, string);
#endif
break;
#endif
} }
if (changed) { if (changed) {
mpeg_sound_set(setting, *variable); mpeg_sound_set(setting, *variable);
@ -144,43 +135,41 @@ void set_sound(char* string,
} }
} }
lcd_stop_scroll(); lcd_stop_scroll();
return false;
} }
static Menu volume(void) static bool volume(void)
{ {
set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME); return set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME);
return MENU_OK;
} }
static Menu balance(void) static bool balance(void)
{ {
set_sound(str(LANG_BALANCE), &global_settings.balance, SOUND_BALANCE); return set_sound(str(LANG_BALANCE), &global_settings.balance,
return MENU_OK; SOUND_BALANCE);
} }
static Menu bass(void) static bool bass(void)
{ {
set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS); return set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS);
return MENU_OK;
}; };
static Menu treble(void) static bool treble(void)
{ {
set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE); return set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE);
return MENU_OK;
} }
#ifdef HAVE_MAS3587F #ifdef HAVE_MAS3587F
static Menu loudness(void) static bool loudness(void)
{ {
set_sound(str(LANG_LOUDNESS), &global_settings.loudness, SOUND_LOUDNESS); return set_sound(str(LANG_LOUDNESS), &global_settings.loudness,
return MENU_OK; SOUND_LOUDNESS);
}; };
static Menu bass_boost(void) static bool bass_boost(void)
{ {
set_sound(str(LANG_BBOOST), &global_settings.bass_boost, SOUND_SUPERBASS); return set_sound(str(LANG_BBOOST), &global_settings.bass_boost,
return MENU_OK; SOUND_SUPERBASS);
}; };
static void set_avc(int val) static void set_avc(int val)
@ -188,11 +177,11 @@ static void set_avc(int val)
mpeg_sound_set(SOUND_AVC, val); mpeg_sound_set(SOUND_AVC, val);
} }
static Menu avc(void) static bool avc(void)
{ {
char* names[] = { str(LANG_OFF), "2s", "4s", "8s" }; char* names[] = { str(LANG_OFF), "2s", "4s", "8s" };
set_option(str(LANG_DECAY), &global_settings.avc, names, 4, set_avc ); return set_option(str(LANG_DECAY), &global_settings.avc,
return MENU_OK; names, 4, set_avc);
} }
#endif /* ARCHOS_RECORDER */ #endif /* ARCHOS_RECORDER */
@ -201,19 +190,18 @@ static void set_chanconf(int val)
mpeg_sound_set(SOUND_CHANNELS, val); mpeg_sound_set(SOUND_CHANNELS, val);
} }
static Menu chanconf(void) static bool chanconf(void)
{ {
char *names[] = {str(LANG_CHANNEL_STEREO), str(LANG_CHANNEL_MONO), char *names[] = {str(LANG_CHANNEL_STEREO), str(LANG_CHANNEL_MONO),
str(LANG_CHANNEL_LEFT),str(LANG_CHANNEL_RIGHT) }; str(LANG_CHANNEL_LEFT), str(LANG_CHANNEL_RIGHT) };
set_option(str(LANG_CHANNEL), return set_option(str(LANG_CHANNEL), &global_settings.channel_config,
&global_settings.channel_config, names, 4, set_chanconf ); names, 4, set_chanconf );
return MENU_OK;
} }
Menu sound_menu(void) bool sound_menu(void)
{ {
int m; int m;
Menu result; bool result;
struct menu_items items[] = { struct menu_items items[] = {
{ str(LANG_VOLUME), volume }, { str(LANG_VOLUME), volume },
{ str(LANG_BASS), bass }, { str(LANG_BASS), bass },

View file

@ -21,6 +21,6 @@
#include "menu.h" #include "menu.h"
Menu sound_menu(void); bool sound_menu(void);
#endif #endif

View file

@ -47,6 +47,7 @@
#include "icons.h" #include "icons.h"
#include "lang.h" #include "lang.h"
#include "language.h" #include "language.h"
#include "screens.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#include "widgets.h" #include "widgets.h"
@ -880,7 +881,8 @@ bool dirbrowse(char *root)
case TREE_MENU: case TREE_MENU:
lcd_stop_scroll(); lcd_stop_scroll();
main_menu(); if (main_menu())
reload_root = true;
restore = true; restore = true;
break; break;
@ -915,24 +917,10 @@ bool dirbrowse(char *root)
break; break;
#endif #endif
#ifndef SIMULATOR case SYS_USB_CONNECTED:
case SYS_USB_CONNECTED: { usb_screen();
backlight_time(4);
/* Tell the USB thread that we are safe */
DEBUGF("dirbrowse got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
/* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&button_queue);
backlight_time(global_settings.backlight);
/* Force a re-read of the root directory */
reload_root = true; reload_root = true;
} break;
break;
#endif
} }
if ( button ) if ( button )

View file

@ -37,6 +37,7 @@
#include "status.h" #include "status.h"
#include "main_menu.h" #include "main_menu.h"
#include "ata.h" #include "ata.h"
#include "screens.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#include "icons.h" #include "icons.h"
#endif #endif
@ -151,22 +152,6 @@ void display_mute_text(bool muted)
sleep(HZ); sleep(HZ);
} }
static void handle_usb(void)
{
#ifndef SIMULATOR
backlight_time(4);
/* Tell the USB thread that we are safe */
DEBUGF("wps got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
/* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&button_queue);
backlight_time(global_settings.backlight);
#endif
}
static int browse_id3(void) static int browse_id3(void)
{ {
int button; int button;
@ -298,12 +283,10 @@ static int browse_id3(void)
exit = true; exit = true;
break; break;
#ifndef SIMULATOR
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
handle_usb(); usb_screen();
return SYS_USB_CONNECTED; return SYS_USB_CONNECTED;
break; break;
#endif
} }
} }
return 0; return 0;
@ -413,7 +396,7 @@ static bool ffwd_rew(int button)
break; break;
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
handle_usb(); usb_screen();
usb = true; usb = true;
exit = true; exit = true;
break; break;
@ -488,7 +471,7 @@ static bool keylock(void)
break; break;
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
handle_usb(); usb_screen();
return true; return true;
case BUTTON_NONE: case BUTTON_NONE:
@ -541,7 +524,8 @@ static bool menu(void)
if ( !last_button ) { if ( !last_button ) {
lcd_stop_scroll(); lcd_stop_scroll();
button_set_release(old_release_mask); button_set_release(old_release_mask);
main_menu(); if (main_menu())
return true;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
if(global_settings.statusbar) if(global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT); lcd_setmargins(0, STATUSBAR_HEIGHT);
@ -608,7 +592,7 @@ static bool menu(void)
break; break;
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
handle_usb(); usb_screen();
return true; return true;
} }
last_button = button; last_button = button;
@ -623,260 +607,6 @@ static bool menu(void)
return false; return false;
} }
#ifdef HAVE_LCD_BITMAP
/* returns:
0 if no key was pressed
1 if a key was pressed (or if ON was held down long enough to repeat)
2 if USB was connected */
int on_screen(void)
{
static int pitch = 100;
bool exit = false;
bool used = false;
while (!exit) {
if ( used ) {
char* ptr;
char buf[32];
int w, h;
lcd_scroll_pause();
lcd_clear_display();
ptr = str(LANG_PITCH_UP);
lcd_getstringsize(ptr,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr, FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_UpArrow],
LCD_WIDTH/2 - 3, h*2, 7, 8, true);
snprintf(buf, sizeof buf, "%d%%", pitch);
lcd_getstringsize(buf,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-w)/2, h, buf, FONT_UI);
ptr = str(LANG_PITCH_DOWN);
lcd_getstringsize(ptr,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr, FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
ptr = str(LANG_PAUSE);
lcd_getstringsize(ptr,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-(w/2))/2, LCD_HEIGHT/2 - h/2, ptr, FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_Pause],
(LCD_WIDTH-(w/2))/2-10, LCD_HEIGHT/2 - h/2, 7, 8, true);
lcd_update();
}
/* use lastbutton, so the main loop can decide whether to
exit to browser or not */
switch (button_get(true)) {
case BUTTON_UP:
case BUTTON_ON | BUTTON_UP:
case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT:
used = true;
pitch++;
if ( pitch > 200 )
pitch = 200;
#ifdef HAVE_MAS3587F
mpeg_set_pitch(pitch);
#endif
break;
case BUTTON_DOWN:
case BUTTON_ON | BUTTON_DOWN:
case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT:
used = true;
pitch--;
if ( pitch < 50 )
pitch = 50;
#ifdef HAVE_MAS3587F
mpeg_set_pitch(pitch);
#endif
break;
case BUTTON_ON | BUTTON_PLAY:
mpeg_pause();
used = true;
break;
case BUTTON_PLAY | BUTTON_REL:
mpeg_resume();
used = true;
break;
case BUTTON_ON | BUTTON_PLAY | BUTTON_REL:
mpeg_resume();
exit = true;
break;
#ifdef SIMULATOR
case BUTTON_ON:
#else
case BUTTON_ON | BUTTON_REL:
case BUTTON_ON | BUTTON_UP | BUTTON_REL:
case BUTTON_ON | BUTTON_DOWN | BUTTON_REL:
#endif
exit = true;
break;
case BUTTON_ON | BUTTON_REPEAT:
used = true;
break;
#ifndef SIMULATOR
case SYS_USB_CONNECTED:
handle_usb();
return 2;
#endif
}
}
if ( used )
return 1;
else
return 0;
}
bool f2_screen(void)
{
bool exit = false;
bool used = false;
int w, h;
char buf[32];
/* Get the font height */
lcd_getstringsize("A",FONT_UI,&w,&h);
lcd_stop_scroll();
while (!exit) {
lcd_clear_display();
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE), FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE), FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2,
global_settings.playlist_shuffle ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
snprintf(buf, sizeof buf, str(LANG_DIR_FILTER),
global_settings.mp3filter ? str(LANG_ON) : str(LANG_OFF));
/* Get the string width and height */
lcd_getstringsize(buf,FONT_UI,&w,&h);
lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf, FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
lcd_update();
switch (button_get(true)) {
case BUTTON_LEFT:
case BUTTON_F2 | BUTTON_LEFT:
global_settings.playlist_shuffle =
!global_settings.playlist_shuffle;
if (global_settings.playlist_shuffle)
randomise_playlist(current_tick);
else
sort_playlist(true);
used = true;
break;
case BUTTON_DOWN:
case BUTTON_F2 | BUTTON_DOWN:
global_settings.mp3filter = !global_settings.mp3filter;
used = true;
break;
case BUTTON_F2 | BUTTON_REL:
if ( used )
exit = true;
used = true;
break;
#ifndef SIMULATOR
case SYS_USB_CONNECTED:
handle_usb();
return true;
#endif
}
}
settings_save();
return false;
}
bool f3_screen(void)
{
bool exit = false;
bool used = false;
lcd_stop_scroll();
while (!exit) {
int w,h;
char* ptr;
ptr = str(LANG_F3_STATUS);
lcd_getstringsize(ptr,FONT_UI,&w,&h);
lcd_clear_display();
lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_F3_SCROLL), FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
lcd_putsxy(0, LCD_HEIGHT/2,
global_settings.scrollbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr, FONT_UI);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2,
global_settings.statusbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
lcd_bitmap(bitmap_icons_7x8[Icon_FastForward],
LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true);
lcd_update();
switch (button_get(true)) {
case BUTTON_LEFT:
case BUTTON_F3 | BUTTON_LEFT:
global_settings.scrollbar = !global_settings.scrollbar;
used = true;
break;
case BUTTON_RIGHT:
case BUTTON_F3 | BUTTON_RIGHT:
global_settings.statusbar = !global_settings.statusbar;
used = true;
break;
case BUTTON_F3 | BUTTON_REL:
if ( used )
exit = true;
used = true;
break;
#ifndef SIMULATOR
case SYS_USB_CONNECTED:
handle_usb();
return true;
#endif
}
}
settings_save();
if (global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
return false;
}
#endif
/* demonstrates showing different formats from playtune */ /* demonstrates showing different formats from playtune */
int wps_show(void) int wps_show(void)
{ {
@ -1088,11 +818,9 @@ int wps_show(void)
button_set_release(old_release_mask); button_set_release(old_release_mask);
return 0; return 0;
#ifndef SIMULATOR
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
handle_usb(); usb_screen();
return SYS_USB_CONNECTED; return SYS_USB_CONNECTED;
#endif
case BUTTON_NONE: /* Timeout */ case BUTTON_NONE: /* Timeout */
update(); update();

View file

@ -29,6 +29,7 @@ int wps_show(void);
bool load_custom_wps(void); bool load_custom_wps(void);
bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string); bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string);
bool refresh_wps(bool refresh_scroll); bool refresh_wps(bool refresh_scroll);
void handle_usb(void);
#ifdef HAVE_RECORDER_KEYPAD #ifdef HAVE_RECORDER_KEYPAD
bool f2_screen(void); bool f2_screen(void);

View file

@ -66,7 +66,8 @@ FIRMSRCS = lcd-recorder.c power.c sprintf.c id3.c usb.c \
mpeg.c powermgmt.c font.c sysfont.c mpeg.c powermgmt.c font.c sysfont.c
APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \ APPS = main.c tree.c menu.c credits.c main_menu.c icons.c language.c \
playlist.c showtext.c wps.c wps-display.c settings.c status.c playlist.c showtext.c wps.c wps-display.c settings.c status.c \
screens.c
MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c
@ -197,6 +198,9 @@ $(OBJDIR)/sysfont.o: $(FIRMWAREDIR)/fonts/clR6x8.bdf
$(OBJDIR)/status.o: $(APPDIR)/status.c $(OBJDIR)/status.o: $(APPDIR)/status.c
$(CC) $(APPCFLAGS) -c $< -o $@ $(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/screens.o: $(APPDIR)/screens.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/version.o: $(FIRMWAREDIR)/version.c $(OBJDIR)/version.o: $(FIRMWAREDIR)/version.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@

View file

@ -81,7 +81,8 @@ FIRMSRCS = lcd-recorder.c sprintf.c id3.c debug.c usb.c mpeg.c power.c\
powermgmt.c font.c panic.c sysfont.c powermgmt.c font.c panic.c sysfont.c
APPS = main.c tree.c menu.c credits.c main_menu.c language.c\ APPS = main.c tree.c menu.c credits.c main_menu.c language.c\
playlist.c showtext.c wps.c wps-display.c settings.c status.c icons.c playlist.c showtext.c wps.c wps-display.c settings.c status.c icons.c\
screens.c
MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c MENUS = games_menu.c demo_menu.c settings_menu.c sound_menu.c
@ -237,6 +238,9 @@ $(OBJDIR)/settings.o: $(APPDIR)/settings.c
$(OBJDIR)/status.o: $(APPDIR)/status.c $(OBJDIR)/status.o: $(APPDIR)/status.c
$(CC) $(APPCFLAGS) -c $< -o $@ $(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/screens.o: $(APPDIR)/screens.c
$(CC) $(APPCFLAGS) -c $< -o $@
$(OBJDIR)/id3.o: $(FIRMWAREDIR)/id3.c $(OBJDIR)/id3.o: $(FIRMWAREDIR)/id3.c
$(CC) $(APPCFLAGS) -c $< -o $@ $(CC) $(APPCFLAGS) -c $< -o $@