summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-01 22:43:54 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-02 02:45:43 +0000
commitb5cb99a7bf3486ce7347dc06451f209b193d516c (patch)
tree9cbebc4c97a7e61d838e5a47928d9c43a78ad5f5
parent9ee618e8891638027d05114250190f215bc01a63 (diff)
downloadrockbox-b5cb99a7bf.tar.gz
rockbox-b5cb99a7bf.tar.bz2
rockbox-b5cb99a7bf.zip
For backlights that have a wide control, support skipping steps.
the rocker, x3ii, and x20 now take advantage of this, and fades are far faster now. Change-Id: Iceb1a5a6c1d1389c3fdb859b32016b5114a80a22
-rw-r--r--firmware/backlight-sw-fading.c22
-rw-r--r--firmware/export/config/agptekrocker.h3
-rw-r--r--firmware/export/config/xduoox20.h3
-rw-r--r--firmware/export/config/xduoox3ii.h3
4 files changed, 28 insertions, 3 deletions
diff --git a/firmware/backlight-sw-fading.c b/firmware/backlight-sw-fading.c
index c336d40458..ecd225667f 100644
--- a/firmware/backlight-sw-fading.c
+++ b/firmware/backlight-sw-fading.c
@@ -27,6 +27,10 @@
#include "backlight.h"
#include "backlight-sw-fading.h"
+#ifndef BRIGHTNESS_STEP
+#define BRIGHTNESS_STEP 1
+#endif
+
/* To adapt a target do:
* - make sure backlight_hw_on doesn't set the brightness to something other than
* the previous value (lowest brightness in most cases)
@@ -46,7 +50,14 @@ static bool _backlight_fade_up(void)
{
if (LIKELY(current_brightness < backlight_brightness))
{
+#if BRIGHTNESS_STEP == 1
backlight_hw_brightness(++current_brightness);
+#else
+ current_brightness += BRIGHTNESS_STEP;
+ if (current_brightness > MAX_BRIGHTNESS_SETTING)
+ current_brightness = MAX_BRIGHTNESS_SETTING;
+ backlight_hw_brightness(current_brightness);
+#endif
}
return(current_brightness >= backlight_brightness);
}
@@ -56,13 +67,24 @@ static bool _backlight_fade_down(void)
{
if (LIKELY(current_brightness > MIN_BRIGHTNESS_SETTING))
{
+#if BRIGHTNESS_STEP == 1
backlight_hw_brightness(--current_brightness);
+#else
+ current_brightness -= BRIGHTNESS_STEP;
+ if (current_brightness < MIN_BRIGHTNESS_SETTING)
+ current_brightness = MIN_BRIGHTNESS_SETTING;
+ backlight_hw_brightness(current_brightness);
+#endif
return false;
}
else
{
/* decrement once more, since backlight is off */
+#if BRIGHTNESS_STEP == 1
current_brightness--;
+#else
+ current_brightness=MIN_BRIGHTNESS_SETTING -1;
+#endif
backlight_hw_off();
return true;
}
diff --git a/firmware/export/config/agptekrocker.h b/firmware/export/config/agptekrocker.h
index 90fd2267fe..c688513137 100644
--- a/firmware/export/config/agptekrocker.h
+++ b/firmware/export/config/agptekrocker.h
@@ -51,10 +51,11 @@
#define HAVE_BACKLIGHT_BRIGHTNESS
/* Main LCD backlight brightness range and defaults: the backlight driver
- * has levels from 0 to 2555. But 0 is off so start at 1.
+ * has levels from 0 to 255. But 0 is off so start at 1.
*/
#define MIN_BRIGHTNESS_SETTING 1
#define MAX_BRIGHTNESS_SETTING 255
+#define BRIGHTNESS_STEP 5
#define DEFAULT_BRIGHTNESS_SETTING 70
/* Which backlight fading type? */
diff --git a/firmware/export/config/xduoox20.h b/firmware/export/config/xduoox20.h
index b90ebceb04..4a5b63bf38 100644
--- a/firmware/export/config/xduoox20.h
+++ b/firmware/export/config/xduoox20.h
@@ -48,10 +48,11 @@
#define HAVE_BACKLIGHT_BRIGHTNESS
/* Main LCD backlight brightness range and defaults: the backlight driver
- * has levels from 0 to 2555. But 0 is off so start at 1.
+ * has levels from 0 to 255. But 0 is off so start at 1.
*/
#define MIN_BRIGHTNESS_SETTING 1
#define MAX_BRIGHTNESS_SETTING 255
+#define BRIGHTNESS_STEP 5
#define DEFAULT_BRIGHTNESS_SETTING 70
/* Which backlight fading type? */
diff --git a/firmware/export/config/xduoox3ii.h b/firmware/export/config/xduoox3ii.h
index 9ad7b5884b..e2066e453c 100644
--- a/firmware/export/config/xduoox3ii.h
+++ b/firmware/export/config/xduoox3ii.h
@@ -48,10 +48,11 @@
#define HAVE_BACKLIGHT_BRIGHTNESS
/* Main LCD backlight brightness range and defaults: the backlight driver
- * has levels from 0 to 2555. But 0 is off so start at 1.
+ * has levels from 0 to 255. But 0 is off so start at 1.
*/
#define MIN_BRIGHTNESS_SETTING 1
#define MAX_BRIGHTNESS_SETTING 255
+#define BRIGHTNESS_STEP 5
#define DEFAULT_BRIGHTNESS_SETTING 70
/* Which backlight fading type? */