2005-07-25 20:50:34 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Greyscale framework
|
|
|
|
* Parameter handling
|
|
|
|
*
|
2006-02-26 13:37:42 +00:00
|
|
|
* This is a generic framework to display up to 33 shades of grey
|
2006-08-07 01:46:42 +00:00
|
|
|
* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey, iPod 4-grey)
|
|
|
|
* within plugins.
|
2005-07-25 20:50:34 +00:00
|
|
|
*
|
2006-02-26 13:37:42 +00:00
|
|
|
* Copyright (C) 2004-2006 Jens Arnold
|
2005-07-25 20:50:34 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
2006-02-26 13:37:42 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-07-25 20:50:34 +00:00
|
|
|
#include "gray.h"
|
|
|
|
|
|
|
|
/* Set position of the top left corner of the greyscale overlay
|
2006-08-07 01:46:42 +00:00
|
|
|
Note that depending on the target LCD, either x or y gets rounded
|
|
|
|
to the nearest multiple of 8 */
|
|
|
|
void gray_set_position(int x, int y)
|
2005-07-25 20:50:34 +00:00
|
|
|
{
|
2006-08-07 01:46:42 +00:00
|
|
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
|
|
|
_gray_info.bx = (x + 3) / 8;
|
|
|
|
x = 8 * _gray_info.bx;
|
|
|
|
#else
|
|
|
|
_gray_info.by = (y + 3) / 8;
|
|
|
|
y = 8 * _gray_info.by;
|
|
|
|
#endif
|
2005-07-25 20:50:34 +00:00
|
|
|
_gray_info.x = x;
|
2006-08-07 01:46:42 +00:00
|
|
|
_gray_info.y = y;
|
2005-07-25 20:50:34 +00:00
|
|
|
|
|
|
|
if (_gray_info.flags & _GRAY_RUNNING)
|
2006-02-26 13:37:42 +00:00
|
|
|
{
|
|
|
|
#ifdef SIMULATOR
|
|
|
|
gray_deferred_lcd_update();
|
|
|
|
gray_update();
|
|
|
|
#else
|
2005-07-25 20:50:34 +00:00
|
|
|
_gray_info.flags |= _GRAY_DEFERRED_UPDATE;
|
2006-02-26 13:37:42 +00:00
|
|
|
#endif
|
|
|
|
}
|
2005-07-25 20:50:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the draw mode for subsequent drawing operations */
|
|
|
|
void gray_set_drawmode(int mode)
|
|
|
|
{
|
|
|
|
_gray_info.drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the current draw mode */
|
|
|
|
int gray_get_drawmode(void)
|
|
|
|
{
|
|
|
|
return _gray_info.drawmode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the foreground shade for subsequent drawing operations */
|
2005-11-16 21:09:23 +00:00
|
|
|
void gray_set_foreground(unsigned brightness)
|
2005-07-25 20:50:34 +00:00
|
|
|
{
|
2006-08-02 00:22:01 +00:00
|
|
|
_gray_info.fg_brightness = brightness;
|
|
|
|
_gray_info.fg_index = _gray_info.idxtable[brightness];
|
2005-07-25 20:50:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the current foreground shade */
|
2005-11-16 21:09:23 +00:00
|
|
|
unsigned gray_get_foreground(void)
|
2005-07-25 20:50:34 +00:00
|
|
|
{
|
2006-08-02 00:22:01 +00:00
|
|
|
return _gray_info.fg_brightness;
|
2005-07-25 20:50:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the background shade for subsequent drawing operations */
|
2005-11-16 21:09:23 +00:00
|
|
|
void gray_set_background(unsigned brightness)
|
2005-07-25 20:50:34 +00:00
|
|
|
{
|
2006-08-02 00:22:01 +00:00
|
|
|
_gray_info.bg_brightness = brightness;
|
|
|
|
_gray_info.bg_index = _gray_info.idxtable[brightness];
|
2005-07-25 20:50:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the current background shade */
|
2005-11-16 21:09:23 +00:00
|
|
|
unsigned gray_get_background(void)
|
2005-07-25 20:50:34 +00:00
|
|
|
{
|
2006-08-02 00:22:01 +00:00
|
|
|
return _gray_info.bg_brightness;
|
2005-07-25 20:50:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set draw mode, foreground and background shades at once */
|
2005-11-16 21:09:23 +00:00
|
|
|
void gray_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness)
|
2005-07-25 20:50:34 +00:00
|
|
|
{
|
|
|
|
gray_set_drawmode(mode);
|
|
|
|
gray_set_foreground(fg_brightness);
|
|
|
|
gray_set_background(bg_brightness);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set font for the text output routines */
|
|
|
|
void gray_setfont(int newfont)
|
|
|
|
{
|
|
|
|
_gray_info.curfont = newfont;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get width and height of a text when printed with the current font */
|
|
|
|
int gray_getstringsize(const unsigned char *str, int *w, int *h)
|
|
|
|
{
|
|
|
|
return _gray_rb->font_getstringsize(str, w, h, _gray_info.curfont);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|