2002-03-28 15:09:10 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Alan Korr
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __LCD_H__
|
|
|
|
#define __LCD_H__
|
|
|
|
|
2002-05-13 12:29:34 +00:00
|
|
|
#include <stdbool.h>
|
2004-10-26 05:40:24 +00:00
|
|
|
#include "cpu.h"
|
2002-04-18 17:42:42 +00:00
|
|
|
#include "config.h"
|
2002-03-28 15:09:10 +00:00
|
|
|
|
2003-04-16 00:12:31 +00:00
|
|
|
#define STYLE_DEFAULT 0
|
|
|
|
#define STYLE_INVERT 1
|
|
|
|
|
2005-02-22 12:19:12 +00:00
|
|
|
#ifdef SIMULATOR
|
|
|
|
#define lcd_icon(x,y) sim_lcd_icon(x,y)
|
2006-01-25 12:15:25 +00:00
|
|
|
#ifndef MAX_PATH
|
2005-06-23 16:53:54 +00:00
|
|
|
#define MAX_PATH 260
|
2006-01-25 12:15:25 +00:00
|
|
|
#endif
|
2005-06-23 16:53:54 +00:00
|
|
|
#else
|
|
|
|
#include "file.h" /* for MAX_PATH; FIXME: Why does this not work for sims? */
|
2005-02-22 12:19:12 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-14 20:43:49 +00:00
|
|
|
#if LCD_DEPTH <=8
|
|
|
|
typedef unsigned char fb_data;
|
|
|
|
#elif LCD_DEPTH <= 16
|
|
|
|
typedef unsigned short fb_data;
|
|
|
|
#endif
|
|
|
|
|
2002-04-25 15:09:03 +00:00
|
|
|
/* common functions */
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_write_command(int byte);
|
|
|
|
extern void lcd_write_command_ex(int cmd, int data1, int data2);
|
2005-11-14 20:43:49 +00:00
|
|
|
extern void lcd_write_data(const fb_data* p_bytes, int count);
|
2002-04-25 15:09:03 +00:00
|
|
|
extern void lcd_init(void);
|
2005-11-10 01:08:09 +00:00
|
|
|
#ifdef SIMULATOR
|
|
|
|
/* Define a dummy device specific init for the sims */
|
|
|
|
#define lcd_init_device()
|
|
|
|
#else
|
|
|
|
extern void lcd_init_device(void);
|
|
|
|
#endif
|
2002-04-25 15:09:03 +00:00
|
|
|
extern void lcd_backlight(bool on);
|
2005-06-23 16:53:54 +00:00
|
|
|
extern int lcd_default_contrast(void);
|
|
|
|
extern void lcd_set_contrast(int val);
|
|
|
|
|
|
|
|
extern void lcd_clear_display(void);
|
2004-08-01 21:50:57 +00:00
|
|
|
extern void lcd_puts(int x, int y, const unsigned char *string);
|
|
|
|
extern void lcd_puts_style(int x, int y, const unsigned char *string, int style);
|
2003-01-10 09:58:04 +00:00
|
|
|
extern void lcd_putc(int x, int y, unsigned short ch);
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_stop_scroll(void);
|
|
|
|
extern void lcd_scroll_speed(int speed);
|
|
|
|
extern void lcd_scroll_delay(int ms);
|
|
|
|
extern void lcd_puts_scroll(int x, int y, const unsigned char* string);
|
2004-08-16 23:37:23 +00:00
|
|
|
extern void lcd_puts_scroll_style(int x, int y, const unsigned char* string,
|
2003-04-16 00:12:31 +00:00
|
|
|
int style);
|
2002-07-22 22:37:03 +00:00
|
|
|
extern void lcd_icon(int icon, bool enable);
|
2002-05-21 08:50:46 +00:00
|
|
|
|
2002-05-24 09:03:08 +00:00
|
|
|
#if defined(SIMULATOR) || defined(HAVE_LCD_BITMAP)
|
2003-12-12 22:11:08 +00:00
|
|
|
/* performance function */
|
2005-11-14 20:43:49 +00:00
|
|
|
extern void lcd_blit(const fb_data* data, int x, int by, int width,
|
2005-06-28 23:15:47 +00:00
|
|
|
int bheight, int stride);
|
2002-08-09 12:20:54 +00:00
|
|
|
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_update(void);
|
2002-08-09 12:20:54 +00:00
|
|
|
/* update a fraction of the screen */
|
|
|
|
extern void lcd_update_rect(int x, int y, int width, int height);
|
2005-05-23 16:23:25 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
extern void lcd_remote_update(void);
|
|
|
|
/* update a fraction of the screen */
|
|
|
|
extern void lcd_remote_update_rect(int x, int y, int width, int height);
|
|
|
|
#endif
|
|
|
|
|
2002-05-21 08:50:46 +00:00
|
|
|
#else
|
|
|
|
#define lcd_update()
|
2002-09-10 08:42:03 +00:00
|
|
|
#define lcd_update_rect(x,y,w,h)
|
2002-05-21 08:50:46 +00:00
|
|
|
#endif
|
2002-04-25 15:09:03 +00:00
|
|
|
|
2002-04-11 12:35:54 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2002-07-22 22:37:03 +00:00
|
|
|
|
|
|
|
/* Icon definitions for lcd_icon() */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ICON_BATTERY = 0,
|
|
|
|
ICON_BATTERY_1,
|
|
|
|
ICON_BATTERY_2,
|
|
|
|
ICON_BATTERY_3,
|
|
|
|
ICON_USB,
|
|
|
|
ICON_PLAY,
|
|
|
|
ICON_RECORD,
|
|
|
|
ICON_PAUSE,
|
|
|
|
ICON_AUDIO,
|
|
|
|
ICON_REPEAT,
|
|
|
|
ICON_1,
|
|
|
|
ICON_VOLUME,
|
|
|
|
ICON_VOLUME_1,
|
|
|
|
ICON_VOLUME_2,
|
|
|
|
ICON_VOLUME_3,
|
|
|
|
ICON_VOLUME_4,
|
|
|
|
ICON_VOLUME_5,
|
|
|
|
ICON_PARAM
|
|
|
|
};
|
2002-04-11 12:35:54 +00:00
|
|
|
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_double_height(bool on);
|
|
|
|
extern void lcd_define_hw_pattern(int which,const char *pattern,int length);
|
|
|
|
extern void lcd_define_pattern(int which,const char *pattern);
|
2003-01-10 10:12:17 +00:00
|
|
|
unsigned char lcd_get_locked_pattern(void);
|
2003-01-10 09:58:04 +00:00
|
|
|
void lcd_unlock_pattern(unsigned char pat);
|
2003-01-27 14:37:03 +00:00
|
|
|
void lcd_put_cursor(int x, int y, char cursor_char);
|
2003-01-29 11:48:35 +00:00
|
|
|
void lcd_remove_cursor(void);
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_bidir_scroll(int threshold);
|
|
|
|
#define JUMP_SCROLL_ALWAYS 5
|
|
|
|
extern void lcd_jump_scroll(int mode); /* 0=off, 1=once, ..., ALWAYS */
|
|
|
|
extern void lcd_jump_scroll_delay(int ms);
|
2002-05-04 12:19:36 +00:00
|
|
|
#endif
|
2002-10-17 18:44:02 +00:00
|
|
|
|
2005-06-30 18:42:24 +00:00
|
|
|
/* Draw modes */
|
2005-06-24 22:33:21 +00:00
|
|
|
#define DRMODE_COMPLEMENT 0
|
|
|
|
#define DRMODE_BG 1
|
|
|
|
#define DRMODE_FG 2
|
|
|
|
#define DRMODE_SOLID 3
|
|
|
|
#define DRMODE_INVERSEVID 4 /* used as bit modifier for basic modes */
|
|
|
|
|
2005-06-30 18:42:24 +00:00
|
|
|
/* Low-level drawing function types */
|
2005-07-06 22:58:02 +00:00
|
|
|
typedef void lcd_pixelfunc_type(int x, int y);
|
2005-06-30 18:42:24 +00:00
|
|
|
typedef void lcd_blockfunc_type(unsigned char *address, unsigned mask, unsigned bits);
|
2005-11-28 10:05:45 +00:00
|
|
|
#if LCD_DEPTH >= 8
|
|
|
|
typedef void lcd_fastpixelfunc_type(fb_data *address);
|
|
|
|
#endif
|
2005-06-30 18:42:24 +00:00
|
|
|
|
2005-07-19 09:24:29 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
2005-11-07 23:07:19 +00:00
|
|
|
#if LCD_DEPTH == 16
|
2005-11-16 21:09:23 +00:00
|
|
|
#define LCD_MAX_RED 31
|
|
|
|
#define LCD_MAX_GREEN 63
|
|
|
|
#define LCD_MAX_BLUE 31
|
|
|
|
#define _RGBPACK(r, g, b) ( ((((r) * 31 + 127) / 255) << 11) \
|
|
|
|
|((((g) * 63 + 127) / 255) << 5) \
|
|
|
|
| (((b) * 31 + 127) / 255))
|
2005-11-19 02:06:46 +00:00
|
|
|
#if (LCD_PIXELFORMAT == RGB565SWAPPED)
|
2005-11-16 21:09:23 +00:00
|
|
|
#define LCD_RGBPACK(r, g, b) ( ((_RGBPACK((r), (g), (b)) & 0xff00) >> 8) \
|
|
|
|
|((_RGBPACK((r), (g), (b)) & 0x00ff) << 8))
|
2005-11-07 23:07:19 +00:00
|
|
|
#else
|
2005-11-16 21:09:23 +00:00
|
|
|
#define LCD_RGBPACK(r, g, b) _RGBPACK((r), (g), (b))
|
2005-11-07 23:07:19 +00:00
|
|
|
#endif
|
2005-11-16 21:09:23 +00:00
|
|
|
#else
|
|
|
|
/* other colour depths */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LCD_BLACK LCD_RGBPACK(0, 0, 0)
|
|
|
|
#define LCD_DARKGRAY LCD_RGBPACK(85, 85, 85)
|
|
|
|
#define LCD_LIGHTGRAY LCD_RGBPACK(170, 170, 170)
|
|
|
|
#define LCD_WHITE LCD_RGBPACK(255, 255, 255)
|
|
|
|
#define LCD_DEFAULT_FG LCD_BLACK
|
|
|
|
#define LCD_DEFAULT_BG LCD_RGBPACK(182, 198, 229) /* rockbox blue */
|
|
|
|
|
|
|
|
#elif LCD_DEPTH > 1 /* greyscale */
|
2005-07-19 09:24:29 +00:00
|
|
|
#define LCD_MAX_LEVEL ((1 << LCD_DEPTH) - 1)
|
2005-11-16 21:09:23 +00:00
|
|
|
#define LCD_BRIGHTNESS(y) (((y) * LCD_MAX_LEVEL + 127) / 255)
|
|
|
|
|
|
|
|
#define LCD_BLACK LCD_BRIGHTNESS(0)
|
|
|
|
#define LCD_DARKGRAY LCD_BRIGHTNESS(85)
|
|
|
|
#define LCD_LIGHTGRAY LCD_BRIGHTNESS(170)
|
|
|
|
#define LCD_WHITE LCD_BRIGHTNESS(255)
|
|
|
|
#define LCD_DEFAULT_FG LCD_BLACK
|
|
|
|
#define LCD_DEFAULT_BG LCD_WHITE
|
2005-07-19 09:24:29 +00:00
|
|
|
#endif
|
2005-06-30 18:42:24 +00:00
|
|
|
|
2005-06-23 16:53:54 +00:00
|
|
|
/* Memory copy of display bitmap */
|
2005-07-06 22:58:02 +00:00
|
|
|
#if LCD_DEPTH == 1
|
2005-11-14 20:43:49 +00:00
|
|
|
extern fb_data lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
|
2005-07-06 22:58:02 +00:00
|
|
|
#elif LCD_DEPTH == 2
|
2005-11-14 20:43:49 +00:00
|
|
|
extern fb_data lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH];
|
2005-11-07 23:07:19 +00:00
|
|
|
#elif LCD_DEPTH == 16
|
2005-11-14 20:43:49 +00:00
|
|
|
extern fb_data lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH];
|
2005-07-06 22:58:02 +00:00
|
|
|
#endif
|
2002-08-01 13:29:30 +00:00
|
|
|
|
2005-12-20 23:15:27 +00:00
|
|
|
#if CONFIG_BACKLIGHT==BL_IRIVER_H300
|
|
|
|
extern void lcd_enable(bool on);
|
|
|
|
#endif
|
|
|
|
|
2006-01-28 12:12:42 +00:00
|
|
|
/* Bitmap formats */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
FORMAT_MONO,
|
|
|
|
FORMAT_NATIVE,
|
|
|
|
FORMAT_ANY /* For passing to read_bmp_file() */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bitmap {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
int format;
|
|
|
|
#endif
|
|
|
|
unsigned char *data;
|
|
|
|
};
|
|
|
|
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_set_invert_display(bool yesno);
|
|
|
|
extern void lcd_set_flip(bool yesno);
|
|
|
|
extern void lcd_roll(int pixels);
|
2005-06-24 22:33:21 +00:00
|
|
|
|
|
|
|
extern void lcd_set_drawmode(int mode);
|
|
|
|
extern int lcd_get_drawmode(void);
|
2002-05-10 14:54:56 +00:00
|
|
|
extern void lcd_setmargins(int xmargin, int ymargin);
|
2002-08-20 19:33:55 +00:00
|
|
|
extern int lcd_getxmargin(void);
|
|
|
|
extern int lcd_getymargin(void);
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_setfont(int font);
|
|
|
|
extern int lcd_getstringsize(const unsigned char *str, int *w, int *h);
|
2005-06-24 22:33:21 +00:00
|
|
|
|
2006-01-22 01:42:05 +00:00
|
|
|
extern void lcd_puts_offset(int x, int y, const unsigned char *str, int offset);
|
|
|
|
extern void lcd_puts_style_offset(int x, int y, const unsigned char *str,
|
|
|
|
int style, int offset);
|
|
|
|
extern void lcd_puts_scroll_offset(int x, int y, const unsigned char *string,
|
|
|
|
int offset);
|
|
|
|
extern void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
|
|
|
|
int style, int offset);
|
|
|
|
|
2005-06-29 01:39:50 +00:00
|
|
|
/* low level drawing function pointer arrays */
|
2005-11-06 23:49:29 +00:00
|
|
|
extern lcd_pixelfunc_type* const lcd_pixelfuncs[8];
|
|
|
|
extern lcd_blockfunc_type* const lcd_blockfuncs[8];
|
2005-11-28 10:05:45 +00:00
|
|
|
#if LCD_DEPTH >= 8
|
|
|
|
extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs[8];
|
|
|
|
#endif
|
2005-06-29 01:39:50 +00:00
|
|
|
|
2002-04-25 13:45:23 +00:00
|
|
|
extern void lcd_drawpixel(int x, int y);
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_drawline(int x1, int y1, int x2, int y2);
|
2005-06-24 22:33:21 +00:00
|
|
|
extern void lcd_hline(int x1, int x2, int y);
|
|
|
|
extern void lcd_vline(int x, int y1, int y2);
|
|
|
|
extern void lcd_drawrect(int x, int y, int width, int height);
|
|
|
|
extern void lcd_fillrect(int x, int y, int width, int height);
|
2005-11-14 20:43:49 +00:00
|
|
|
extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
|
2005-06-28 23:15:47 +00:00
|
|
|
int stride, int x, int y, int width, int height);
|
2005-11-14 20:43:49 +00:00
|
|
|
extern void lcd_bitmap(const fb_data *src, int x, int y, int width,
|
2005-06-30 18:42:24 +00:00
|
|
|
int height);
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_putsxy(int x, int y, const unsigned char *string);
|
2005-06-24 22:33:21 +00:00
|
|
|
|
2005-06-23 16:53:54 +00:00
|
|
|
extern void lcd_invertscroll(int x, int y);
|
2002-12-12 15:20:37 +00:00
|
|
|
extern void lcd_bidir_scroll(int threshold);
|
|
|
|
extern void lcd_scroll_step(int pixels);
|
2002-09-20 08:07:51 +00:00
|
|
|
|
2005-07-06 22:58:02 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2005-11-16 21:09:23 +00:00
|
|
|
extern void lcd_set_foreground(unsigned foreground);
|
|
|
|
extern unsigned lcd_get_foreground(void);
|
|
|
|
extern void lcd_set_background(unsigned background);
|
|
|
|
extern unsigned lcd_get_background(void);
|
|
|
|
extern void lcd_set_drawinfo(int mode, unsigned foreground,
|
|
|
|
unsigned background);
|
|
|
|
|
2005-07-06 22:58:02 +00:00
|
|
|
extern void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
|
|
|
|
int stride, int x, int y, int width, int height);
|
|
|
|
extern void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width,
|
2005-07-14 18:11:36 +00:00
|
|
|
int height);
|
2005-07-06 22:58:02 +00:00
|
|
|
#else /* LCD_DEPTH == 1 */
|
|
|
|
#define lcd_mono_bitmap lcd_bitmap
|
|
|
|
#define lcd_mono_bitmap_part lcd_bitmap_part
|
|
|
|
#endif
|
|
|
|
|
2005-07-19 09:24:29 +00:00
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2002-04-11 12:45:06 +00:00
|
|
|
|
2005-06-23 16:53:54 +00:00
|
|
|
/* internal usage, but in multiple drivers */
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#define SCROLL_SPACING 3
|
|
|
|
|
|
|
|
struct scrollinfo {
|
|
|
|
char line[MAX_PATH + LCD_WIDTH/2 + SCROLL_SPACING + 2];
|
|
|
|
int len; /* length of line in chars */
|
|
|
|
int width; /* length of line in pixels */
|
|
|
|
int offset;
|
|
|
|
int startx;
|
|
|
|
bool backward; /* scroll presently forward or backward? */
|
|
|
|
bool bidir;
|
|
|
|
bool invert; /* invert the scrolled text */
|
|
|
|
long start_tick;
|
|
|
|
};
|
|
|
|
#else /* !HAVE_LCD_BITMAP */
|
|
|
|
|
|
|
|
struct scrollinfo {
|
|
|
|
int mode;
|
|
|
|
char text[MAX_PATH];
|
|
|
|
int textlen;
|
|
|
|
int offset;
|
|
|
|
int turn_offset;
|
|
|
|
int startx;
|
|
|
|
int starty;
|
|
|
|
long scroll_start_tick;
|
|
|
|
int direction; /* +1 for right or -1 for left*/
|
|
|
|
int jump_scroll;
|
|
|
|
int jump_scroll_steps;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2002-04-18 17:42:42 +00:00
|
|
|
#endif /* __LCD_H__ */
|