plugins: More HAVE_BACKLIGHT cleanup

Change-Id: I70cf700f5bc3d4375c025efa62ef40fd2bd70293
This commit is contained in:
Solomon Peachy 2020-07-24 19:20:15 -04:00
parent 2127906384
commit 9be5bc4cf0
30 changed files with 149 additions and 44 deletions

View file

@ -148,7 +148,9 @@ 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 */
@ -698,7 +700,9 @@ 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();
}

View file

@ -2526,9 +2526,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();
@ -2557,8 +2558,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;
}

View file

@ -21,8 +21,6 @@
#include "plugin.h"
#include "lib/playback_control.h"
/* variable button definitions */
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
(CONFIG_KEYPAD == IRIVER_H300_PAD)
@ -636,15 +634,19 @@ static int run_timer(int nr)
rb->lcd_puts(0, FIRST_LINE+1, (unsigned char *)"ROUND UP!");
else
rb->lcd_puts(0, FIRST_LINE+1, (unsigned char *)"TIME OUT!");
#ifdef HAVE_BACKLIGHT
rb->backlight_on();
#endif
ticks = max_ticks;
} else {
now=*rb->current_tick;
if (!chesspause) {
ticks+=now-last_tick;
if ((max_ticks-ticks)/HZ == 10) {
/* Backlight on if 10 seconds remain */
#ifdef HAVE_BACKLIGHT
/* Backlight on if 10 seconds remain */
rb->backlight_on();
#endif
}
}
last_tick=now;

View file

@ -262,10 +262,12 @@ 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
@ -436,9 +438,11 @@ 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();

View file

@ -722,7 +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
@ -736,8 +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

View file

@ -277,8 +277,10 @@ 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
}
@ -366,8 +368,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);

View file

@ -358,7 +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);
@ -522,9 +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

View file

@ -1025,8 +1025,10 @@ 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);
@ -1053,8 +1055,10 @@ 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 */

View file

@ -1899,8 +1899,9 @@ enum plugin_status plugin_start(UNUSED const void* parameter)
{
rb->lcd_setfont(FONT_SYSFIXED);
/* Turn off backlight timeout */
#ifdef HAVE_BACKLIGHT
backlight_ignore_timeout();
#endif
/* now go ahead and have fun! */
game_loop();
@ -1916,8 +1917,9 @@ enum plugin_status plugin_start(UNUSED const void* parameter)
/* Restore user's original backlight setting */
rb->lcd_setfont(FONT_UI);
/* Turn on backlight timeout (revert to settings) */
#ifdef HAVE_BACKLIGHT
backlight_use_settings();
#endif
return PLUGIN_OK;
}

View file

@ -2687,8 +2687,10 @@ static int lrc_main(void)
vp_lyrics[i].height -= h;
}
#ifdef HAVE_BACKLIGHT
if (prefs.backlight_on)
backlight_ignore_timeout();
#endif
/* in case settings that may affect break position
* are changed (statusbar_on and wrap). */
@ -2780,8 +2782,10 @@ static int lrc_main(void)
FOR_NB_SCREENS(i)
rb->viewportmanager_theme_undo(i, false);
#ifdef HAVE_BACKLIGHT
if (prefs.backlight_on)
backlight_use_settings();
#endif
return ret;
}

View file

@ -498,8 +498,10 @@ 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);
@ -589,6 +591,8 @@ 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);
}

View file

@ -256,7 +256,9 @@ 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
@ -270,9 +272,10 @@ 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);

View file

@ -1204,8 +1204,10 @@ 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
@ -1213,8 +1215,10 @@ 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
}
}

View file

@ -1929,9 +1929,10 @@ 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)))
@ -1964,8 +1965,10 @@ 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();
}

View file

@ -768,9 +768,11 @@ enum plugin_status plugin_start(const void* parameter)
the settings have changed when we quit */
old_settings = settings;
#ifdef HAVE_BACKLIGHT
/*Turn off backlight for ai*/
if(settings.ai)
backlight_ignore_timeout();
#endif
/* Initialise the hardware */
init_PacmanMachine(settings_to_dip(settings));
@ -803,8 +805,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;
}

View file

@ -138,8 +138,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
@ -317,9 +319,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

View file

@ -747,8 +747,10 @@ 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();
@ -787,8 +789,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;
}

View file

@ -574,7 +574,9 @@ 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;
@ -766,7 +768,10 @@ static void led_resistance_calc(void)
break;
default:
quit = true;
#ifdef HAVE_BACKLIGHT
backlight_use_settings();
#endif
break;
}
}
@ -779,7 +784,9 @@ 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;
@ -903,7 +910,9 @@ static void resistance_to_color(void)
break;
default:
quit = true;
#ifdef HAVE_BACKLIGHT
backlight_use_settings();
#endif
break;
}
}
@ -915,7 +924,9 @@ 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;
@ -984,7 +995,9 @@ static void color_to_resistance(void)
case PLA_SELECT:
default:
quit = true;
#ifdef HAVE_BACKLIGHT
backlight_use_settings();
#endif
break;
}
}

View file

@ -1505,14 +1505,16 @@ 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 ();
@ -1682,8 +1684,10 @@ 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;
@ -1731,7 +1735,9 @@ 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;
}

View file

@ -83,8 +83,9 @@ 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();
@ -138,9 +139,10 @@ 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;
}

View file

@ -594,9 +594,10 @@ 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
@ -607,7 +608,9 @@ 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();

View file

@ -473,7 +473,9 @@ 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
@ -577,6 +579,8 @@ enum plugin_status plugin_start(const void* parameter)
rb->yield();
}
#ifdef HAVE_BACKLIGHT
backlight_use_settings();
#endif
return usb? PLUGIN_USB_CONNECTED: PLUGIN_OK;
}

View file

@ -64,8 +64,9 @@ 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
@ -218,8 +219,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);

View file

@ -2125,8 +2125,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);
@ -2138,8 +2140,10 @@ 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;
}

View file

@ -141,7 +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 */
@ -300,7 +302,9 @@ 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);

View file

@ -324,13 +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;
}

View file

@ -189,10 +189,12 @@ enum plugin_status plugin_start(const void* parameter)
return PLUGIN_OK;
}
update_screen();
#ifdef HAVE_BACKLIGHT
#ifdef HAVE_REMOTE_LCD
rb->remote_backlight_on();
#endif
rb->backlight_on();
#endif
rb->splash(HZ, "Done");
update_screen();
while (1) {

View file

@ -2415,9 +2415,10 @@ 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();
@ -2425,8 +2426,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;
}

View file

@ -1303,9 +1303,10 @@ 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()) {
@ -1315,8 +1316,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);

View file

@ -121,7 +121,9 @@ 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)
@ -425,7 +427,9 @@ 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));