diff options
-rw-r--r-- | apps/plugin.c | 7 | ||||
-rw-r--r-- | apps/plugin.h | 10 | ||||
-rw-r--r-- | apps/plugins/clock/clock_settings.c | 4 | ||||
-rw-r--r-- | apps/plugins/demystify.c | 19 | ||||
-rw-r--r-- | apps/plugins/lib/helper.c | 56 | ||||
-rw-r--r-- | apps/plugins/lib/helper.h | 4 | ||||
-rw-r--r-- | apps/plugins/rockblox.c | 3 | ||||
-rw-r--r-- | apps/plugins/rocklife.c | 5 |
8 files changed, 71 insertions, 37 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 9b620b1280..9067097591 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -525,6 +525,13 @@ static const struct plugin_api rockbox_api = { file_exists, dir_exists, + +#ifdef HAVE_REMOTE_LCD + remote_backlight_set_timeout, +#if CONFIG_CHARGING + remote_backlight_set_timeout_plugged, +#endif +#endif /* HAVE_REMOTE_LCD */ }; int plugin_load(const char* plugin, void* parameter) diff --git a/apps/plugin.h b/apps/plugin.h index 0aacd4e5fa..9105932485 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -113,7 +113,7 @@ #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 90 +#define PLUGIN_API_VERSION 91 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any @@ -648,7 +648,13 @@ struct plugin_api { bool (*file_exists)(const char *file); bool (*dir_exists)(const char *path); - + +#ifdef HAVE_REMOTE_LCD + void (*remote_backlight_set_timeout)(int index); +#if CONFIG_CHARGING + void (*remote_backlight_set_timeout_plugged)(int index); +#endif +#endif /* HAVE_REMOTE_LCD */ }; /* plugin header */ diff --git a/apps/plugins/clock/clock_settings.c b/apps/plugins/clock/clock_settings.c index b59a265a3b..fddea57c34 100644 --- a/apps/plugins/clock/clock_settings.c +++ b/apps/plugins/clock/clock_settings.c @@ -78,11 +78,11 @@ void clock_settings_reset(struct clock_settings* settings){ void apply_backlight_setting(int backlight_setting) { if(backlight_setting == ALWAS_OFF) - rb->backlight_set_timeout(0); + rb->backlight_set_timeout(-1); else if(backlight_setting == ROCKBOX_SETTING) rb->backlight_set_timeout(rb->global_settings->backlight_timeout); else if(backlight_setting == ALWAYS_ON) - rb->backlight_set_timeout(1); + rb->backlight_set_timeout(0); } void clock_settings_skin_next(struct clock_settings* settings){ diff --git a/apps/plugins/demystify.c b/apps/plugins/demystify.c index 3164eefb23..580783f18d 100644 --- a/apps/plugins/demystify.c +++ b/apps/plugins/demystify.c @@ -23,6 +23,7 @@ #ifdef HAVE_LCD_BITMAP #include "pluginlib_actions.h" +#include "helper.h" PLUGIN_HEADER #define DEFAULT_WAIT_TIME 3 @@ -255,9 +256,9 @@ void cleanup(void *parameter) { (void)parameter; - rb->screens[SCREEN_MAIN]->backlight_set_timeout(rb->global_settings->backlight_timeout); -#if NB_SCREENS==2 - rb->screens[SCREEN_REMOTE]->backlight_set_timeout(rb->global_settings->remote_backlight_timeout); + backlight_use_settings(rb); +#ifdef HAVE_REMOTE_LCD + remote_backlight_use_settings(rb); #endif } @@ -428,16 +429,14 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) int ret; rb = api; /* copy to global api pointer */ + (void)parameter; #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); #endif - (void)parameter; - if (rb->global_settings->backlight_timeout > 0) - { - int i; - FOR_NB_SCREENS(i) - rb->screens[i]->backlight_set_timeout(1);/* keep the light on */ - } + backlight_force_on(rb); /* backlight control in lib/helper.c */ +#ifdef HAVE_REMOTE_LCD + remote_backlight_force_on(rb); /* remote backlight control in lib/helper.c */ +#endif ret = plugin_main(); return ret; diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c index 0151a36c6c..2feff14a22 100644 --- a/apps/plugins/lib/helper.c +++ b/apps/plugins/lib/helper.c @@ -19,37 +19,55 @@ #include "plugin.h" -/* - * force the backlight on - * now enabled regardless of HAVE_BACKLIGHT because it is not needed to - * build and makes modded targets easier to update - */ +/* Force the backlight on */ void backlight_force_on(struct plugin_api* rb) { - if(!rb) return; -/* #ifdef HAVE_BACKLIGHT */ + if(!rb) + return; if (rb->global_settings->backlight_timeout > 0) rb->backlight_set_timeout(0); #if CONFIG_CHARGING if (rb->global_settings->backlight_timeout_plugged > 0) rb->backlight_set_timeout_plugged(0); #endif /* CONFIG_CHARGING */ -/* #endif */ /* HAVE_BACKLIGHT */ -} +} -/* - * reset backlight operation to its settings - * now enabled regardless of HAVE_BACKLIGHT because it is not needed to - * build and makes modded targets easier to update - */ +/* Reset backlight operation to its settings */ void backlight_use_settings(struct plugin_api* rb) { - if(!rb) return; -/* #ifdef HAVE_BACKLIGHT */ + if (!rb) + return; rb->backlight_set_timeout(rb->global_settings->backlight_timeout); #if CONFIG_CHARGING - rb->backlight_set_timeout_plugged(rb->global_settings-> \ - backlight_timeout_plugged); + rb->backlight_set_timeout_plugged(rb->global_settings-> + backlight_timeout_plugged); +#endif /* CONFIG_CHARGING */ +} + +#ifdef HAVE_REMOTE_LCD +/* Force the backlight on */ +void remote_backlight_force_on(struct plugin_api* rb) +{ + if (!rb) + return; + if (rb->global_settings->remote_backlight_timeout > 0) + rb->remote_backlight_set_timeout(0); +#if CONFIG_CHARGING + if (rb->global_settings->remote_backlight_timeout_plugged > 0) + rb->remote_backlight_set_timeout_plugged(0); +#endif /* CONFIG_CHARGING */ +} + +/* Reset backlight operation to its settings */ +void remote_backlight_use_settings(struct plugin_api* rb) +{ + if (!rb) + return; + rb->remote_backlight_set_timeout(rb->global_settings-> + remote_backlight_timeout); +#if CONFIG_CHARGING + rb->remote_backlight_set_timeout_plugged(rb->global_settings-> + remote_backlight_timeout_plugged); #endif /* CONFIG_CHARGING */ -/* #endif */ /* HAVE_BACKLIGHT */ } +#endif /* HAVE_REMOTE_LCD */ diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h index f2f5f8761b..744ad4dbd3 100644 --- a/apps/plugins/lib/helper.h +++ b/apps/plugins/lib/helper.h @@ -26,5 +26,9 @@ */ void backlight_force_on(struct plugin_api* rb); void backlight_use_settings(struct plugin_api* rb); +#ifdef HAVE_REMOTE_LCD +void remote_backlight_force_on(struct plugin_api* rb); +void remote_backlight_use_settings(struct plugin_api* rb); +#endif #endif diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index 10c6100b26..64c9485bd0 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c @@ -1118,8 +1118,7 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter) #endif /* Save user's HighScore */ highscore_save(HIGH_SCORE,Highest,MAX_HIGH_SCORES); - /* Restore user's original backlight setting */ - rb->backlight_set_timeout (rb->global_settings->backlight_timeout); + backlight_use_settings(rb); /* backlight control in lib/helper.c */ return ret; } diff --git a/apps/plugins/rocklife.c b/apps/plugins/rocklife.c index f881d88526..14856638e2 100644 --- a/apps/plugins/rocklife.c +++ b/apps/plugins/rocklife.c @@ -60,6 +60,7 @@ #include "plugin.h" #include "pluginlib_actions.h" +#include "helper.h" PLUGIN_HEADER @@ -405,7 +406,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) (void)parameter; rb = api; - rb->backlight_set_timeout(1); + backlight_force_on(rb); /* backlight control in lib/helper.c */ #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); rb->lcd_set_background(LCD_DEFAULT_BG); @@ -482,7 +483,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) rb->yield(); } - rb->backlight_set_timeout(rb->global_settings->backlight_timeout); + backlight_use_settings(rb); /* backlight control in lib/helper.c */ return PLUGIN_OK; } |