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:
parent
c909b4b42e
commit
b1b8bd4dd1
29 changed files with 695 additions and 645 deletions
|
@ -46,7 +46,7 @@ extern char *thread_name[];
|
|||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
/* Test code!!! */
|
||||
Menu dbg_os(void)
|
||||
bool dbg_os(void)
|
||||
{
|
||||
char buf[32];
|
||||
int button;
|
||||
|
@ -77,13 +77,13 @@ Menu dbg_os(void)
|
|||
{
|
||||
case BUTTON_OFF:
|
||||
case BUTTON_LEFT:
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
Menu dbg_os(void)
|
||||
bool dbg_os(void)
|
||||
{
|
||||
char buf[32];
|
||||
int button;
|
||||
|
@ -110,7 +110,7 @@ Menu dbg_os(void)
|
|||
switch(button)
|
||||
{
|
||||
case BUTTON_STOP:
|
||||
return MENU_OK;
|
||||
return false;
|
||||
|
||||
case BUTTON_LEFT:
|
||||
currval--;
|
||||
|
@ -125,13 +125,13 @@ Menu dbg_os(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
/* Test code!!! */
|
||||
Menu dbg_ports(void)
|
||||
bool dbg_ports(void)
|
||||
{
|
||||
unsigned short porta;
|
||||
unsigned short portb;
|
||||
|
@ -186,13 +186,13 @@ Menu dbg_ports(void)
|
|||
switch(button)
|
||||
{
|
||||
case BUTTON_OFF:
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
Menu dbg_ports(void)
|
||||
bool dbg_ports(void)
|
||||
{
|
||||
unsigned short porta;
|
||||
unsigned short portb;
|
||||
|
@ -268,7 +268,7 @@ Menu dbg_ports(void)
|
|||
switch(button)
|
||||
{
|
||||
case BUTTON_STOP:
|
||||
return MENU_OK;
|
||||
return false;
|
||||
|
||||
case BUTTON_LEFT:
|
||||
currval--;
|
||||
|
@ -283,13 +283,13 @@ Menu dbg_ports(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RTC
|
||||
/* Read RTC RAM contents and display them */
|
||||
Menu dbg_rtc(void)
|
||||
bool dbg_rtc(void)
|
||||
{
|
||||
char buf[32];
|
||||
unsigned char addr = 0, r, c;
|
||||
|
@ -333,15 +333,15 @@ Menu dbg_rtc(void)
|
|||
break;
|
||||
case BUTTON_OFF:
|
||||
case BUTTON_LEFT:
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
Menu dbg_rtc(void)
|
||||
bool dbg_rtc(void)
|
||||
{
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -351,7 +351,7 @@ Menu dbg_rtc(void)
|
|||
#define NUMROWS 4
|
||||
#endif
|
||||
/* Read MAS registers and display them */
|
||||
Menu dbg_mas(void)
|
||||
bool dbg_mas(void)
|
||||
{
|
||||
char buf[32];
|
||||
unsigned int addr = 0, r, i;
|
||||
|
@ -395,14 +395,14 @@ Menu dbg_mas(void)
|
|||
#else
|
||||
case BUTTON_DOWN:
|
||||
#endif
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MAS3587F
|
||||
Menu dbg_mas_codec(void)
|
||||
bool dbg_mas_codec(void)
|
||||
{
|
||||
char buf[32];
|
||||
unsigned int addr = 0, r, i;
|
||||
|
@ -433,10 +433,10 @@ Menu dbg_mas_codec(void)
|
|||
if (addr) { addr -= 4; }
|
||||
break;
|
||||
case BUTTON_LEFT:
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -450,7 +450,7 @@ Menu dbg_mas_codec(void)
|
|||
#define BAT_FIRST_VAL MAX(POWER_HISTORY_LEN - LCD_WIDTH - 1, 0)
|
||||
#define BAT_YSPACE (LCD_HEIGHT - 20)
|
||||
|
||||
Menu view_battery(void)
|
||||
bool view_battery(void)
|
||||
{
|
||||
int view = 0;
|
||||
int i, x, y;
|
||||
|
@ -571,16 +571,16 @@ Menu view_battery(void)
|
|||
|
||||
case BUTTON_LEFT:
|
||||
case BUTTON_OFF:
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MAS3507D
|
||||
Menu dbg_mas_info(void)
|
||||
bool dbg_mas_info(void)
|
||||
{
|
||||
int button;
|
||||
char buf[32];
|
||||
|
@ -714,7 +714,7 @@ Menu dbg_mas_info(void)
|
|||
switch(button)
|
||||
{
|
||||
case BUTTON_STOP:
|
||||
return MENU_OK;
|
||||
return false;
|
||||
|
||||
case BUTTON_LEFT:
|
||||
currval--;
|
||||
|
@ -750,14 +750,14 @@ Menu dbg_mas_info(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
Menu debug_menu(void)
|
||||
bool debug_menu(void)
|
||||
{
|
||||
int m;
|
||||
Menu result;
|
||||
bool result;
|
||||
|
||||
struct menu_items items[] = {
|
||||
{ "View I/O ports", dbg_ports },
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#ifndef _DEBUG_MENU_H
|
||||
#define _DEBUG_MENU_H
|
||||
|
||||
Menu debug_menu(void);
|
||||
bool debug_menu(void);
|
||||
|
||||
#ifndef SIMULATOR
|
||||
extern Menu dbg_ports(void);
|
||||
extern bool dbg_ports(void);
|
||||
#ifdef HAVE_RTC
|
||||
extern Menu dbg_rtc(void);
|
||||
extern bool dbg_rtc(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -33,14 +33,14 @@
|
|||
|
||||
#include "lang.h"
|
||||
|
||||
extern Menu bounce(void);
|
||||
extern Menu snow(void);
|
||||
extern Menu oscillograph(void);
|
||||
extern bool bounce(void);
|
||||
extern bool snow(void);
|
||||
extern bool oscillograph(void);
|
||||
|
||||
Menu demo_menu(void)
|
||||
bool demo_menu(void)
|
||||
{
|
||||
int m;
|
||||
Menu result;
|
||||
bool result;
|
||||
|
||||
struct menu_items items[] = {
|
||||
{ str(LANG_BOUNCE), bounce },
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef _DEMOS_MENU_H
|
||||
#define _DEMOS_MENU_H
|
||||
|
||||
Menu demo_menu(void);
|
||||
bool demo_menu(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -36,13 +36,13 @@
|
|||
#include "wormlet.h"
|
||||
#include "lang.h"
|
||||
|
||||
extern Menu tetris(void);
|
||||
extern Menu snake(void);
|
||||
extern bool tetris(void);
|
||||
extern bool snake(void);
|
||||
|
||||
Menu games_menu(void)
|
||||
bool games_menu(void)
|
||||
{
|
||||
int m;
|
||||
Menu result;
|
||||
bool result;
|
||||
|
||||
struct menu_items items[] = {
|
||||
{ str(LANG_TETRIS), tetris },
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
|
||||
#include "menu.h"
|
||||
|
||||
Menu games_menu(void);
|
||||
bool games_menu(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -117,7 +117,7 @@ int show_logo( void )
|
|||
return 0;
|
||||
}
|
||||
|
||||
Menu show_credits(void)
|
||||
bool show_credits(void)
|
||||
{
|
||||
int j = 0;
|
||||
int btn;
|
||||
|
@ -132,23 +132,23 @@ Menu show_credits(void)
|
|||
|
||||
btn = button_get(false);
|
||||
if (btn != BUTTON_NONE && !(btn & BUTTON_REL))
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
roll_credits();
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef SIMULATOR
|
||||
#define mp3buf 0
|
||||
#define mp3end 0
|
||||
|
||||
extern Menu simulate_usb(void);
|
||||
extern bool simulate_usb(void);
|
||||
#else
|
||||
/* defined in linker script */
|
||||
extern unsigned char mp3buf[];
|
||||
extern unsigned char mp3end[];
|
||||
#endif
|
||||
Menu show_info(void)
|
||||
bool show_info(void)
|
||||
{
|
||||
char s[32];
|
||||
int buflen = ((mp3end - mp3buf) * 100) / 0x100000;
|
||||
|
@ -199,13 +199,13 @@ Menu show_info(void)
|
|||
done = true;
|
||||
}
|
||||
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
|
||||
Menu main_menu(void)
|
||||
bool main_menu(void)
|
||||
{
|
||||
int m;
|
||||
Menu result;
|
||||
bool result;
|
||||
|
||||
/* main menu */
|
||||
struct menu_items items[] = {
|
||||
|
|
|
@ -22,6 +22,6 @@
|
|||
#include "menu.h"
|
||||
|
||||
extern int show_logo(void);
|
||||
extern Menu main_menu(void);
|
||||
extern bool main_menu(void);
|
||||
|
||||
#endif
|
||||
|
|
46
apps/menu.c
46
apps/menu.c
|
@ -33,7 +33,7 @@
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "icons.h"
|
||||
#include "widgets.h"
|
||||
#include "wps.h"
|
||||
#include "screens.h"
|
||||
#endif
|
||||
|
||||
struct menu {
|
||||
|
@ -242,13 +242,13 @@ void menu_exit(int m)
|
|||
inuse[m] = false;
|
||||
}
|
||||
|
||||
Menu menu_run(int m)
|
||||
bool menu_run(int m)
|
||||
{
|
||||
Menu result = MENU_OK;
|
||||
bool exit = false;
|
||||
|
||||
menu_draw(m);
|
||||
|
||||
while(1) {
|
||||
while (!exit) {
|
||||
switch( button_get_w_tmo(HZ/2) ) {
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
case BUTTON_UP:
|
||||
|
@ -303,12 +303,12 @@ Menu menu_run(int m)
|
|||
are gonna clear the screen anyway */
|
||||
lcd_clear_display();
|
||||
|
||||
/* if a child returns that the contents is changed, we
|
||||
must remember this, even if we perhaps invoke other
|
||||
children too before returning back */
|
||||
if(MENU_DISK_CHANGED ==
|
||||
menus[m].items[menus[m].cursor].function())
|
||||
result = MENU_DISK_CHANGED;
|
||||
/* if a child returns that USB was used,
|
||||
we return immediately */
|
||||
if (menus[m].items[menus[m].cursor].function()) {
|
||||
lcd_scroll_pause(); /* just in case */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Return to previous display state */
|
||||
menu_draw(m);
|
||||
|
@ -321,39 +321,29 @@ Menu menu_run(int m)
|
|||
case BUTTON_STOP:
|
||||
case BUTTON_MENU:
|
||||
#endif
|
||||
lcd_stop_scroll();
|
||||
while (button_get(false)); /* clear button queue */
|
||||
return result;
|
||||
lcd_scroll_pause();
|
||||
exit = true;
|
||||
break;
|
||||
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
case BUTTON_F3:
|
||||
if (f3_screen())
|
||||
return SYS_USB_CONNECTED;
|
||||
return true;
|
||||
menu_draw(m);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifndef SIMULATOR
|
||||
case SYS_USB_CONNECTED:
|
||||
backlight_time(4);
|
||||
usb_acknowledge(SYS_USB_CONNECTED_ACK);
|
||||
usb_wait_for_disconnect(&button_queue);
|
||||
backlight_time(global_settings.backlight);
|
||||
usb_screen();
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
lcd_icon(ICON_PARAM, true);
|
||||
lcd_icon(ICON_PARAM, false);
|
||||
#endif
|
||||
menu_draw(m);
|
||||
result = MENU_DISK_CHANGED;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
|
||||
status_draw();
|
||||
lcd_update();
|
||||
}
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
|
11
apps/menu.h
11
apps/menu.h
|
@ -22,16 +22,9 @@
|
|||
|
||||
#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 {
|
||||
unsigned char *desc;
|
||||
Menu (*function) (void);
|
||||
bool (*function) (void); /* return true if USB was connected */
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
Menu menu_run(int menu);
|
||||
bool menu_run(int menu);
|
||||
|
||||
#endif /* End __MENU_H__ */
|
||||
|
|
|
@ -257,10 +257,10 @@ void game_init(void) {
|
|||
|
||||
}
|
||||
|
||||
Menu snake(void) {
|
||||
bool snake(void) {
|
||||
game_init();
|
||||
lcd_clear_display();
|
||||
game();
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "button.h"
|
||||
#include "kernel.h"
|
||||
#include "menu.h"
|
||||
#include "screens.h"
|
||||
|
||||
#ifdef SIMULATOR
|
||||
#include <stdio.h>
|
||||
|
@ -37,6 +38,10 @@
|
|||
#define SOKOBAN_TITLE_FONT 2
|
||||
#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 int current_level=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 b = 0;
|
||||
int c = 0;
|
||||
|
@ -1790,7 +1795,7 @@ void load_level (int level_to_load) {
|
|||
return;
|
||||
}
|
||||
|
||||
void update_screen(void) {
|
||||
static void update_screen(void) {
|
||||
int b = 0;
|
||||
int c = 0;
|
||||
char s[25];
|
||||
|
@ -1855,7 +1860,8 @@ void update_screen(void) {
|
|||
|
||||
|
||||
|
||||
void sokoban_loop(void) {
|
||||
static bool sokoban_loop(void)
|
||||
{
|
||||
int ii = 0;
|
||||
moves = 0;
|
||||
current_level = 0;
|
||||
|
@ -1868,7 +1874,7 @@ void sokoban_loop(void) {
|
|||
|
||||
case BUTTON_OFF:
|
||||
/* get out of here */
|
||||
return;
|
||||
return false;
|
||||
|
||||
case BUTTON_F3:
|
||||
/* increase level */
|
||||
|
@ -2170,6 +2176,10 @@ void sokoban_loop(void) {
|
|||
row++;
|
||||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
usb_screen();
|
||||
return true;
|
||||
|
||||
default:
|
||||
idle = true;
|
||||
break;
|
||||
|
@ -2192,20 +2202,23 @@ void sokoban_loop(void) {
|
|||
lcd_invertrect(0,0,111,63);
|
||||
lcd_update();
|
||||
if ( button_get(false) )
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
load_level(current_level);
|
||||
lcd_clear_display();
|
||||
update_screen();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Menu sokoban(void)
|
||||
bool sokoban(void)
|
||||
{
|
||||
bool result;
|
||||
int w, h;
|
||||
int len = strlen(SOKOBAN_TITLE);
|
||||
|
||||
|
@ -2240,9 +2253,9 @@ Menu sokoban(void)
|
|||
lcd_update();
|
||||
sleep(HZ*2);
|
||||
lcd_clear_display();
|
||||
sokoban_loop();
|
||||
result = sokoban_loop();
|
||||
|
||||
return MENU_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,10 +22,7 @@
|
|||
|
||||
#include "menu.h"
|
||||
|
||||
void load_level(int);
|
||||
void update_screen(void);
|
||||
void sokoban_loop(void);
|
||||
Menu sokoban(void);
|
||||
bool sokoban(void);
|
||||
|
||||
#endif /*__SOKOBAN__ */
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "kernel.h"
|
||||
#include <string.h>
|
||||
#include "menu.h"
|
||||
#include "screens.h"
|
||||
|
||||
#ifdef SIMULATOR
|
||||
#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;
|
||||
}
|
||||
|
||||
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, 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);
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
|
@ -156,7 +157,7 @@ void to_virtual(void)
|
|||
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;
|
||||
for (a = 0; a < 4; a++)
|
||||
|
@ -166,7 +167,7 @@ bool block_touch (int x, int y)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool gameover(void)
|
||||
static bool gameover(void)
|
||||
{
|
||||
int i;
|
||||
int frame, block, y, x;
|
||||
|
@ -191,7 +192,7 @@ bool gameover(void)
|
|||
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;
|
||||
for(i=0;i < 4;i++)
|
||||
|
@ -204,7 +205,7 @@ bool valid_position(int x, int y, int block, int frame)
|
|||
return true;
|
||||
}
|
||||
|
||||
void from_virtual(void)
|
||||
static void from_virtual(void)
|
||||
{
|
||||
int x,y;
|
||||
for(y = 0; y < max_y; y++)
|
||||
|
@ -215,7 +216,7 @@ void from_virtual(void)
|
|||
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;
|
||||
if(f != 0)
|
||||
|
@ -239,7 +240,7 @@ void move_block(int x,int y,int f)
|
|||
current_f = last_frame;
|
||||
}
|
||||
|
||||
void new_block(void)
|
||||
static void new_block(void)
|
||||
{
|
||||
current_b = next_b;
|
||||
current_f = next_f;
|
||||
|
@ -266,7 +267,7 @@ void new_block(void)
|
|||
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;
|
||||
bool line;
|
||||
|
@ -298,7 +299,7 @@ int check_lines(void)
|
|||
return lines / 4;
|
||||
}
|
||||
|
||||
void move_down(void)
|
||||
static void move_down(void)
|
||||
{
|
||||
int l;
|
||||
char s[25];
|
||||
|
@ -327,7 +328,7 @@ void move_down(void)
|
|||
move_block(-4,0,0);
|
||||
}
|
||||
|
||||
void game_loop(void)
|
||||
static bool game_loop(void)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
|
@ -336,28 +337,32 @@ void game_loop(void)
|
|||
{
|
||||
switch(button_get_w_tmo(HZ/10))
|
||||
{
|
||||
case BUTTON_OFF:
|
||||
return;
|
||||
case BUTTON_OFF:
|
||||
return false;
|
||||
|
||||
case BUTTON_UP:
|
||||
case BUTTON_UP | BUTTON_REPEAT:
|
||||
move_block(0,-3,0);
|
||||
break;
|
||||
case BUTTON_UP:
|
||||
case BUTTON_UP | BUTTON_REPEAT:
|
||||
move_block(0,-3,0);
|
||||
break;
|
||||
|
||||
case BUTTON_DOWN:
|
||||
case BUTTON_DOWN | BUTTON_REPEAT:
|
||||
move_block(0,3,0);
|
||||
break;
|
||||
case BUTTON_DOWN:
|
||||
case BUTTON_DOWN | BUTTON_REPEAT:
|
||||
move_block(0,3,0);
|
||||
break;
|
||||
|
||||
case BUTTON_RIGHT:
|
||||
case BUTTON_RIGHT | BUTTON_REPEAT:
|
||||
move_block(0,0,1);
|
||||
break;
|
||||
case BUTTON_RIGHT:
|
||||
case BUTTON_RIGHT | BUTTON_REPEAT:
|
||||
move_block(0,0,1);
|
||||
break;
|
||||
|
||||
case BUTTON_LEFT:
|
||||
case BUTTON_LEFT | BUTTON_REPEAT:
|
||||
move_down();
|
||||
break;
|
||||
case BUTTON_LEFT:
|
||||
case BUTTON_LEFT | BUTTON_REPEAT:
|
||||
move_down();
|
||||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
usb_screen();
|
||||
return true;
|
||||
}
|
||||
|
||||
count++;
|
||||
|
@ -369,14 +374,16 @@ void game_loop(void)
|
|||
lcd_putsxy (2, 52, str(LANG_TETRIS_LOSE), 0);
|
||||
lcd_update();
|
||||
sleep(HZ * 3);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
move_down();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void init_tetris(void)
|
||||
static void init_tetris(void)
|
||||
{
|
||||
memset(&virtual, 0, sizeof(virtual));
|
||||
|
||||
|
@ -391,7 +398,7 @@ void init_tetris(void)
|
|||
next_f = 0;
|
||||
}
|
||||
|
||||
Menu tetris(void)
|
||||
bool tetris(void)
|
||||
{
|
||||
init_tetris();
|
||||
|
||||
|
@ -402,9 +409,7 @@ Menu tetris(void)
|
|||
next_b = t_rand(blocks);
|
||||
next_f = t_rand(block_frames[next_b]);
|
||||
new_block();
|
||||
game_loop();
|
||||
|
||||
return MENU_OK;
|
||||
return game_loop();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "menu.h"
|
||||
#include "rtc.h"
|
||||
#include "lang.h"
|
||||
#include "screens.h"
|
||||
|
||||
/* size of the field the worm lives in */
|
||||
#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.
|
||||
*/
|
||||
Menu wormlet(void)
|
||||
bool wormlet(void)
|
||||
{
|
||||
bool wormDead = false;
|
||||
int button;
|
||||
|
@ -1974,6 +1975,10 @@ Menu wormlet(void)
|
|||
use_remote = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
usb_screen();
|
||||
return true;
|
||||
}
|
||||
} while (button != BUTTON_PLAY &&
|
||||
button != BUTTON_OFF && button != BUTTON_ON);
|
||||
|
@ -2007,7 +2012,7 @@ Menu wormlet(void)
|
|||
}
|
||||
while (button != BUTTON_OFF);
|
||||
|
||||
return MENU_OK;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "menu.h"
|
||||
|
||||
Menu wormlet(void);
|
||||
bool wormlet(void);
|
||||
|
||||
#endif /*__WORMLET__ */
|
||||
|
||||
|
|
292
apps/screens.c
Normal file
292
apps/screens.c
Normal 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
30
apps/screens.h
Normal 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
|
180
apps/settings.c
180
apps/settings.c
|
@ -38,6 +38,7 @@
|
|||
#include "powermgmt.h"
|
||||
#include "status.h"
|
||||
#include "atoi.h"
|
||||
#include "screens.h"
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "icons.h"
|
||||
#include "font.h"
|
||||
|
@ -476,84 +477,84 @@ bool settings_load_eq(char* file)
|
|||
if (!strcasecmp(buf_set,"volume")) {
|
||||
global_settings.volume = (atoi(buf_val)/2);
|
||||
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);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
|
||||
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"bass")) {
|
||||
if (buf_val[0] == '-')
|
||||
global_settings.bass = ((mpeg_sound_max(SOUND_BASS)/2)-atoi(buf_val+1));
|
||||
else
|
||||
global_settings.bass = (atoi(buf_val)+(mpeg_sound_max(SOUND_BASS)/2));
|
||||
if (global_settings.bass > mpeg_sound_max(SOUND_BASS) ||
|
||||
if (!strcasecmp(buf_set,"bass")) {
|
||||
if (buf_val[0] == '-')
|
||||
global_settings.bass = ((mpeg_sound_max(SOUND_BASS)/2)-atoi(buf_val+1));
|
||||
else
|
||||
global_settings.bass = (atoi(buf_val)+(mpeg_sound_max(SOUND_BASS)/2));
|
||||
if (global_settings.bass > mpeg_sound_max(SOUND_BASS) ||
|
||||
global_settings.bass < mpeg_sound_min(SOUND_BASS)) {
|
||||
global_settings.bass = mpeg_sound_default(SOUND_BASS);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_BASS, global_settings.bass);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"treble")) {
|
||||
if (buf_val[0] == '-')
|
||||
global_settings.treble = ((mpeg_sound_max(SOUND_TREBLE)/2)-atoi(buf_val+1));
|
||||
else
|
||||
global_settings.treble = (atoi(buf_val)+(mpeg_sound_max(SOUND_TREBLE)/2));
|
||||
if (global_settings.treble > mpeg_sound_max(SOUND_TREBLE) ||
|
||||
global_settings.treble < mpeg_sound_min(SOUND_TREBLE)) {
|
||||
global_settings.treble = mpeg_sound_default(SOUND_TREBLE);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_TREBLE, global_settings.treble);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"balance")) {
|
||||
if (buf_val[0] == '-')
|
||||
global_settings.balance = -(atoi(buf_val+1)/2);
|
||||
else
|
||||
global_settings.balance = ((atoi(buf_val)/2));
|
||||
if (global_settings.balance > mpeg_sound_max(SOUND_BALANCE) ||
|
||||
global_settings.balance < mpeg_sound_min(SOUND_BALANCE)) {
|
||||
global_settings.balance = mpeg_sound_default(SOUND_BALANCE);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_BALANCE, global_settings.balance);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"channels")) {
|
||||
global_settings.channel_config = atoi(buf_val);
|
||||
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_default(SOUND_CHANNELS);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"loudness")) {
|
||||
global_settings.loudness = atoi(buf_val);
|
||||
if(global_settings.loudness > mpeg_sound_max(SOUND_LOUDNESS) ||
|
||||
global_settings.loudness < mpeg_sound_min(SOUND_LOUDNESS)) {
|
||||
global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"bass boost")) {
|
||||
global_settings.bass_boost = (atoi(buf_val)/10);
|
||||
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_default(SOUND_SUPERBASS);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost);
|
||||
} else if (!strcasecmp(buf_set,"auto volume")) {
|
||||
global_settings.avc = atoi(buf_val);
|
||||
if (global_settings.avc > mpeg_sound_max(SOUND_AVC) ||
|
||||
global_settings.avc < mpeg_sound_min(SOUND_AVC)) {
|
||||
global_settings.avc = mpeg_sound_default(SOUND_AVC);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_AVC, global_settings.avc);
|
||||
}
|
||||
global_settings.bass = mpeg_sound_default(SOUND_BASS);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_BASS, global_settings.bass);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"treble")) {
|
||||
if (buf_val[0] == '-')
|
||||
global_settings.treble = ((mpeg_sound_max(SOUND_TREBLE)/2)-atoi(buf_val+1));
|
||||
else
|
||||
global_settings.treble = (atoi(buf_val)+(mpeg_sound_max(SOUND_TREBLE)/2));
|
||||
if (global_settings.treble > mpeg_sound_max(SOUND_TREBLE) ||
|
||||
global_settings.treble < mpeg_sound_min(SOUND_TREBLE)) {
|
||||
global_settings.treble = mpeg_sound_default(SOUND_TREBLE);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_TREBLE, global_settings.treble);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"balance")) {
|
||||
if (buf_val[0] == '-')
|
||||
global_settings.balance = -(atoi(buf_val+1)/2);
|
||||
else
|
||||
global_settings.balance = ((atoi(buf_val)/2));
|
||||
if (global_settings.balance > mpeg_sound_max(SOUND_BALANCE) ||
|
||||
global_settings.balance < mpeg_sound_min(SOUND_BALANCE)) {
|
||||
global_settings.balance = mpeg_sound_default(SOUND_BALANCE);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_BALANCE, global_settings.balance);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"channels")) {
|
||||
global_settings.channel_config = atoi(buf_val);
|
||||
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_default(SOUND_CHANNELS);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"loudness")) {
|
||||
global_settings.loudness = atoi(buf_val);
|
||||
if(global_settings.loudness > mpeg_sound_max(SOUND_LOUDNESS) ||
|
||||
global_settings.loudness < mpeg_sound_min(SOUND_LOUDNESS)) {
|
||||
global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness);
|
||||
} else
|
||||
if (!strcasecmp(buf_set,"bass boost")) {
|
||||
global_settings.bass_boost = (atoi(buf_val)/10);
|
||||
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_default(SOUND_SUPERBASS);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost);
|
||||
} else if (!strcasecmp(buf_set,"auto volume")) {
|
||||
global_settings.avc = atoi(buf_val);
|
||||
if (global_settings.avc > mpeg_sound_max(SOUND_AVC) ||
|
||||
global_settings.avc < mpeg_sound_min(SOUND_AVC)) {
|
||||
global_settings.avc = mpeg_sound_default(SOUND_AVC);
|
||||
syntax_error = true;
|
||||
}
|
||||
mpeg_sound_set(SOUND_AVC, global_settings.avc);
|
||||
}
|
||||
if (syntax_error) {
|
||||
lcd_clear_display();
|
||||
lcd_puts(0,1,"SyntaxError");
|
||||
|
@ -636,20 +637,24 @@ void settings_display(void)
|
|||
#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 };
|
||||
int value = !*variable;
|
||||
set_option(string, &value, names, 2, NULL);
|
||||
bool result;
|
||||
|
||||
result = set_option(string, &value, names, 2, NULL);
|
||||
*variable = !value;
|
||||
return result;
|
||||
}
|
||||
|
||||
void set_int(char* string,
|
||||
bool set_int(char* string,
|
||||
char* unit,
|
||||
int* variable,
|
||||
void (*function)(int),
|
||||
|
@ -713,14 +718,20 @@ void set_int(char* string,
|
|||
#endif
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
usb_screen();
|
||||
return true;
|
||||
}
|
||||
if ( function && button != BUTTON_NONE)
|
||||
function(*variable);
|
||||
}
|
||||
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))
|
||||
{
|
||||
bool done = false;
|
||||
|
@ -778,12 +789,17 @@ void set_option(char* string, int* variable, char* options[],
|
|||
#endif
|
||||
done = true;
|
||||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
usb_screen();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( function && button != BUTTON_NONE)
|
||||
function(*variable);
|
||||
}
|
||||
lcd_stop_scroll();
|
||||
return false;
|
||||
}
|
||||
|
||||
#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}};
|
||||
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;
|
||||
int button;
|
||||
|
@ -999,9 +1015,13 @@ void set_time(char* string, int timedate[])
|
|||
#endif
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
usb_screen();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -112,19 +112,20 @@ void settings_reset(void);
|
|||
void settings_display(void);
|
||||
|
||||
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 );
|
||||
void set_option(char* string, int* variable, char* options[],
|
||||
bool set_bool(char* string, bool* variable );
|
||||
bool set_option(char* string, int* variable, char* options[],
|
||||
int numoptions, void (*function)(int));
|
||||
void set_int(char* string,
|
||||
bool set_int(char* string,
|
||||
char* unit,
|
||||
int* variable,
|
||||
void (*function)(int),
|
||||
int step,
|
||||
int min,
|
||||
int max );
|
||||
void set_time(char* string, int timedate[]);
|
||||
bool set_time(char* string, int timedate[]);
|
||||
|
||||
/* global settings */
|
||||
extern struct user_settings global_settings;
|
||||
|
|
|
@ -38,99 +38,94 @@
|
|||
#include "ata.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,
|
||||
str(LANG_HIDDEN_SHOW), str(LANG_HIDDEN_HIDE) );
|
||||
return MENU_OK;
|
||||
return set_bool_options( str(LANG_HIDDEN),
|
||||
&global_settings.show_hidden_files,
|
||||
str(LANG_HIDDEN_SHOW),
|
||||
str(LANG_HIDDEN_HIDE) );
|
||||
}
|
||||
|
||||
static Menu contrast(void)
|
||||
static bool contrast(void)
|
||||
{
|
||||
set_int( str(LANG_CONTRAST), "", &global_settings.contrast,
|
||||
lcd_set_contrast, 1, 0, MAX_CONTRAST_SETTING );
|
||||
return MENU_OK;
|
||||
return set_int( str(LANG_CONTRAST), "", &global_settings.contrast,
|
||||
lcd_set_contrast, 1, 0, MAX_CONTRAST_SETTING );
|
||||
}
|
||||
|
||||
#ifndef HAVE_RECORDER_KEYPAD
|
||||
static Menu shuffle(void)
|
||||
static bool shuffle(void)
|
||||
{
|
||||
set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle );
|
||||
return MENU_OK;
|
||||
return set_bool( str(LANG_SHUFFLE), &global_settings.playlist_shuffle );
|
||||
}
|
||||
#endif
|
||||
|
||||
static Menu play_selected(void)
|
||||
static bool play_selected(void)
|
||||
{
|
||||
set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected );
|
||||
return MENU_OK;
|
||||
return set_bool( str(LANG_PLAY_SELECTED), &global_settings.play_selected );
|
||||
}
|
||||
|
||||
static Menu mp3_filter(void)
|
||||
static bool mp3_filter(void)
|
||||
{
|
||||
set_bool( str(LANG_MP3FILTER), &global_settings.mp3filter );
|
||||
return MENU_OK;
|
||||
return set_bool( str(LANG_MP3FILTER), &global_settings.mp3filter );
|
||||
}
|
||||
|
||||
static Menu sort_case(void)
|
||||
static bool sort_case(void)
|
||||
{
|
||||
set_bool( str(LANG_SORT_CASE), &global_settings.sort_case );
|
||||
return MENU_OK;
|
||||
return set_bool( str(LANG_SORT_CASE), &global_settings.sort_case );
|
||||
}
|
||||
|
||||
static Menu resume(void)
|
||||
static bool resume(void)
|
||||
{
|
||||
char* names[] = { str(LANG_OFF),
|
||||
str(LANG_RESUME_SETTING_ASK),
|
||||
str(LANG_ON) };
|
||||
set_option( str(LANG_RESUME), &global_settings.resume, names, 3, NULL );
|
||||
return MENU_OK;
|
||||
return set_option( str(LANG_RESUME), &global_settings.resume,
|
||||
names, 3, NULL );
|
||||
}
|
||||
|
||||
static Menu backlight_timer(void)
|
||||
static bool backlight_timer(void)
|
||||
{
|
||||
char* names[] = { str(LANG_OFF), str(LANG_ON),
|
||||
"1s ", "2s ", "3s ", "4s ", "5s ",
|
||||
"6s ", "7s ", "8s ", "9s ", "10s",
|
||||
"15s", "20s", "25s", "30s", "45s",
|
||||
"60s", "90s"};
|
||||
set_option(str(LANG_BACKLIGHT), &global_settings.backlight, names, 19,
|
||||
backlight_time );
|
||||
return MENU_OK;
|
||||
return set_option(str(LANG_BACKLIGHT), &global_settings.backlight,
|
||||
names, 19, backlight_time );
|
||||
}
|
||||
|
||||
static Menu poweroff_idle_timer(void)
|
||||
static bool poweroff_idle_timer(void)
|
||||
{
|
||||
char* names[] = { str(LANG_OFF),
|
||||
"1m ", "2m ", "3m ", "4m ", "5m ",
|
||||
"6m ", "7m ", "8m ", "9m ", "10m",
|
||||
"15m", "30m", "45m", "60m"};
|
||||
set_option(str(LANG_POWEROFF_IDLE), &global_settings.poweroff, names,
|
||||
15, set_poweroff_timeout);
|
||||
return MENU_OK;
|
||||
return set_option(str(LANG_POWEROFF_IDLE), &global_settings.poweroff,
|
||||
names, 15, set_poweroff_timeout);
|
||||
}
|
||||
|
||||
static Menu scroll_speed(void)
|
||||
static bool scroll_speed(void)
|
||||
{
|
||||
set_int(str(LANG_SCROLL), "", &global_settings.scroll_speed,
|
||||
&lcd_scroll_speed, 1, 1, 30 );
|
||||
return MENU_OK;
|
||||
return set_int(str(LANG_SCROLL), "", &global_settings.scroll_speed,
|
||||
&lcd_scroll_speed, 1, 1, 30 );
|
||||
}
|
||||
|
||||
#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_LO : CHARGE_RESTART_HI;
|
||||
return MENU_OK;
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
static Menu timedate_set(void)
|
||||
static bool timedate_set(void)
|
||||
{
|
||||
int timedate[7]; /* hour,minute,second,year,month,day,dayofweek */
|
||||
bool result;
|
||||
|
||||
#ifdef HAVE_RTC
|
||||
timedate[0] = rtc_read(0x03); /* hour */
|
||||
|
@ -167,7 +162,7 @@ static Menu timedate_set(void)
|
|||
timedate[5] = 1;
|
||||
#endif
|
||||
|
||||
set_time(str(LANG_TIME),timedate);
|
||||
result = set_time(str(LANG_TIME),timedate);
|
||||
|
||||
#ifdef HAVE_RTC
|
||||
if(timedate[0] != -1) {
|
||||
|
@ -194,49 +189,45 @@ static Menu timedate_set(void)
|
|||
rtc_write(0x00, 0x00); /* 0.1 + 0.01 seconds */
|
||||
}
|
||||
#endif
|
||||
return MENU_OK;
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
static Menu spindown(void)
|
||||
static bool spindown(void)
|
||||
{
|
||||
set_int(str(LANG_SPINDOWN), "s", &global_settings.disk_spindown,
|
||||
ata_spindown, 1, 3, 254 );
|
||||
return MENU_OK;
|
||||
return set_int(str(LANG_SPINDOWN), "s", &global_settings.disk_spindown,
|
||||
ata_spindown, 1, 3, 254 );
|
||||
}
|
||||
|
||||
static Menu ff_rewind_min_step(void)
|
||||
static bool ff_rewind_min_step(void)
|
||||
{
|
||||
char* names[] = { "1s", "2s", "3s", "4s",
|
||||
"5s", "6s", "8s", "10s",
|
||||
"15s", "20s", "25s", "30s",
|
||||
"45s", "60s" };
|
||||
set_option(str(LANG_FFRW_STEP), &global_settings.ff_rewind_min_step,
|
||||
names, 14, NULL );
|
||||
return MENU_OK;
|
||||
return set_option(str(LANG_FFRW_STEP), &global_settings.ff_rewind_min_step,
|
||||
names, 14, NULL );
|
||||
}
|
||||
|
||||
static Menu ff_rewind_accel(void)
|
||||
static bool ff_rewind_accel(void)
|
||||
{
|
||||
char* names[] = { str(LANG_OFF), "2x/1s", "2x/2s", "2x/3s",
|
||||
"2x/4s", "2x/5s", "2x/6s", "2x/7s",
|
||||
"2x/8s", "2x/9s", "2x/10s", "2x/11s",
|
||||
"2x/12s", "2x/13s", "2x/14s", "2x/15s", };
|
||||
set_option(str(LANG_FFRW_ACCEL), &global_settings.ff_rewind_accel,
|
||||
names, 16, NULL );
|
||||
return MENU_OK;
|
||||
return set_option(str(LANG_FFRW_ACCEL), &global_settings.ff_rewind_accel,
|
||||
names, 16, NULL );
|
||||
}
|
||||
|
||||
static Menu browse_current(void)
|
||||
static bool browse_current(void)
|
||||
{
|
||||
set_bool( str(LANG_FOLLOW), &global_settings.browse_current );
|
||||
return MENU_OK;
|
||||
return set_bool( str(LANG_FOLLOW), &global_settings.browse_current );
|
||||
}
|
||||
|
||||
Menu playback_settings_menu(void)
|
||||
static bool playback_settings_menu(void)
|
||||
{
|
||||
int m;
|
||||
Menu result;
|
||||
bool result;
|
||||
|
||||
struct menu_items items[] = {
|
||||
#ifndef HAVE_RECORDER_KEYPAD
|
||||
|
@ -268,7 +259,7 @@ Menu playback_settings_menu(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
static Menu reset_settings(void)
|
||||
static bool reset_settings(void)
|
||||
{
|
||||
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;
|
||||
Menu result;
|
||||
bool result;
|
||||
|
||||
struct menu_items items[] = {
|
||||
{ str(LANG_CASE_MENU), sort_case },
|
||||
|
@ -312,16 +303,16 @@ static Menu fileview_settings_menu(void)
|
|||
{ 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);
|
||||
menu_exit(m);
|
||||
return result;
|
||||
}
|
||||
|
||||
static Menu display_settings_menu(void)
|
||||
static bool display_settings_menu(void)
|
||||
{
|
||||
int m;
|
||||
Menu result;
|
||||
bool result;
|
||||
|
||||
struct menu_items items[] = {
|
||||
{ str(LANG_SCROLL_MENU), scroll_speed },
|
||||
|
@ -335,10 +326,10 @@ static Menu display_settings_menu(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
static Menu system_settings_menu(void)
|
||||
static bool system_settings_menu(void)
|
||||
{
|
||||
int m;
|
||||
Menu result;
|
||||
bool result;
|
||||
|
||||
struct menu_items items[] = {
|
||||
{ str(LANG_SPINDOWN), spindown },
|
||||
|
@ -358,10 +349,10 @@ static Menu system_settings_menu(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
Menu settings_menu(void)
|
||||
bool settings_menu(void)
|
||||
{
|
||||
int m;
|
||||
Menu result;
|
||||
bool result;
|
||||
|
||||
struct menu_items items[] = {
|
||||
{ str(LANG_PLAYBACK), playback_settings_menu },
|
||||
|
@ -370,7 +361,7 @@ Menu settings_menu(void)
|
|||
{ 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);
|
||||
menu_exit(m);
|
||||
return result;
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
|
||||
#include "menu.h"
|
||||
|
||||
Menu settings_menu(void);
|
||||
bool settings_menu(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "mpeg.h"
|
||||
#include "settings.h"
|
||||
#include "status.h"
|
||||
#include "screens.h"
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "icons.h"
|
||||
#endif
|
||||
|
@ -38,7 +39,7 @@ static char *fmt[] =
|
|||
"%d.%02d %s " /* 2 decimals */
|
||||
};
|
||||
|
||||
void set_sound(char* string,
|
||||
bool set_sound(char* string,
|
||||
int* variable,
|
||||
int setting)
|
||||
{
|
||||
|
@ -120,20 +121,10 @@ void set_sound(char* string,
|
|||
#endif
|
||||
done = true;
|
||||
break;
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
case BUTTON_F3:
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
global_settings.statusbar = !global_settings.statusbar;
|
||||
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
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
usb_screen();
|
||||
return true;
|
||||
}
|
||||
if (changed) {
|
||||
mpeg_sound_set(setting, *variable);
|
||||
|
@ -144,43 +135,41 @@ void set_sound(char* string,
|
|||
}
|
||||
}
|
||||
lcd_stop_scroll();
|
||||
return false;
|
||||
}
|
||||
|
||||
static Menu volume(void)
|
||||
static bool volume(void)
|
||||
{
|
||||
set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME);
|
||||
return MENU_OK;
|
||||
return set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME);
|
||||
}
|
||||
|
||||
static Menu balance(void)
|
||||
static bool balance(void)
|
||||
{
|
||||
set_sound(str(LANG_BALANCE), &global_settings.balance, SOUND_BALANCE);
|
||||
return MENU_OK;
|
||||
return set_sound(str(LANG_BALANCE), &global_settings.balance,
|
||||
SOUND_BALANCE);
|
||||
}
|
||||
|
||||
static Menu bass(void)
|
||||
static bool bass(void)
|
||||
{
|
||||
set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS);
|
||||
return MENU_OK;
|
||||
return set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS);
|
||||
};
|
||||
|
||||
static Menu treble(void)
|
||||
static bool treble(void)
|
||||
{
|
||||
set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE);
|
||||
return MENU_OK;
|
||||
return set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MAS3587F
|
||||
static Menu loudness(void)
|
||||
static bool loudness(void)
|
||||
{
|
||||
set_sound(str(LANG_LOUDNESS), &global_settings.loudness, SOUND_LOUDNESS);
|
||||
return MENU_OK;
|
||||
return set_sound(str(LANG_LOUDNESS), &global_settings.loudness,
|
||||
SOUND_LOUDNESS);
|
||||
};
|
||||
|
||||
static Menu bass_boost(void)
|
||||
static bool bass_boost(void)
|
||||
{
|
||||
set_sound(str(LANG_BBOOST), &global_settings.bass_boost, SOUND_SUPERBASS);
|
||||
return MENU_OK;
|
||||
return set_sound(str(LANG_BBOOST), &global_settings.bass_boost,
|
||||
SOUND_SUPERBASS);
|
||||
};
|
||||
|
||||
static void set_avc(int val)
|
||||
|
@ -188,11 +177,11 @@ static void set_avc(int val)
|
|||
mpeg_sound_set(SOUND_AVC, val);
|
||||
}
|
||||
|
||||
static Menu avc(void)
|
||||
static bool avc(void)
|
||||
{
|
||||
char* names[] = { str(LANG_OFF), "2s", "4s", "8s" };
|
||||
set_option(str(LANG_DECAY), &global_settings.avc, names, 4, set_avc );
|
||||
return MENU_OK;
|
||||
return set_option(str(LANG_DECAY), &global_settings.avc,
|
||||
names, 4, set_avc);
|
||||
}
|
||||
#endif /* ARCHOS_RECORDER */
|
||||
|
||||
|
@ -201,19 +190,18 @@ static void set_chanconf(int 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),
|
||||
str(LANG_CHANNEL_LEFT),str(LANG_CHANNEL_RIGHT) };
|
||||
set_option(str(LANG_CHANNEL),
|
||||
&global_settings.channel_config, names, 4, set_chanconf );
|
||||
return MENU_OK;
|
||||
str(LANG_CHANNEL_LEFT), str(LANG_CHANNEL_RIGHT) };
|
||||
return set_option(str(LANG_CHANNEL), &global_settings.channel_config,
|
||||
names, 4, set_chanconf );
|
||||
}
|
||||
|
||||
Menu sound_menu(void)
|
||||
bool sound_menu(void)
|
||||
{
|
||||
int m;
|
||||
Menu result;
|
||||
bool result;
|
||||
struct menu_items items[] = {
|
||||
{ str(LANG_VOLUME), volume },
|
||||
{ str(LANG_BASS), bass },
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
|
||||
#include "menu.h"
|
||||
|
||||
Menu sound_menu(void);
|
||||
bool sound_menu(void);
|
||||
|
||||
#endif
|
||||
|
|
24
apps/tree.c
24
apps/tree.c
|
@ -47,6 +47,7 @@
|
|||
#include "icons.h"
|
||||
#include "lang.h"
|
||||
#include "language.h"
|
||||
#include "screens.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "widgets.h"
|
||||
|
@ -880,7 +881,8 @@ bool dirbrowse(char *root)
|
|||
|
||||
case TREE_MENU:
|
||||
lcd_stop_scroll();
|
||||
main_menu();
|
||||
if (main_menu())
|
||||
reload_root = true;
|
||||
restore = true;
|
||||
break;
|
||||
|
||||
|
@ -915,24 +917,10 @@ bool dirbrowse(char *root)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifndef SIMULATOR
|
||||
case SYS_USB_CONNECTED: {
|
||||
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 */
|
||||
case SYS_USB_CONNECTED:
|
||||
usb_screen();
|
||||
reload_root = true;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if ( button )
|
||||
|
|
288
apps/wps.c
288
apps/wps.c
|
@ -37,6 +37,7 @@
|
|||
#include "status.h"
|
||||
#include "main_menu.h"
|
||||
#include "ata.h"
|
||||
#include "screens.h"
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "icons.h"
|
||||
#endif
|
||||
|
@ -151,22 +152,6 @@ void display_mute_text(bool muted)
|
|||
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)
|
||||
{
|
||||
int button;
|
||||
|
@ -298,12 +283,10 @@ static int browse_id3(void)
|
|||
exit = true;
|
||||
break;
|
||||
|
||||
#ifndef SIMULATOR
|
||||
case SYS_USB_CONNECTED:
|
||||
handle_usb();
|
||||
usb_screen();
|
||||
return SYS_USB_CONNECTED;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -413,7 +396,7 @@ static bool ffwd_rew(int button)
|
|||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
handle_usb();
|
||||
usb_screen();
|
||||
usb = true;
|
||||
exit = true;
|
||||
break;
|
||||
|
@ -488,7 +471,7 @@ static bool keylock(void)
|
|||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
handle_usb();
|
||||
usb_screen();
|
||||
return true;
|
||||
|
||||
case BUTTON_NONE:
|
||||
|
@ -541,7 +524,8 @@ static bool menu(void)
|
|||
if ( !last_button ) {
|
||||
lcd_stop_scroll();
|
||||
button_set_release(old_release_mask);
|
||||
main_menu();
|
||||
if (main_menu())
|
||||
return true;
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
if(global_settings.statusbar)
|
||||
lcd_setmargins(0, STATUSBAR_HEIGHT);
|
||||
|
@ -608,7 +592,7 @@ static bool menu(void)
|
|||
break;
|
||||
|
||||
case SYS_USB_CONNECTED:
|
||||
handle_usb();
|
||||
usb_screen();
|
||||
return true;
|
||||
}
|
||||
last_button = button;
|
||||
|
@ -623,260 +607,6 @@ static bool menu(void)
|
|||
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 */
|
||||
int wps_show(void)
|
||||
{
|
||||
|
@ -1088,11 +818,9 @@ int wps_show(void)
|
|||
button_set_release(old_release_mask);
|
||||
return 0;
|
||||
|
||||
#ifndef SIMULATOR
|
||||
case SYS_USB_CONNECTED:
|
||||
handle_usb();
|
||||
usb_screen();
|
||||
return SYS_USB_CONNECTED;
|
||||
#endif
|
||||
|
||||
case BUTTON_NONE: /* Timeout */
|
||||
update();
|
||||
|
|
|
@ -29,6 +29,7 @@ int wps_show(void);
|
|||
bool load_custom_wps(void);
|
||||
bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string);
|
||||
bool refresh_wps(bool refresh_scroll);
|
||||
void handle_usb(void);
|
||||
|
||||
#ifdef HAVE_RECORDER_KEYPAD
|
||||
bool f2_screen(void);
|
||||
|
|
|
@ -66,7 +66,8 @@ FIRMSRCS = lcd-recorder.c power.c sprintf.c id3.c usb.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 \
|
||||
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
|
||||
|
||||
|
@ -197,6 +198,9 @@ $(OBJDIR)/sysfont.o: $(FIRMWAREDIR)/fonts/clR6x8.bdf
|
|||
$(OBJDIR)/status.o: $(APPDIR)/status.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/screens.o: $(APPDIR)/screens.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/version.o: $(FIRMWAREDIR)/version.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
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
|
||||
|
||||
|
@ -237,6 +238,9 @@ $(OBJDIR)/settings.o: $(APPDIR)/settings.c
|
|||
$(OBJDIR)/status.o: $(APPDIR)/status.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/screens.o: $(APPDIR)/screens.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/id3.o: $(FIRMWAREDIR)/id3.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
|
||||
|
|
Loading…
Reference in a new issue