From 3183b9e534eba4ca07ffaa68895e63177b5d8761 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Fri, 4 Apr 2008 19:14:19 +0000 Subject: 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 --- apps/plugins/lib/grey.h | 1 + apps/plugins/lib/grey_core.c | 16 ++++++++-------- 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(); } -- cgit v1.2.3