From 97a82ee3eca1be69bd2d08e8fd9db09c0807ae5d Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 23 Nov 2022 23:00:29 -0500 Subject: [PATCH] plugins HAVE_BACKLIGHT helper remove ifdefs in favor of dummy functions lessen the ifdef hell Change-Id: I52f830284e4599f3fc3a75c27dda27058b8de1a3 --- apps/plugins/2048.c | 5 +-- apps/plugins/brickmania.c | 8 ++--- apps/plugins/chopper.c | 8 ++--- apps/plugins/credits.c | 8 ++--- apps/plugins/demystify.c | 12 +++---- apps/plugins/doom/rockdoom.c | 8 ++--- apps/plugins/fft/fft.c | 6 ++-- apps/plugins/fire.c | 6 ++-- apps/plugins/fireworks.c | 8 ++--- apps/plugins/imageviewer/imageviewer.c | 4 --- apps/plugins/lamp.c | 15 +++----- apps/plugins/lib/helper.c | 48 ++++++++++++++++++++++---- apps/plugins/lib/helper.h | 10 ------ apps/plugins/maze.c | 5 +-- apps/plugins/mazezam.c | 5 +-- apps/plugins/mpegplayer/mpegplayer.c | 5 +-- apps/plugins/oscilloscope.c | 6 ++-- apps/plugins/pacbox/pacbox.c | 4 +-- apps/plugins/pictureflow/pictureflow.c | 3 +- apps/plugins/plasma.c | 8 ++--- apps/plugins/pong.c | 7 ++-- apps/plugins/puzzles/rockbox.c | 4 --- apps/plugins/resistor.c | 18 ++++------ apps/plugins/rockblox.c | 11 ++---- apps/plugins/rockboy/menu.c | 6 ++-- apps/plugins/rockboy/rockboy.c | 5 +-- apps/plugins/rocklife.c | 6 ++-- apps/plugins/sdl/main.c | 7 ++-- apps/plugins/spacerocks.c | 7 ++-- apps/plugins/speedread.c | 7 ++-- apps/plugins/starfield.c | 8 ++--- apps/plugins/test_disk.c | 6 ++-- apps/plugins/test_fps.c | 8 ++--- apps/plugins/test_gfx.c | 8 ++--- apps/plugins/test_grey.c | 8 ++--- apps/plugins/wormlet.c | 7 ++-- apps/plugins/xobox.c | 7 ++-- apps/plugins/xworld/sys.c | 6 ++-- 38 files changed, 140 insertions(+), 178 deletions(-) diff --git a/apps/plugins/2048.c b/apps/plugins/2048.c index 2633753071..456f973aef 100644 --- a/apps/plugins/2048.c +++ b/apps/plugins/2048.c @@ -148,9 +148,7 @@ static inline int rand_range(int min, int max) /* prepares for exit */ static void cleanup(void) { -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif } /* returns 2 or 4 */ @@ -700,9 +698,8 @@ static void init_game(bool newgame) max_numeral_width = rb->font_get_width(rb->font_get(WHAT_FONT), '0'); #endif -#ifdef HAVE_BACKLIGHT backlight_ignore_timeout(); -#endif + draw(); } diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 3e7ea27441..de65ce69e1 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c @@ -2533,10 +2533,10 @@ enum plugin_status plugin_start(const void* parameter) #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif -#ifdef HAVE_BACKLIGHT + /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + /* now go ahead and have fun! */ rb->srand( *rb->current_tick ); brickmania_loadgame(); @@ -2565,9 +2565,9 @@ enum plugin_status plugin_start(const void* parameter) configfile_save(CONFIG_FILE_NAME,config,1,0); /* Restore user's original backlight setting */ rb->lcd_setfont(FONT_UI); -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif + return PLUGIN_OK; } diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c index 392b840317..5c87e74e50 100644 --- a/apps/plugins/chopper.c +++ b/apps/plugins/chopper.c @@ -1083,10 +1083,10 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_set_foreground(LCD_WHITE); #endif -#ifdef HAVE_BACKLIGHT + /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + rb->srand( *rb->current_tick ); @@ -1098,10 +1098,10 @@ enum plugin_status plugin_start(const void* parameter) configfile_save(CFG_FILE, config, 1, 0); rb->lcd_setfont(FONT_UI); -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif + return ret; } diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c index 9e43aab2a7..efdcf42df1 100644 --- a/apps/plugins/credits.c +++ b/apps/plugins/credits.c @@ -303,10 +303,10 @@ enum plugin_status plugin_start(const void* parameter) { (void)parameter; -#ifdef HAVE_BACKLIGHT + /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + #if LCD_DEPTH>=16 rb->lcd_set_foreground (LCD_WHITE); @@ -318,10 +318,10 @@ enum plugin_status plugin_start(const void* parameter) if(!rb->action_userabort(3*HZ)) roll_credits(); -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif + return PLUGIN_OK; } diff --git a/apps/plugins/demystify.c b/apps/plugins/demystify.c index 74537e94f8..1a1505ff96 100644 --- a/apps/plugins/demystify.c +++ b/apps/plugins/demystify.c @@ -262,12 +262,10 @@ static void polygons_draw(struct polygon_fifo * polygons, struct screen * displa static void cleanup(void) { -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#ifdef HAVE_REMOTE_LCD remote_backlight_use_settings(); -#endif -#endif + } #ifdef HAVE_LCD_COLOR @@ -438,12 +436,10 @@ enum plugin_status plugin_start(const void* parameter) #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif -#ifdef HAVE_BACKLIGHT + backlight_ignore_timeout(); -#ifdef HAVE_REMOTE_LCD remote_backlight_ignore_timeout(); -#endif -#endif + ret = plugin_main(); return ret; diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c index 6594859c08..b68107f8aa 100644 --- a/apps/plugins/doom/rockdoom.c +++ b/apps/plugins/doom/rockdoom.c @@ -722,9 +722,9 @@ enum plugin_status plugin_start(const void* parameter) systemvol= rb->global_settings->volume-rb->global_settings->volume%mod; general_translucency = default_translucency; // phares -#ifdef HAVE_BACKLIGHT + backlight_ignore_timeout(); -#endif + #ifdef RB_PROFILE rb->profile_thread(); #endif @@ -738,9 +738,9 @@ enum plugin_status plugin_start(const void* parameter) #ifdef RB_PROFILE rb->profstop(); #endif -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#endif + M_SaveDefaults (); I_Quit(); // Make SURE everything was closed out right diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c index 35498227bf..f612a0ea35 100644 --- a/apps/plugins/fft/fft.c +++ b/apps/plugins/fft/fft.c @@ -1184,9 +1184,8 @@ static void fft_cleanup(void) #ifndef HAVE_LCD_COLOR grey_release(); #endif -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#endif /* save settings if changed */ if (rb->memcmp(&fft, &fft_disk, sizeof(fft))) @@ -1237,9 +1236,8 @@ static bool fft_setup(void) mylcd_clear_display(); myosd_lcd_update(); #endif -#ifdef HAVE_BACKLIGHT + backlight_ignore_timeout(); -#endif #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->trigger_cpu_boost(); diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c index f3e6fb35e4..43d10bf920 100644 --- a/apps/plugins/fire.c +++ b/apps/plugins/fire.c @@ -279,10 +279,9 @@ static void cleanup(void *parameter) #ifndef HAVE_LCD_COLOR grey_release(); #endif -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif } @@ -371,10 +370,9 @@ enum plugin_status plugin_start(const void* parameter) #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif -#ifdef HAVE_BACKLIGHT + /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) rb->lcd_set_mode(LCD_MODE_PAL256); diff --git a/apps/plugins/fireworks.c b/apps/plugins/fireworks.c index b7dad0d8ba..febd093e3f 100644 --- a/apps/plugins/fireworks.c +++ b/apps/plugins/fireworks.c @@ -358,9 +358,9 @@ enum plugin_status plugin_start(const void* parameter) /* set everything up.. no BL timeout, no backdrop, white-text-on-black-background. */ -#ifdef HAVE_BACKLIGHT + backlight_ignore_timeout(); -#endif + #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); rb->lcd_set_background(LCD_BLACK); @@ -524,10 +524,10 @@ enum plugin_status plugin_start(const void* parameter) break; } } -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif + #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); #endif diff --git a/apps/plugins/imageviewer/imageviewer.c b/apps/plugins/imageviewer/imageviewer.c index e30a98ef68..a8ef3efc97 100644 --- a/apps/plugins/imageviewer/imageviewer.c +++ b/apps/plugins/imageviewer/imageviewer.c @@ -1064,10 +1064,8 @@ enum plugin_status plugin_start(const void* parameter) ARRAYLEN(config), IMGVIEW_SETTINGS_MINVERSION); rb->memcpy(&old_settings, &settings, sizeof (settings)); -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); @@ -1094,10 +1092,8 @@ enum plugin_status plugin_start(const void* parameter) rb->storage_spindown(rb->global_settings->disk_spindown); #endif -#ifdef HAVE_BACKLIGHT /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif #ifdef USEGSLIB grey_release(); /* deinitialize */ diff --git a/apps/plugins/lamp.c b/apps/plugins/lamp.c index 6c9ae6626d..42a2353b2a 100644 --- a/apps/plugins/lamp.c +++ b/apps/plugins/lamp.c @@ -103,9 +103,8 @@ enum plugin_status plugin_start(const void* parameter) int current_brightness = MAX_BRIGHTNESS_SETTING; backlight_brightness_set(MAX_BRIGHTNESS_SETTING); #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ -#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS + buttonlight_brightness_set(MAX_BRIGHTNESS_SETTING); -#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ #ifdef HAVE_LCD_INVERT #ifdef HAVE_NEGATIVE_LCD @@ -116,9 +115,8 @@ enum plugin_status plugin_start(const void* parameter) #endif /* HAVE_LCD_INVERT */ backlight_force_on(); -#ifdef HAVE_BUTTON_LIGHT buttonlight_force_on(); -#endif /* HAVE_BUTTON_LIGHT */ + rb->lcd_clear_display(); rb->lcd_update(); @@ -207,20 +205,17 @@ enum plugin_status plugin_start(const void* parameter) /* restore */ backlight_use_settings(); -#ifdef HAVE_BUTTON_LIGHT + buttonlight_use_settings(); -#endif /* HAVE_BUTTON_LIGHT */ #ifdef HAVE_LCD_INVERT rb->lcd_set_invert_display(rb->global_settings->invert); #endif /* HAVE_LCD_INVERT */ -#ifdef HAVE_BACKLIGHT_BRIGHTNESS + backlight_brightness_use_setting(); -#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ -#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS + buttonlight_brightness_use_setting(); -#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ #if LCD_DEPTH > 1 rb->lcd_set_background(bg_color); diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c index 018c1616c8..92d9ec905e 100644 --- a/apps/plugins/lib/helper.c +++ b/apps/plugins/lib/helper.c @@ -58,7 +58,12 @@ void backlight_use_settings(void) backlight_timeout_plugged); #endif /* CONFIG_CHARGING */ } -#endif /* HAVE_BACKLIGHT */ +#else /* HAVE_BACKLIGHT */ +/* DUMMY FUNCTIONS */ +void backlight_force_on(void){} +void backlight_ignore_timeout(void){} +void backlight_use_settings(void){} +#endif /* !HAVE_BACKLIGHT */ #ifdef HAVE_SW_POWEROFF static bool original_sw_poweroff_state = true; @@ -73,7 +78,11 @@ void sw_poweroff_restore(void) { rb->button_set_sw_poweroff_state(original_sw_poweroff_state); } -#endif +#else /* HAVE_SW_POWEROFF */ +/* DUMMY FUNCTIONS */ +void sw_poweroff_disable(void){} +void sw_poweroff_restore(void){} +#endif /* !HAVE_SW_POWEROFF */ #ifdef HAVE_REMOTE_LCD /* Force the backlight on */ @@ -106,7 +115,12 @@ void remote_backlight_use_settings(void) remote_backlight_timeout_plugged); #endif /* CONFIG_CHARGING */ } -#endif /* HAVE_REMOTE_LCD */ +#else /* HAVE_REMOTE_LCD */ +/* DUMMY FUNCTIONS */ +void remote_backlight_force_on(void){} +void remote_backlight_ignore_timeout(void){} +void remote_backlight_use_settings(void){} +#endif /* !HAVE_REMOTE_LCD */ #ifdef HAVE_BUTTON_LIGHT /* Force the buttonlight on */ @@ -133,7 +147,13 @@ void buttonlight_use_settings(void) { rb->buttonlight_set_timeout(rb->global_settings->buttonlight_timeout); } -#endif /* HAVE_BUTTON_LIGHT */ +#else /* HAVE_BUTTON_LIGHT */ +/* DUMMY FUNCTIONS */ +void buttonlight_force_on(void){} +void buttonlight_force_off(void){} +void buttonlight_ignore_timeout(void){} +void buttonlight_use_settings(void){} +#endif /* !HAVE_BUTTON_LIGHT */ #ifdef HAVE_BACKLIGHT_BRIGHTNESS void backlight_brightness_set(int brightness) @@ -145,7 +165,15 @@ void backlight_brightness_use_setting(void) { rb->backlight_set_brightness(rb->global_settings->brightness); } -#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ +#else /* HAVE_BACKLIGHT_BRIGHTNESS */ +/* DUMMY FUNCTIONS */ +void backlight_brightness_set(int brightness) +{ + (void)brightness; +} +void backlight_brightness_use_setting(void){} + +#endif /* !HAVE_BACKLIGHT_BRIGHTNESS */ #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS void buttonlight_brightness_set(int brightness) @@ -157,4 +185,12 @@ void buttonlight_brightness_use_setting(void) { rb->buttonlight_set_brightness(rb->global_settings->buttonlight_brightness); } -#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ +#else /* HAVE_BUTTONLIGHT_BRIGHTNESS */ +/* DUMMY FUNCTIONS */ +void buttonlight_brightness_set(int brightness) +{ + (void)brightness; +} + +void buttonlight_brightness_use_setting(void){} +#endif /* !HAVE_BUTTONLIGHT_BRIGHTNESS */ diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h index 00ad8ac087..e59325d5d9 100644 --- a/apps/plugins/lib/helper.h +++ b/apps/plugins/lib/helper.h @@ -32,39 +32,29 @@ void backlight_force_on(void); void backlight_ignore_timeout(void); void backlight_use_settings(void); -#ifdef HAVE_SW_POWEROFF /** * Disable and restore software poweroff (i.e. holding PLAY on iPods). * Only call _restore() if _disable() was called earlier! */ void sw_poweroff_disable(void); void sw_poweroff_restore(void); -#endif -#ifdef HAVE_REMOTE_LCD void remote_backlight_force_on(void); void remote_backlight_ignore_timeout(void); void remote_backlight_use_settings(void); -#endif -#ifdef HAVE_BUTTON_LIGHT void buttonlight_force_on(void); void buttonlight_force_off(void); void buttonlight_ignore_timeout(void); void buttonlight_use_settings(void); -#endif /** * Backlight brightness adjustment settings */ -#ifdef HAVE_BACKLIGHT_BRIGHTNESS void backlight_brightness_set(int brightness); void backlight_brightness_use_setting(void); -#endif -#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS void buttonlight_brightness_set(int brightness); void buttonlight_brightness_use_setting(void); -#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ #endif /* _LIB_HELPER_H_ */ diff --git a/apps/plugins/maze.c b/apps/plugins/maze.c index 20d5c82495..8c951ebdcc 100644 --- a/apps/plugins/maze.c +++ b/apps/plugins/maze.c @@ -498,10 +498,8 @@ enum plugin_status plugin_start(const void* parameter) struct maze maze; (void)parameter; -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif /* Seed the RNG */ rb->srand(*rb->current_tick); @@ -591,8 +589,7 @@ enum plugin_status plugin_start(const void* parameter) #endif } /* Turn on backlight timeout (revert to settings) */ -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif + return ((quit == 1) ? PLUGIN_OK : PLUGIN_USB_CONNECTED); } diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c index cd7b6e22a8..423b09288d 100644 --- a/apps/plugins/mazezam.c +++ b/apps/plugins/mazezam.c @@ -256,9 +256,7 @@ static void store_lcd_settings(void) ******************************************************************************/ static void restore_lcd_settings(void) { /* Turn on backlight timeout (revert to settings) */ -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif /* Restore the old settings */ #if LCD_DEPTH > 1 @@ -272,10 +270,9 @@ static void restore_lcd_settings(void) { * Adjust the LCD settings to suit MazezaM levels ******************************************************************************/ static void plugin_lcd_settings(void) { -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + /* Set the new settings */ #ifdef HAVE_LCD_COLOR rb->lcd_set_background(MAZEZAM_BG_COLOR); diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index e66b4df146..654a348959 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -1215,10 +1215,9 @@ static void osd_lcd_enable_hook(unsigned short id, void* param) static void osdbacklight_hw_on_video_mode(bool video_on) { if (video_on) { -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) rb->remove_event(LCD_EVENT_ACTIVATION, osd_lcd_enable_hook); #endif @@ -1226,10 +1225,8 @@ static void osdbacklight_hw_on_video_mode(bool video_on) #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) rb->add_event(LCD_EVENT_ACTIVATION, osd_lcd_enable_hook); #endif -#ifdef HAVE_BACKLIGHT /* Revert to user's backlight settings */ backlight_use_settings(); -#endif } } diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c index ae84e14f7f..ef9e6b8a98 100644 --- a/apps/plugins/oscilloscope.c +++ b/apps/plugins/oscilloscope.c @@ -1939,10 +1939,9 @@ static void osc_cleanup(void) rb->lcd_set_foreground(LCD_DEFAULT_FG); rb->lcd_set_background(LCD_DEFAULT_BG); #endif -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif /* save settings if changed */ if (rb->memcmp(&osc, &osc_disk, sizeof(osc))) @@ -1975,10 +1974,9 @@ static void osc_setup(void) mixer_sampr = rb->mixer_get_frequency(); #endif -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + graphmode_setup(); } diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c index 71c9751cad..9434aed743 100755 --- a/apps/plugins/pacbox/pacbox.c +++ b/apps/plugins/pacbox/pacbox.c @@ -809,8 +809,8 @@ enum plugin_status plugin_start(const void* parameter) #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); #endif -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#endif + return PLUGIN_OK; } diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index cdc9641f5c..7670ef01df 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -3493,10 +3493,9 @@ static void cleanup(void) rb->cpu_boost(false); #endif end_pf_thread(); -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif #ifdef USEGSLIB grey_release(); diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c index f944d3d775..8da53874e1 100644 --- a/apps/plugins/plasma.c +++ b/apps/plugins/plasma.c @@ -140,10 +140,10 @@ static void cleanup(void) #ifndef HAVE_LCD_COLOR grey_release(); #endif -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif + #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) rb->lcd_set_mode(LCD_MODE_RGB565); #endif @@ -321,10 +321,10 @@ enum plugin_status plugin_start(const void* parameter) #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif -#ifdef HAVE_BACKLIGHT + /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) rb->lcd_set_mode(LCD_MODE_PAL256); #endif diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c index b49fec2459..17e6e6ed73 100644 --- a/apps/plugins/pong.c +++ b/apps/plugins/pong.c @@ -750,10 +750,9 @@ enum plugin_status plugin_start(const void* parameter) this to avoid the compiler warning about it */ (void)parameter; -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + /* Clear screen */ rb->lcd_clear_display(); @@ -792,9 +791,9 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_clear_display(); } } -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif + return (game == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED; } diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c index 563820ba23..e175429075 100644 --- a/apps/plugins/puzzles/rockbox.c +++ b/apps/plugins/puzzles/rockbox.c @@ -3390,9 +3390,7 @@ static void shutdown_tlsf(void) static void exit_handler(void) { -#ifdef HAVE_SW_POWEROFF sw_poweroff_restore(); -#endif unload_fonts(); shutdown_tlsf(); @@ -3652,9 +3650,7 @@ static void puzzles_main(void) { rb_atexit(exit_handler); -#ifdef HAVE_SW_POWEROFF sw_poweroff_disable(); -#endif init_default_settings(); init_fonttab(); diff --git a/apps/plugins/resistor.c b/apps/plugins/resistor.c index d32ac3fad9..4461dc0dea 100644 --- a/apps/plugins/resistor.c +++ b/apps/plugins/resistor.c @@ -574,9 +574,8 @@ static void display_helpfile(void) static void led_resistance_calc(void) { -#ifdef HAVE_BACKLIGHT backlight_ignore_timeout(); -#endif + int voltage_menu_selection, button_press, j, k, l, foreward_current = 0; int fwd_current_selection = 0; bool quit = false; @@ -769,9 +768,8 @@ static void led_resistance_calc(void) default: quit = true; -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif + break; } } @@ -784,9 +782,8 @@ static void led_resistance_calc(void) static void resistance_to_color(void) { -#ifdef HAVE_BACKLIGHT backlight_ignore_timeout(); -#endif + int menu_selection; int menu_selection_tol; int button_press; @@ -910,9 +907,9 @@ static void resistance_to_color(void) break; default: quit = true; -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#endif + break; } } @@ -924,9 +921,8 @@ static void resistance_to_color(void) static void color_to_resistance(void) { -#ifdef HAVE_BACKLIGHT backlight_ignore_timeout(); -#endif + bool quit = false; int button_input = 0; @@ -995,9 +991,7 @@ static void color_to_resistance(void) case PLA_SELECT: default: quit = true; -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif break; } } diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index 927710b37b..cc719e5067 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c @@ -1498,16 +1498,13 @@ static int rockblox_loop (void) #ifdef HAS_BUTTON_HOLD if (rb->button_hold ()) { /* Turn on backlight timeout (revert to settings) */ -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif rb->splash(0, "Paused"); while (rb->button_hold ()) rb->sleep(HZ/10); -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + /* get rid of the splash text */ rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT); show_details (); @@ -1677,10 +1674,9 @@ enum plugin_status plugin_start (const void *parameter) rb->lcd_setfont (FONT_SYSFIXED); -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + load_game(); resume_file = resume; @@ -1728,9 +1724,8 @@ enum plugin_status plugin_start (const void *parameter) /* Save user's HighScore */ highscore_save(SCORE_FILE, highscores, NUM_SCORES); -#ifdef HAVE_BACKLIGNT + backlight_use_settings(); -#endif return PLUGIN_OK; } diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index 6fafdc11a6..caa8d499cb 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c @@ -83,9 +83,8 @@ int do_user_menu(void) { rb->lcd_set_mode(LCD_MODE_RGB565); #endif -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif + /* Clean out the button Queue */ while (rb->button_get(false) != BUTTON_NONE) rb->yield(); @@ -139,10 +138,9 @@ int do_user_menu(void) { rb->lcd_set_mode(LCD_MODE_PAL256); #endif -#ifdef HAVE_BACKLIGHT /* ignore backlight time out */ backlight_ignore_timeout(); -#endif + return ret; } diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c index 2c5c6e4dbf..2d0c349507 100644 --- a/apps/plugins/rockboy/rockboy.c +++ b/apps/plugins/rockboy/rockboy.c @@ -602,10 +602,9 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_set_mode(LCD_MODE_PAL256); #endif -#ifdef HAVE_BACKLIGHT /* ignore backlight time out */ backlight_ignore_timeout(); -#endif + gnuboy_main(parameter); #ifdef HAVE_WHEEL_POSITION @@ -616,9 +615,7 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_set_mode(LCD_MODE_RGB565); #endif -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif if(!rb->audio_status()) rockboy_pcm_close(); diff --git a/apps/plugins/rocklife.c b/apps/plugins/rocklife.c index 99297abd0f..bed947cc71 100644 --- a/apps/plugins/rocklife.c +++ b/apps/plugins/rocklife.c @@ -474,9 +474,8 @@ enum plugin_status plugin_start(const void* parameter) char *ptemp; (void)(parameter); -#ifdef HAVE_BACKLIGHT backlight_ignore_timeout(); -#endif + #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #ifdef HAVE_LCD_COLOR @@ -580,8 +579,7 @@ enum plugin_status plugin_start(const void* parameter) rb->yield(); } -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif + return usb? PLUGIN_USB_CONNECTED: PLUGIN_OK; } diff --git a/apps/plugins/sdl/main.c b/apps/plugins/sdl/main.c index 6efb072faf..7220c7cfd9 100644 --- a/apps/plugins/sdl/main.c +++ b/apps/plugins/sdl/main.c @@ -64,9 +64,8 @@ void cleanup(void) if(audiobuf) memset(audiobuf, 0, 4); /* clear */ -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif + #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); #endif @@ -219,9 +218,9 @@ enum plugin_status plugin_start(const void *param) #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(true); #endif -#ifdef HAVE_BACKLIGHT + backlight_ignore_timeout(); -#endif + /* set the real exit handler */ #undef rb_atexit rb_atexit(cleanup); diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c index 1099672c4c..85beccb1c2 100644 --- a/apps/plugins/spacerocks.c +++ b/apps/plugins/spacerocks.c @@ -2128,10 +2128,10 @@ enum plugin_status plugin_start(const void* parameter) #endif /* universal font */ rb->lcd_setfont(FONT_SYSFIXED); -#ifdef HAVE_BACKLIGHT + /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + highscore_load(SCORE_FILE, highscores, NUM_SCORES); rb->srand(*rb->current_tick); @@ -2143,10 +2143,9 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_setfont(FONT_UI); highscore_save(SCORE_FILE, highscores, NUM_SCORES); -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif return ret; } diff --git a/apps/plugins/speedread.c b/apps/plugins/speedread.c index 42634fb536..55d8fd58e5 100644 --- a/apps/plugins/speedread.c +++ b/apps/plugins/speedread.c @@ -141,9 +141,9 @@ static void cleanup(void) { if(custom_font != FONT_UI) rb->font_unload(custom_font); -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#endif + } /* returns height of drawn area */ @@ -302,9 +302,8 @@ static void begin_anim(void) static void init_drawing(void) { -#ifdef HAVE_BACKLIGHT backlight_ignore_timeout(); -#endif + atexit(cleanup); rb->lcd_set_background(OUTSIDE_COLOR); diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c index 7fc400d0ee..39ed8a8171 100644 --- a/apps/plugins/starfield.c +++ b/apps/plugins/starfield.c @@ -324,14 +324,14 @@ enum plugin_status plugin_start(const void* parameter) int ret; (void)parameter; -#ifdef HAVE_BACKLIGHT + /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + ret = plugin_main(); -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif + return ret; } diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c index 1429668556..fee6c4d0b0 100644 --- a/apps/plugins/test_disk.c +++ b/apps/plugins/test_disk.c @@ -467,10 +467,9 @@ enum plugin_status plugin_start(const void* parameter) rb->srand(*rb->current_tick); -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + while(!quit) { @@ -489,9 +488,8 @@ enum plugin_status plugin_start(const void* parameter) } /* Turn on backlight timeout (revert to settings) */ -#ifdef HAVE_BACKLIGHT backlight_use_settings(); -#endif + rb->rmdir(testbasedir); return PLUGIN_OK; diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c index ddf938ac25..2f4e9bb13e 100644 --- a/apps/plugins/test_fps.c +++ b/apps/plugins/test_fps.c @@ -401,9 +401,9 @@ enum plugin_status plugin_start(const void* parameter) #if (CONFIG_PLATFORM & PLATFORM_NATIVE) cpu_freq = *rb->cpu_frequency; /* remember CPU frequency */ #endif -#ifdef HAVE_BACKLIGHT + backlight_ignore_timeout(); -#endif + time_main_update(); rb->sleep(HZ); #if defined(HAVE_LCD_COLOR) && (MEMORYSIZE > 2) @@ -424,9 +424,9 @@ enum plugin_status plugin_start(const void* parameter) (cpu_freq + 500000) / 1000000); log_text(str); #endif -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#endif + /* wait until user closes plugin */ plugin_quit(); diff --git a/apps/plugins/test_gfx.c b/apps/plugins/test_gfx.c index 7734179159..60e2836463 100644 --- a/apps/plugins/test_gfx.c +++ b/apps/plugins/test_gfx.c @@ -495,9 +495,9 @@ enum plugin_status plugin_start(const void* parameter) rb->lcd_set_backdrop(NULL); rb->lcd_clear_display(); #endif -#ifdef HAVE_BACKLIGHT + backlight_ignore_timeout(); -#endif + rb->splashf(0, "LCD driver performance test, please wait %d sec", 7*4*DURATION/HZ); init_rand_table(); @@ -522,9 +522,9 @@ enum plugin_status plugin_start(const void* parameter) (cpu_freq + 500000) / 1000000); #endif rb->close(log_fd); -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#endif + #ifdef TEST_GREYLIB grey_release(); #endif diff --git a/apps/plugins/test_grey.c b/apps/plugins/test_grey.c index 121cbad051..07fda1b9c6 100644 --- a/apps/plugins/test_grey.c +++ b/apps/plugins/test_grey.c @@ -123,9 +123,9 @@ enum plugin_status plugin_start(const void* parameter) } for (i = 0; i <= STEPS; i++) input_levels[i] = lcd_levels[i] = (255 * i + (STEPS/2)) / STEPS; -#ifdef HAVE_BACKLIGHT + backlight_ignore_timeout(); -#endif + grey_set_background(0); /* set background to black */ grey_clear_display(); grey_show(true); @@ -221,8 +221,8 @@ enum plugin_status plugin_start(const void* parameter) } grey_release(); -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#endif + return PLUGIN_OK; } diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c index 162cea6208..c09ef48bdc 100644 --- a/apps/plugins/wormlet.c +++ b/apps/plugins/wormlet.c @@ -2428,10 +2428,9 @@ static bool launch_wormlet(void) rb->lcd_clear_display(); -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + /* start the game */ while (game_result == 1) game_result = run(); @@ -2439,10 +2438,10 @@ static bool launch_wormlet(void) switch (game_result) { case 2: -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif + return false; break; } diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index b8b1964db4..c7499fed7a 100644 --- a/apps/plugins/xobox.c +++ b/apps/plugins/xobox.c @@ -1297,10 +1297,9 @@ enum plugin_status plugin_start (const void *parameter) rb->lcd_set_backdrop(NULL); #endif -#ifdef HAVE_BACKLIGHT /* Turn off backlight timeout */ backlight_ignore_timeout(); -#endif + highscore_load(SCORE_FILE, highscores, NUM_SCORES); if (!load_game()) { @@ -1310,10 +1309,10 @@ enum plugin_status plugin_start (const void *parameter) randomize (); ret = xobox_loop (); -#ifdef HAVE_BACKLIGHT + /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); -#endif + rb->lcd_setfont (FONT_UI); highscore_save(SCORE_FILE, highscores, NUM_SCORES); diff --git a/apps/plugins/xworld/sys.c b/apps/plugins/xworld/sys.c index a806de5297..ece9d87b66 100644 --- a/apps/plugins/xworld/sys.c +++ b/apps/plugins/xworld/sys.c @@ -122,9 +122,8 @@ void exit_handler(void) #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); #endif -#ifdef HAVE_BACKLIGHT + backlight_use_settings(); -#endif } static bool sys_do_help(void) @@ -428,9 +427,8 @@ void sys_menu(struct System* sys) void sys_init(struct System* sys, const char* title) { (void) title; -#ifdef HAVE_BACKLIGHT + backlight_ignore_timeout(); -#endif rb_atexit(exit_handler); save_sys = sys; rb->memset(&sys->input, 0, sizeof(sys->input));