Upside Down option for display (and buttons) now wired into the display settings menu, persistence, simulator stubs

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4168 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jörg Hohensohn 2003-12-20 10:00:37 +00:00
parent 2a8386106b
commit a5e1d06354
8 changed files with 99 additions and 7 deletions

View File

@ -1842,3 +1842,8 @@ id: LANG_MOVE_FAILED
desc: Error message displayed in playlist viewer
eng: "Move failed"
new:
id: LANG_FLIP_DISPLAY
desc: in settings_menu, option to turn display+buttos by 180 degreed
eng: "Upside Down"
new:

View File

@ -103,6 +103,7 @@ offset abs
0x1a 0x2e <time until disk spindown>
0x1b 0x2f <browse current, play selected, recursive dir insert>
0x1c 0x30 <peak meter hold timeout (bit 0-4),
flip_display (bit 6)
rec_editable (bit 7)>
0x1d 0x31 <(int) Resume shuffle seed, or -1 if no shuffle>
0x21 0x35 <repeat mode (bit 0-1), rec. channels (bit 2),
@ -362,6 +363,7 @@ int settings_save( void )
((global_settings.recursive_dir_insert & 3) << 2));
config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold |
(global_settings.flip_display ? 0x40 : 0) |
(global_settings.rec_editable?0x80:0);
memcpy(&config_block[0x1d], &global_settings.resume_seed, 4);
@ -516,6 +518,9 @@ void settings_apply(void)
#ifdef HAVE_LCD_BITMAP
lcd_set_invert_display(global_settings.invert);
lcd_set_flip(global_settings.flip_display);
button_set_flip(global_settings.flip_display);
lcd_update(); /* refresh after flipping the screen */
settings_apply_pm_range();
peak_meter_init_times(
global_settings.peak_meter_release, global_settings.peak_meter_hold,
@ -660,6 +665,8 @@ void settings_load(void)
if (config_block[0x1c] != 0xFF) {
global_settings.peak_meter_hold = (config_block[0x1c]) & 0x1f;
global_settings.flip_display =
(config_block[0x1c] & 0x40)?true:false;
global_settings.rec_editable =
(config_block[0x1c] & 0x80)?true:false;
}
@ -970,6 +977,8 @@ bool settings_load_config(char* file)
set_cfg_bool(&global_settings.scrollbar, value);
else if (!strcasecmp(name, "invert"))
set_cfg_bool(&global_settings.invert, value);
else if (!strcasecmp(name, "flip diplay"))
set_cfg_bool(&global_settings.flip_display, value);
else if (!strcasecmp(name, "invert cursor"))
set_cfg_bool(&global_settings.invert_cursor, value);
else if (!strcasecmp(name, "show icons"))
@ -1295,6 +1304,8 @@ bool settings_save_config(void)
#ifdef HAVE_LCD_BITMAP
fprintf(fd, "invert: %s\r\n", boolopt[global_settings.invert]);
fprintf(fd, "flip display: %s\r\n", boolopt[global_settings.flip_display]);
fprintf(fd, "invert cursor: %s\r\n",
boolopt[global_settings.invert_cursor]);
@ -1446,6 +1457,7 @@ void settings_reset(void) {
global_settings.resume = RESUME_ASK;
global_settings.contrast = lcd_default_contrast();
global_settings.invert = DEFAULT_INVERT_SETTING;
global_settings.flip_display= false;
global_settings.poweroff = DEFAULT_POWEROFF_SETTING;
global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING;
global_settings.invert_cursor = DEFAULT_INVERT_CURSOR_SETTING;

View File

@ -92,6 +92,7 @@ struct user_settings
bool invert; /* invert display */
bool invert_cursor; /* invert the current file in dir browser and menu
instead of using the default cursor */
bool flip_display; /* turn display (and button layout) by 180 degrees */
int poweroff; /* power off timer */
int backlight_timeout; /* backlight off timeout: 0-18 0=never,
1=always,

View File

@ -106,6 +106,20 @@ static bool invert_cursor(void)
NULL);
}
/**
* Menu to turn the display+buttons by 180 degrees
*/
static bool flip_display(void)
{
bool rc = set_bool( str(LANG_FLIP_DISPLAY),
&global_settings.flip_display);
button_set_flip(global_settings.flip_display);
lcd_set_flip(global_settings.flip_display);
return rc;
}
/**
* Menu to configure the battery display on status bar
*/
@ -362,7 +376,7 @@ static bool peak_meter_menu(void)
{ str(LANG_PM_MAX) , peak_meter_max },
};
m=menu_init( items, sizeof items / sizeof(struct menu_items) );
m=menu_init( items, sizeof(items) / sizeof(*items) );
result = menu_run(m);
menu_exit(m);
return result;
@ -757,7 +771,7 @@ static bool playback_settings_menu(void)
bool old_shuffle = global_settings.playlist_shuffle;
m=menu_init( items, sizeof items / sizeof(struct menu_items) );
m=menu_init( items, sizeof(items) / sizeof(*items) );
result = menu_run(m);
menu_exit(m);
@ -836,7 +850,7 @@ static bool 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(*items) );
result = menu_run(m);
menu_exit(m);
return result;
@ -861,7 +875,7 @@ static bool scroll_settings_menu(void)
#endif
};
m = menu_init( items, sizeof items / sizeof(struct menu_items) );
m=menu_init( items, sizeof(items) / sizeof(*items) );
result = menu_run(m);
menu_exit(m);
return result;
@ -884,6 +898,7 @@ static bool display_settings_menu(void)
{ str(LANG_STATUS_BAR), status_bar },
{ str(LANG_INVERT), invert },
{ str(LANG_INVERT_CURSOR), invert_cursor },
{ str(LANG_FLIP_DISPLAY), flip_display },
{ str(LANG_PM_MENU), peak_meter_menu },
{ str(LANG_VOLUME_DISPLAY), volume_type },
{ str(LANG_BATTERY_DISPLAY), battery_type },
@ -892,7 +907,7 @@ static bool display_settings_menu(void)
{ str(LANG_CAPTION_BACKLIGHT), caption_backlight },
};
m=menu_init( items, sizeof items / sizeof(struct menu_items) );
m=menu_init( items, sizeof(items) / sizeof(*items) );
result = menu_run(m);
menu_exit(m);
return result;
@ -929,7 +944,7 @@ static bool system_settings_menu(void)
{ str(LANG_RESET), reset_settings },
};
m=menu_init( items, sizeof items / sizeof(struct menu_items) );
m=menu_init( items, sizeof(items) / sizeof(*items) );
result = menu_run(m);
menu_exit(m);
return result;
@ -954,7 +969,7 @@ bool settings_menu(void)
{ str(LANG_SAVE_SETTINGS), settings_save_config },
};
m = menu_init( items, sizeof items / sizeof(struct menu_items) );
m=menu_init( items, sizeof(items) / sizeof(*items) );
result = menu_run(m);
menu_exit(m);
return result;

