1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jens Arnold 2008-04-04 19:14:19 +00:00
parent 1b335ae961
commit 3183b9e534
2 changed files with 9 additions and 8 deletions

View file

@ -130,6 +130,7 @@ void grey_ub_scroll_down(int count);
/* flag definitions */ /* flag definitions */
#define _GREY_RUNNING 0x8000 /* greyscale overlay is running */ #define _GREY_RUNNING 0x8000 /* greyscale overlay is running */
#define _GREY_DEFERRED_UPDATE 0x4000 /* lcd_update() requested */ #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, /* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit,
* whichever is faster for the architecture) */ * whichever is faster for the architecture) */

View file

@ -242,10 +242,8 @@ static unsigned long _grey_get_pixel(int x, int y);
static void _timer_isr(void); static void _timer_isr(void);
#endif #endif
#if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR)
static bool backlight_state;
static void invert_gvalues(void) static void invert_gvalues(void)
{ {
unsigned char *val, *end; unsigned char *val, *end;
@ -339,11 +337,12 @@ static unsigned long _grey_get_pixel(int x, int y)
static void _timer_isr(void) static void _timer_isr(void)
{ {
#if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) #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(); invert_gvalues();
return; /* don't overload this timer slot */ return; /* don't overload this timer slot */
} }
@ -422,7 +421,7 @@ static void fill_gvalues(void)
unsigned data; unsigned data;
#if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR)
unsigned imask = backlight_state ? 0xff : 0; unsigned imask = (_grey_info.flags & _GREY_BACKLIGHT_ON) ? 0xff : 0;
#else #else
const unsigned imask = 0; const unsigned imask = 0;
#endif #endif
@ -561,7 +560,8 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size,
else else
{ {
#if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) #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 #endif
fill_gvalues(); fill_gvalues();
} }