summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2008-04-04 19:14:19 +0000
committerJens Arnold <amiconn@rockbox.org>2008-04-04 19:14:19 +0000
commit3183b9e534eba4ca07ffaa68895e63177b5d8761 (patch)
tree5c4cc061f28140503d7b93d3ac1c4f9589a646d4
parent1b335ae96136951b6caf12405fd28f7d99912a45 (diff)
Greyscale library: Put the backlight status on 1st/2nd Gen into the flags, saving a separate global.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16964 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/lib/grey.h1
-rw-r--r--apps/plugins/lib/grey_core.c16
2 files changed, 9 insertions, 8 deletions
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h
index 3d5e6d16c4..3f7be44522 100644
--- a/apps/plugins/lib/grey.h
+++ b/apps/plugins/lib/grey.h
@@ -130,6 +130,7 @@ void grey_ub_scroll_down(int count);
/* flag definitions */
#define _GREY_RUNNING 0x8000 /* greyscale overlay is running */
#define _GREY_DEFERRED_UPDATE 0x4000 /* lcd_update() requested */
+#define _GREY_BACKLIGHT_ON 0x2000 /* backlight is active - only used on 1st+2nd Gen */
/* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit,
* whichever is faster for the architecture) */
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c
index 6b196e1aaf..5125d77432 100644
--- a/apps/plugins/lib/grey_core.c
+++ b/apps/plugins/lib/grey_core.c
@@ -242,10 +242,8 @@ static unsigned long _grey_get_pixel(int x, int y);
static void _timer_isr(void);
#endif
-#if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR)
-static bool backlight_state;
-
+#if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR)
static void invert_gvalues(void)
{
unsigned char *val, *end;
@@ -339,11 +337,12 @@ static unsigned long _grey_get_pixel(int x, int y)
static void _timer_isr(void)
{
#if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR)
- bool bls = _grey_info.rb->is_backlight_on(true);
+ unsigned long check = _grey_info.rb->is_backlight_on(true)
+ ? 0 : _GREY_BACKLIGHT_ON;
- if ((backlight_state != bls) && !(_grey_info.flags & GREY_RAWMAPPED))
+ if ((_grey_info.flags & (_GREY_BACKLIGHT_ON|GREY_RAWMAPPED)) == check)
{
- backlight_state = bls;
+ _grey_info.flags ^= _GREY_BACKLIGHT_ON;
invert_gvalues();
return; /* don't overload this timer slot */
}
@@ -422,7 +421,7 @@ static void fill_gvalues(void)
unsigned data;
#if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR)
- unsigned imask = backlight_state ? 0xff : 0;
+ unsigned imask = (_grey_info.flags & _GREY_BACKLIGHT_ON) ? 0xff : 0;
#else
const unsigned imask = 0;
#endif
@@ -561,7 +560,8 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
else
{
#if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR)
- backlight_state = _grey_info.rb->is_backlight_on(true);
+ if (_grey_info.rb->is_backlight_on(true))
+ _grey_info.flags |= _GREY_BACKLIGHT_ON;
#endif
fill_gvalues();
}