summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang5
-rw-r--r--apps/settings.c12
-rw-r--r--apps/settings.h1
-rw-r--r--apps/settings_menu.c29
-rw-r--r--firmware/drivers/button.c47
-rw-r--r--firmware/export/button.h3
-rw-r--r--uisimulator/common/lcd-common.c4
-rw-r--r--uisimulator/common/stubs.c5
8 files changed, 99 insertions, 7 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index ce2b300d8c..ffdc12b306 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1842,3 +1842,8 @@ id: LANG_MOVE_FAILED
1842desc: Error message displayed in playlist viewer 1842desc: Error message displayed in playlist viewer
1843eng: "Move failed" 1843eng: "Move failed"
1844new: 1844new:
1845
1846id: LANG_FLIP_DISPLAY
1847desc: in settings_menu, option to turn display+buttos by 180 degreed
1848eng: "Upside Down"
1849new:
diff --git a/apps/settings.c b/apps/settings.c
index 3c56257db4..b2fa22170b 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -103,6 +103,7 @@ offset abs
1030x1a 0x2e <time until disk spindown> 1030x1a 0x2e <time until disk spindown>
1040x1b 0x2f <browse current, play selected, recursive dir insert> 1040x1b 0x2f <browse current, play selected, recursive dir insert>
1050x1c 0x30 <peak meter hold timeout (bit 0-4), 1050x1c 0x30 <peak meter hold timeout (bit 0-4),
106 flip_display (bit 6)
106 rec_editable (bit 7)> 107 rec_editable (bit 7)>
1070x1d 0x31 <(int) Resume shuffle seed, or -1 if no shuffle> 1080x1d 0x31 <(int) Resume shuffle seed, or -1 if no shuffle>
1080x21 0x35 <repeat mode (bit 0-1), rec. channels (bit 2), 1090x21 0x35 <repeat mode (bit 0-1), rec. channels (bit 2),
@@ -362,6 +363,7 @@ int settings_save( void )
362 ((global_settings.recursive_dir_insert & 3) << 2)); 363 ((global_settings.recursive_dir_insert & 3) << 2));
363 364
364 config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold | 365 config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold |
366 (global_settings.flip_display ? 0x40 : 0) |
365 (global_settings.rec_editable?0x80:0); 367 (global_settings.rec_editable?0x80:0);
366 368
367 memcpy(&config_block[0x1d], &global_settings.resume_seed, 4); 369 memcpy(&config_block[0x1d], &global_settings.resume_seed, 4);
@@ -516,6 +518,9 @@ void settings_apply(void)
516 518
517#ifdef HAVE_LCD_BITMAP 519#ifdef HAVE_LCD_BITMAP
518 lcd_set_invert_display(global_settings.invert); 520 lcd_set_invert_display(global_settings.invert);
521 lcd_set_flip(global_settings.flip_display);
522 button_set_flip(global_settings.flip_display);
523 lcd_update(); /* refresh after flipping the screen */
519 settings_apply_pm_range(); 524 settings_apply_pm_range();
520 peak_meter_init_times( 525 peak_meter_init_times(
521 global_settings.peak_meter_release, global_settings.peak_meter_hold, 526 global_settings.peak_meter_release, global_settings.peak_meter_hold,
@@ -660,6 +665,8 @@ void settings_load(void)
660 665
661 if (config_block[0x1c] != 0xFF) { 666 if (config_block[0x1c] != 0xFF) {
662 global_settings.peak_meter_hold = (config_block[0x1c]) & 0x1f; 667 global_settings.peak_meter_hold = (config_block[0x1c]) & 0x1f;
668 global_settings.flip_display =
669 (config_block[0x1c] & 0x40)?true:false;
663 global_settings.rec_editable = 670 global_settings.rec_editable =
664 (config_block[0x1c] & 0x80)?true:false; 671 (config_block[0x1c] & 0x80)?true:false;
665 } 672 }
@@ -970,6 +977,8 @@ bool settings_load_config(char* file)
970 set_cfg_bool(&global_settings.scrollbar, value); 977 set_cfg_bool(&global_settings.scrollbar, value);
971 else if (!strcasecmp(name, "invert")) 978 else if (!strcasecmp(name, "invert"))
972 set_cfg_bool(&global_settings.invert, value); 979 set_cfg_bool(&global_settings.invert, value);
980 else if (!strcasecmp(name, "flip diplay"))
981 set_cfg_bool(&global_settings.flip_display, value);
973 else if (!strcasecmp(name, "invert cursor")) 982 else if (!strcasecmp(name, "invert cursor"))
974 set_cfg_bool(&global_settings.invert_cursor, value); 983 set_cfg_bool(&global_settings.invert_cursor, value);
975 else if (!strcasecmp(name, "show icons")) 984 else if (!strcasecmp(name, "show icons"))
@@ -1295,6 +1304,8 @@ bool settings_save_config(void)
1295#ifdef HAVE_LCD_BITMAP 1304#ifdef HAVE_LCD_BITMAP
1296 fprintf(fd, "invert: %s\r\n", boolopt[global_settings.invert]); 1305 fprintf(fd, "invert: %s\r\n", boolopt[global_settings.invert]);
1297 1306
1307 fprintf(fd, "flip display: %s\r\n", boolopt[global_settings.flip_display]);
1308
1298 fprintf(fd, "invert cursor: %s\r\n", 1309 fprintf(fd, "invert cursor: %s\r\n",
1299 boolopt[global_settings.invert_cursor]); 1310 boolopt[global_settings.invert_cursor]);
1300 1311
@@ -1446,6 +1457,7 @@ void settings_reset(void) {
1446 global_settings.resume = RESUME_ASK; 1457 global_settings.resume = RESUME_ASK;
1447 global_settings.contrast = lcd_default_contrast(); 1458 global_settings.contrast = lcd_default_contrast();
1448 global_settings.invert = DEFAULT_INVERT_SETTING; 1459 global_settings.invert = DEFAULT_INVERT_SETTING;
1460 global_settings.flip_display= false;
1449 global_settings.poweroff = DEFAULT_POWEROFF_SETTING; 1461 global_settings.poweroff = DEFAULT_POWEROFF_SETTING;
1450 global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING; 1462 global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING;
1451 global_settings.invert_cursor = DEFAULT_INVERT_CURSOR_SETTING; 1463 global_settings.invert_cursor = DEFAULT_INVERT_CURSOR_SETTING;
diff --git a/apps/settings.h b/apps/settings.h
index b96f4c6410..074be0690a 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -92,6 +92,7 @@ struct user_settings
92 bool invert; /* invert display */ 92 bool invert; /* invert display */
93 bool invert_cursor; /* invert the current file in dir browser and menu 93 bool invert_cursor; /* invert the current file in dir browser and menu
94 instead of using the default cursor */ 94 instead of using the default cursor */
95 bool flip_display; /* turn display (and button layout) by 180 degrees */
95 int poweroff; /* power off timer */ 96 int poweroff; /* power off timer */
96 int backlight_timeout; /* backlight off timeout: 0-18 0=never, 97 int backlight_timeout; /* backlight off timeout: 0-18 0=never,
97 1=always, 98 1=always,
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index c26aa125a2..c3932f3264 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -107,6 +107,20 @@ static bool invert_cursor(void)
107} 107}
108 108
109/** 109/**
110 * Menu to turn the display+buttons by 180 degrees
111 */
112static bool flip_display(void)
113{
114 bool rc = set_bool( str(LANG_FLIP_DISPLAY),
115 &global_settings.flip_display);
116
117 button_set_flip(global_settings.flip_display);
118 lcd_set_flip(global_settings.flip_display);
119
120 return rc;
121}
122
123/**
110 * Menu to configure the battery display on status bar 124 * Menu to configure the battery display on status bar
111 */ 125 */
112static bool battery_type(void) 126static bool battery_type(void)
@@ -362,7 +376,7 @@ static bool peak_meter_menu(void)
362 { str(LANG_PM_MAX) , peak_meter_max }, 376 { str(LANG_PM_MAX) , peak_meter_max },
363 }; 377 };
364 378
365 m=menu_init( items, sizeof items / sizeof(struct menu_items) ); 379 m=menu_init( items, sizeof(items) / sizeof(*items) );
366 result = menu_run(m); 380 result = menu_run(m);
367 menu_exit(m); 381 menu_exit(m);
368 return result; 382 return result;
@@ -757,7 +771,7 @@ static bool playback_settings_menu(void)
757 771
758 bool old_shuffle = global_settings.playlist_shuffle; 772 bool old_shuffle = global_settings.playlist_shuffle;
759 773
760 m=menu_init( items, sizeof items / sizeof(struct menu_items) ); 774 m=menu_init( items, sizeof(items) / sizeof(*items) );
761 result = menu_run(m); 775 result = menu_run(m);
762 menu_exit(m); 776 menu_exit(m);
763 777
@@ -836,7 +850,7 @@ static bool fileview_settings_menu(void)
836 { str(LANG_FOLLOW), browse_current }, 850 { str(LANG_FOLLOW), browse_current },
837 }; 851 };
838 852
839 m = menu_init( items, sizeof items / sizeof(struct menu_items) ); 853 m=menu_init( items, sizeof(items) / sizeof(*items) );
840 result = menu_run(m); 854 result = menu_run(m);
841 menu_exit(m); 855 menu_exit(m);
842 return result; 856 return result;
@@ -861,7 +875,7 @@ static bool scroll_settings_menu(void)
861#endif 875#endif
862 }; 876 };
863 877
864 m = menu_init( items, sizeof items / sizeof(struct menu_items) ); 878 m=menu_init( items, sizeof(items) / sizeof(*items) );
865 result = menu_run(m); 879 result = menu_run(m);
866 menu_exit(m); 880 menu_exit(m);
867 return result; 881 return result;
@@ -884,6 +898,7 @@ static bool display_settings_menu(void)
884 { str(LANG_STATUS_BAR), status_bar }, 898 { str(LANG_STATUS_BAR), status_bar },
885 { str(LANG_INVERT), invert }, 899 { str(LANG_INVERT), invert },
886 { str(LANG_INVERT_CURSOR), invert_cursor }, 900 { str(LANG_INVERT_CURSOR), invert_cursor },
901 { str(LANG_FLIP_DISPLAY), flip_display },
887 { str(LANG_PM_MENU), peak_meter_menu }, 902 { str(LANG_PM_MENU), peak_meter_menu },
888 { str(LANG_VOLUME_DISPLAY), volume_type }, 903 { str(LANG_VOLUME_DISPLAY), volume_type },
889 { str(LANG_BATTERY_DISPLAY), battery_type }, 904 { str(LANG_BATTERY_DISPLAY), battery_type },
@@ -892,7 +907,7 @@ static bool display_settings_menu(void)
892 { str(LANG_CAPTION_BACKLIGHT), caption_backlight }, 907 { str(LANG_CAPTION_BACKLIGHT), caption_backlight },
893 }; 908 };
894 909
895 m=menu_init( items, sizeof items / sizeof(struct menu_items) ); 910 m=menu_init( items, sizeof(items) / sizeof(*items) );
896 result = menu_run(m); 911 result = menu_run(m);
897 menu_exit(m); 912 menu_exit(m);
898 return result; 913 return result;
@@ -929,7 +944,7 @@ static bool system_settings_menu(void)
929 { str(LANG_RESET), reset_settings }, 944 { str(LANG_RESET), reset_settings },
930 }; 945 };
931 946
932 m=menu_init( items, sizeof items / sizeof(struct menu_items) ); 947 m=menu_init( items, sizeof(items) / sizeof(*items) );
933 result = menu_run(m); 948 result = menu_run(m);
934 menu_exit(m); 949 menu_exit(m);
935 return result; 950 return result;
@@ -954,7 +969,7 @@ bool settings_menu(void)
954 { str(LANG_SAVE_SETTINGS), settings_save_config }, 969 { str(LANG_SAVE_SETTINGS), settings_save_config },
955 }; 970 };
956 971
957 m = menu_init( items, sizeof items / sizeof(struct menu_items) ); 972 m=menu_init( items, sizeof(items) / sizeof(*items) );
958 result = menu_run(m); 973 result = menu_run(m);
959 menu_exit(m); 974 menu_exit(m);
960 return result; 975 return result;
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index c0cd046db6..cfe98e298a 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -34,6 +34,9 @@
34struct event_queue button_queue; 34struct event_queue button_queue;
35 35
36long last_keypress; 36long last_keypress;
37#ifdef HAVE_RECORDER_KEYPAD
38static bool flipped; /* bottons can be flipped to match the LCD flip */
39#endif
37 40
38/* how often we check to see if a button is pressed */ 41/* how often we check to see if a button is pressed */
39#define POLL_FREQUENCY HZ/20 42#define POLL_FREQUENCY HZ/20
@@ -212,6 +215,47 @@ void button_init()
212#endif 215#endif
213 queue_init(&button_queue); 216 queue_init(&button_queue);
214 tick_add_task(button_tick); 217 tick_add_task(button_tick);
218 last_keypress = current_tick;
219 flipped = false;
220}
221
222
223/*
224 * set the flip attribute
225 * better only call this when the queue is empty
226 */
227void button_set_flip(bool flip)
228{
229 flipped = flip;
230}
231
232
233/*
234 * helper function to swap UP/DOWN, LEFT/RIGHT, F1/F3
235 */
236static int button_flip(int button)
237{
238 int newbutton;
239
240 newbutton = button &
241 ~(BUTTON_UP | BUTTON_DOWN
242 | BUTTON_LEFT | BUTTON_RIGHT
243 | BUTTON_F1 | BUTTON_F3);
244
245 if (button & BUTTON_UP)
246 newbutton |= BUTTON_DOWN;
247 if (button & BUTTON_DOWN)
248 newbutton |= BUTTON_UP;
249 if (button & BUTTON_LEFT)
250 newbutton |= BUTTON_RIGHT;
251 if (button & BUTTON_RIGHT)
252 newbutton |= BUTTON_LEFT;
253 if (button & BUTTON_F1)
254 newbutton |= BUTTON_F3;
255 if (button & BUTTON_F3)
256 newbutton |= BUTTON_F1;
257
258 return newbutton;
215} 259}
216 260
217/* 261/*
@@ -276,6 +320,9 @@ static int button_read(void)
276#endif 320#endif
277 } 321 }
278 } 322 }
323
324 if (btn && flipped)
325 return button_flip(btn); /* swap upside down */
279 326
280 return btn; 327 return btn;
281} 328}
diff --git a/firmware/export/button.h b/firmware/export/button.h
index 8500adaeb8..efe3684473 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -29,6 +29,9 @@ extern long last_keypress;
29void button_init (void); 29void button_init (void);
30int button_get (bool block); 30int button_get (bool block);
31int button_get_w_tmo(int ticks); 31int button_get_w_tmo(int ticks);
32#ifdef HAVE_RECORDER_KEYPAD
33void button_set_flip(bool flip); /* turn 180 degrees */
34#endif
32 35
33#define BUTTON_NONE 0x0000 36#define BUTTON_NONE 0x0000
34 37
diff --git a/uisimulator/common/lcd-common.c b/uisimulator/common/lcd-common.c
index 719c61b488..0b0d3e0716 100644
--- a/uisimulator/common/lcd-common.c
+++ b/uisimulator/common/lcd-common.c
@@ -41,3 +41,7 @@ void lcd_blit(unsigned char* p_data, int x, int y, int width, int height,
41 (void)stride; 41 (void)stride;
42} 42}
43 43
44void lcd_set_flip(bool yesno)
45{
46 (void)yesno;
47} \ No newline at end of file
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index d3e5189d49..533b909786 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -220,3 +220,8 @@ void cpu_sleep(bool enabled)
220{ 220{
221 (void)enabled; 221 (void)enabled;
222} 222}
223
224void button_set_flip(bool yesno)
225{
226 (void)yesno;
227}