View File

@ -34,6 +34,9 @@
struct event_queue button_queue;
long last_keypress;
#ifdef HAVE_RECORDER_KEYPAD
static bool flipped; /* bottons can be flipped to match the LCD flip */
#endif
/* how often we check to see if a button is pressed */
#define POLL_FREQUENCY HZ/20
@ -212,6 +215,47 @@ void button_init()
#endif
queue_init(&button_queue);
tick_add_task(button_tick);
last_keypress = current_tick;
flipped = false;
}
/*
* set the flip attribute
* better only call this when the queue is empty
*/
void button_set_flip(bool flip)
{
flipped = flip;
}
/*
* helper function to swap UP/DOWN, LEFT/RIGHT, F1/F3
*/
static int button_flip(int button)
{
int newbutton;
newbutton = button &
~(BUTTON_UP | BUTTON_DOWN
| BUTTON_LEFT | BUTTON_RIGHT
| BUTTON_F1 | BUTTON_F3);
if (button & BUTTON_UP)
newbutton |= BUTTON_DOWN;
if (button & BUTTON_DOWN)
newbutton |= BUTTON_UP;
if (button & BUTTON_LEFT)
newbutton |= BUTTON_RIGHT;
if (button & BUTTON_RIGHT)
newbutton |= BUTTON_LEFT;
if (button & BUTTON_F1)
newbutton |= BUTTON_F3;
if (button & BUTTON_F3)
newbutton |= BUTTON_F1;
return newbutton;
}
/*
@ -276,6 +320,9 @@ static int button_read(void)
#endif
}
}
if (btn && flipped)
return button_flip(btn); /* swap upside down */
return btn;
}

View File

@ -29,6 +29,9 @@ extern long last_keypress;
void button_init (void);
int button_get (bool block);
int button_get_w_tmo(int ticks);
#ifdef HAVE_RECORDER_KEYPAD
void button_set_flip(bool flip); /* turn 180 degrees */
#endif
#define BUTTON_NONE 0x0000

View File

@ -41,3 +41,7 @@ void lcd_blit(unsigned char* p_data, int x, int y, int width, int height,
(void)stride;
}
void lcd_set_flip(bool yesno)
{
(void)yesno;
}

View File

@ -220,3 +220,8 @@ void cpu_sleep(bool enabled)
{
(void)enabled;
}
void button_set_flip(bool yesno)
{
(void)yesno;
}