diff options
-rw-r--r-- | apps/lang/english.lang | 5 | ||||
-rw-r--r-- | apps/menu.c | 16 | ||||
-rw-r--r-- | apps/settings.c | 26 | ||||
-rw-r--r-- | apps/settings.h | 3 | ||||
-rw-r--r-- | apps/settings_menu.c | 9 | ||||
-rw-r--r-- | apps/tree.c | 42 | ||||
-rw-r--r-- | firmware/drivers/lcd-recorder.c | 27 | ||||
-rw-r--r-- | firmware/export/lcd.h | 6 |
8 files changed, 111 insertions, 23 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 529000bec9..e080491e2c 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -1462,3 +1462,8 @@ id: LANG_VBRFIX desc: The context menu entry eng: "Update VBR file" new: + +id: LANG_INVERT_CURSOR +desc: in settings_menu +eng: "Invert cursor" +new: diff --git a/apps/menu.c b/apps/menu.c index bdf6f45e54..1c6be6f58a 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -64,7 +64,7 @@ struct menu { the margins, so this is the amount of lines we add to the cursor Y position to position it on a line */ -#define CURSOR_WIDTH 4 +#define CURSOR_WIDTH (global_settings.invert_cursor ? 0 : 4) #define SCROLLBAR_X 0 #define SCROLLBAR_Y lcd_getymargin() @@ -92,6 +92,8 @@ void put_cursorxy(int x, int y, bool on) #ifdef HAVE_LCD_BITMAP int fh, fw; int xpos, ypos; + if (global_settings.invert_cursor) + return; lcd_getstringsize("A", &fw, &fh); xpos = x*6; ypos = y*fh + lcd_getymargin(); @@ -146,7 +148,13 @@ static void menu_draw(int m) (i < menus[m].itemcount) && (i<menus[m].top+menu_lines); i++) { if((menus[m].cursor - menus[m].top)==(i-menus[m].top)) - lcd_puts_scroll(LINE_X, i-menus[m].top, menus[m].items[i].desc); +#ifdef HAVE_LCD_BITMAP + if (global_settings.invert_cursor) + lcd_puts_scroll_style(LINE_X, i-menus[m].top, + menus[m].items[i].desc, STYLE_INVERT); + else +#endif + lcd_puts_scroll(LINE_X, i-menus[m].top, menus[m].items[i].desc); else lcd_puts(LINE_X, i-menus[m].top, menus[m].items[i].desc); } @@ -197,8 +205,8 @@ static void put_cursor(int m, int target) do_update = false; } - if (do_update) { - put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true); + if (do_update && !global_settings.invert_cursor) { + put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true); lcd_update(); } diff --git a/apps/settings.c b/apps/settings.c index 18a9e86fab..8c132c5f9b 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -84,7 +84,7 @@ offset abs 0x08 0x1c <loudness byte> 0x09 0x1d <bass boost byte> 0x0a 0x1e <contrast (bit 0-5), invert bit (bit 6)> -0x0b 0x1f <backlight_on_when_charging, backlight_timeout> +0x0b 0x1f <backlight_on_when_charging, invert_cursor, backlight_timeout> 0x0c 0x20 <poweroff timer byte> 0x0d 0x21 <resume settings byte> 0x0e 0x22 <shuffle,dirfilter,sort_case,discharge,statusbar,show_hidden, @@ -304,7 +304,8 @@ int settings_save( void ) config_block[0xb] = (unsigned char) ((global_settings.backlight_on_when_charging?0x40:0) | - (global_settings.backlight_timeout & 0x3f)); + (global_settings.invert_cursor ? 0x20 : 0) | + (global_settings.backlight_timeout & 0x1f)); config_block[0xc] = (unsigned char)global_settings.poweroff; config_block[0xd] = (unsigned char)global_settings.resume; @@ -560,7 +561,9 @@ void settings_load(void) if (config_block[0xb] != 0xFF) { /* Bit 7 is unused to be able to detect uninitialized entry */ - global_settings.backlight_timeout = config_block[0xb] & 0x3f; + global_settings.backlight_timeout = config_block[0xb] & 0x1f; + global_settings.invert_cursor = + config_block[0xb] & 0x20 ? true : false; global_settings.backlight_on_when_charging = config_block[0xb] & 0x40 ? true : false; } @@ -657,7 +660,7 @@ void settings_load(void) config_block[0x28] | (config_block[0x29] << 8); global_settings.fade_on_stop=config_block[0xae]; - + global_settings.peak_meter_clip_hold = (config_block[0xb0]) & 0x1f; global_settings.peak_meter_performance = (config_block[0xb0] & 0x80) != 0; @@ -679,9 +682,9 @@ void settings_load(void) if (config_block[0xb7] != 0xff) global_settings.bidir_limit = config_block[0xb7]; - if (config_block[0xae] != 0xff) - global_settings.fade_on_stop = config_block[0xae]; - + if (config_block[0xae] != 0xff) + global_settings.fade_on_stop = config_block[0xae]; + memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4); memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); @@ -941,6 +944,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, "invert cursor")) + set_cfg_bool(&global_settings.invert_cursor, value); #endif else if (!strcasecmp(name, "shuffle")) set_cfg_bool(&global_settings.playlist_shuffle, value); @@ -1305,6 +1310,10 @@ bool settings_save_config(void) snprintf(buf, sizeof(buf), "invert: %s\r\n", options[global_settings.invert]); write(fd, buf, strlen(buf)); + + snprintf(buf, sizeof(buf), "invert cursor: %s\r\n", + options[global_settings.invert_cursor]); + write(fd, buf, strlen(buf)); } snprintf(buf, sizeof(buf), "peak meter release: %d\r\n", @@ -1463,6 +1472,7 @@ void settings_reset(void) { global_settings.invert = DEFAULT_INVERT_SETTING; global_settings.poweroff = DEFAULT_POWEROFF_SETTING; global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING; + global_settings.invert_cursor = DEFAULT_INVERT_CURSOR_SETTING; global_settings.backlight_on_when_charging = DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING; global_settings.battery_capacity = 1500; /* mAh */ @@ -1684,7 +1694,7 @@ bool set_option(char* string, int* variable, char* options[], #endif if ( *variable < (numoptions-1) ) (*variable)++; - else + else (*variable) -= (numoptions-1); break; diff --git a/apps/settings.h b/apps/settings.h index 9f5f233a90..7876a18afa 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -79,6 +79,8 @@ struct user_settings int contrast; /* lcd contrast: 0-63 0=low 63=high */ bool invert; /* invert display */ + bool invert_cursor; /* invert the current file in dir browser and menu + instead of using the default cursor */ int poweroff; /* power off timer */ int backlight_timeout; /* backlight off timeout: 0-18 0=never, 1=always, @@ -191,6 +193,7 @@ extern char rockboxdir[]; #endif #define MIN_CONTRAST_SETTING 5 #define DEFAULT_INVERT_SETTING false +#define DEFAULT_INVERT_CURSOR_SETTING false #define DEFAULT_POWEROFF_SETTING 0 #define DEFAULT_BACKLIGHT_TIMEOUT_SETTING 5 #define DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING 0 diff --git a/apps/settings_menu.c b/apps/settings_menu.c index c4d8c02c91..6f2fe28b91 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c @@ -59,6 +59,14 @@ static bool invert(void) return rc; } +static bool invert_cursor(void) +{ + bool rc = set_bool( str(LANG_INVERT_CURSOR), + &global_settings.invert_cursor); + + return rc; +} + /** * Menu to configure the battery display on status bar */ @@ -726,6 +734,7 @@ static bool display_settings_menu(void) { str(LANG_CONTRAST), contrast }, #ifdef HAVE_LCD_BITMAP { str(LANG_INVERT), invert }, + { str(LANG_INVERT_CURSOR), invert_cursor }, { str(LANG_PM_MENU), peak_meter_menu }, { str(LANG_VOLUME_DISPLAY), volume_type }, { str(LANG_BATTERY_DISPLAY), battery_type }, diff --git a/apps/tree.c b/apps/tree.c index 5a8618babb..a29cc5e420 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -107,7 +107,7 @@ void browse_root(void) the margins, so this is the amount of lines we add to the cursor Y position to position it on a line */ -#define CURSOR_WIDTH 4 +#define CURSOR_WIDTH (global_settings.invert_cursor ? 0 : 4) #define ICON_WIDTH 6 @@ -195,7 +195,13 @@ static void showfileline(int line, int direntry, bool scroll) *dotpos = 0; } if(scroll) - lcd_puts_scroll(LINE_X, line, dircache[direntry].name); +#ifdef HAVE_LCD_BITMAP + if (global_settings.invert_cursor) + lcd_puts_scroll_style(LINE_X, line, dircache[direntry].name, + STYLE_INVERT); + else +#endif + lcd_puts_scroll(LINE_X, line, dircache[direntry].name); else lcd_puts(LINE_X, line, dircache[direntry].name); if (temp) @@ -203,7 +209,13 @@ static void showfileline(int line, int direntry, bool scroll) } else { if(scroll) - lcd_puts_scroll(LINE_X, line, dircache[direntry].name); +#ifdef HAVE_LCD_BITMAP + if (global_settings.invert_cursor) + lcd_puts_scroll_style(LINE_X, line, dircache[direntry].name, + STYLE_INVERT); + else +#endif + lcd_puts_scroll(LINE_X, line, dircache[direntry].name); else lcd_puts(LINE_X, line, dircache[direntry].name); } @@ -666,6 +678,11 @@ static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen) int dircursor = *dc; char buf[MAX_PATH]; +#ifdef HAVE_LCD_BITMAP + int fw, fh; + lcd_getstringsize("A", &fw, &fh); +#endif + while (!exit) { switch (button_get(true)) { case TREE_PREV: @@ -717,8 +734,19 @@ static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen) break; } if ( used && !exit ) { +#ifdef HAVE_LCD_BITMAP + int xpos,ypos; +#endif showdir(currdir, dirstart); - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); +#ifdef HAVE_LCD_BITMAP + if (global_settings.invert_cursor) { + xpos = lcd_getxmargin(); + ypos = (CURSOR_Y + dircursor) * fh + lcd_getymargin(); + lcd_invertrect(xpos, ypos, LCD_WIDTH-xpos, fh); + } + else +#endif + put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); lcd_update(); } } @@ -1020,8 +1048,7 @@ bool dirbrowse(char *root) { if (dircursor + dirstart + 1 < numentries ) { if(dircursor+1 < tree_max_on_screen) { - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, - false); + put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); dircursor++; put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } @@ -1034,8 +1061,7 @@ bool dirbrowse(char *root) } else { if(numentries < tree_max_on_screen) { - put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, - false); + put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); dirstart = dircursor = 0; put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 6665ea88dc..fcb7d306b8 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c @@ -81,6 +81,7 @@ struct scrollinfo { int starty; bool backward; /* scroll presently forward or backward? */ bool bidir; + bool invert; /* invert the scrolled text */ long start_tick; }; @@ -270,6 +271,11 @@ int lcd_getstringsize(unsigned char *str, int *w, int *h) /* put a string at a given char position */ void lcd_puts(int x, int y, unsigned char *str) { + lcd_puts_style(x, y, str, STYLE_DEFAULT); +} + +void lcd_puts_style(int x, int y, unsigned char *str, int style) +{ int xpos,ypos,w,h; #if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) @@ -294,6 +300,8 @@ void lcd_puts(int x, int y, unsigned char *str) ypos = ymargin + y*h; lcd_putsxy(xpos, ypos, str); lcd_clearrect(xpos + w, ypos, LCD_WIDTH - (xpos + w), h); + if (style & STYLE_INVERT) + lcd_invertrect(xpos, ypos, LCD_WIDTH - xpos, h); #if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) lcd_update(); @@ -670,14 +678,19 @@ void lcd_invertpixel(int x, int y) INVERT_PIXEL(x,y); } -void lcd_puts_scroll(int x, int y, unsigned char* string) +void lcd_puts_scroll(int x, int y, unsigned char *string) +{ + lcd_puts_scroll_style(x, y, string, STYLE_DEFAULT); +} + +void lcd_puts_scroll_style(int x, int y, unsigned char *string, int style) { struct scrollinfo* s; int w, h; int index; int free_index=0; - DEBUGF("puts_scroll: %s\n", string); + DEBUGF("puts_scroll_style: %s\n", string); for (index = 0; index < SCROLLABLE_LINES; index++) { s = &scroll[index]; @@ -698,8 +711,14 @@ void lcd_puts_scroll(int x, int y, unsigned char* string) index=free_index; s = &scroll[index]; /* get the proper 's' */ s->start_tick = current_tick + scroll_delay; + s->invert = false; + if (style & STYLE_INVERT) { + s->invert = true; + lcd_puts_style(x,y,string,STYLE_INVERT); + } + else + lcd_puts(x,y,string); - lcd_puts(x,y,string); lcd_getstringsize(string, &w, &h); if (LCD_WIDTH - x * 8 - xmargin < w) { @@ -819,6 +838,8 @@ static void scroll_thread(void) lcd_clearrect(xpos, ypos, LCD_WIDTH - xmargin, h); lcd_putsxyofs(xpos, ypos, s->offset, s->line); + if (s->invert) + lcd_invertrect(xpos, ypos, LCD_WIDTH - xmargin, h); lcd_update_rect(xpos, ypos, LCD_WIDTH - xmargin, h); } diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index 74bbcc304e..45d9296555 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -24,14 +24,20 @@ #include "sh7034.h" #include "config.h" +#define STYLE_DEFAULT 0 +#define STYLE_INVERT 1 + /* common functions */ extern void lcd_init(void); extern void lcd_clear_display(void); extern void lcd_backlight(bool on); extern void lcd_puts(int x, int y, unsigned char *string); +extern void lcd_puts_style(int x, int y, unsigned char *string, int style); extern void lcd_putc(int x, int y, unsigned short ch); extern void lcd_puts_scroll(int x, int y, unsigned char* string ); +extern void lcd_puts_scroll_style(int x, int y, unsigned char* string, + int style); extern void lcd_icon(int icon, bool enable); extern void lcd_stop_scroll(void); extern void lcd_scroll_speed( int speed ); |