forked from len0rd/rockbox
Cleaned up lcd API
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@236 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4fbea7cf8b
commit
29db1a9e72
2 changed files with 219 additions and 272 deletions
|
@ -20,6 +20,8 @@
|
|||
#include "config.h"
|
||||
#include "lcd.h"
|
||||
|
||||
/*** definitions ***/
|
||||
|
||||
#define LCDR (PBDR+1)
|
||||
|
||||
/* PA14 : /LCD-BL --- backlight */
|
||||
|
@ -31,7 +33,7 @@
|
|||
#define LCD_CS 2 // PB1 = 1 --- 0010 --- /LCD-CS
|
||||
#define LCD_SD 4 // PB2 = 1 --- 0100 --- LCD-SD
|
||||
#define LCD_SC 8 // PB3 = 1 --- 1000 --- LCD-SC
|
||||
#ifndef JBP_OLD
|
||||
#ifdef HAVE_NEW_CHARCELL_LCD
|
||||
# define LCD_CONTRAST_SET ((char)0x50)
|
||||
# define LCD_CRAM ((char)0x80) /* Characters */
|
||||
# define LCD_PRAM ((char)0xC0) /* Patterns */
|
||||
|
@ -46,6 +48,56 @@
|
|||
#define LCD_CURSOR(x,y) ((char)(LCD_CRAM+((y)*16+(x))))
|
||||
#define LCD_ICON(i) ((char)(LCD_IRAM+i))
|
||||
|
||||
#elif HAVE_LCD_BITMAP
|
||||
|
||||
#define LCD_SD 1 // PB0 = 1 --- 0001
|
||||
#define LCD_SC 2 // PB1 = 1 --- 0010
|
||||
#define LCD_RS 4 // PB2 = 1 --- 0100
|
||||
#define LCD_CS 8 // PB3 = 1 --- 1000
|
||||
#define LCD_DS LCD_RS
|
||||
|
||||
#define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00)
|
||||
#define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10)
|
||||
#define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20)
|
||||
#define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28)
|
||||
#define LCD_SET_DISPLAY_START_LINE ((char)0x40)
|
||||
#define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81)
|
||||
#define LCD_SET_SEGMENT_REMAP ((char)0xA0)
|
||||
#define LCD_SET_LCD_BIAS ((char)0xA2)
|
||||
#define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4)
|
||||
#define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5)
|
||||
#define LCD_SET_NORMAL_DISPLAY ((char)0xA6)
|
||||
#define LCD_SET_REVERSE_DISPLAY ((char)0xA7)
|
||||
#define LCD_SET_INDICATOR_OFF ((char)0xAC)
|
||||
#define LCD_SET_INDICATOR_ON ((char)0xAD)
|
||||
#define LCD_SET_DISPLAY_OFF ((char)0xAE)
|
||||
#define LCD_SET_DISPLAY_ON ((char)0xAF)
|
||||
#define LCD_SET_PAGE_ADDRESS ((char)0xB0)
|
||||
#define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0)
|
||||
#define LCD_SET_DISPLAY_OFFSET ((char)0xD3)
|
||||
#define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0)
|
||||
#define LCD_SOFTWARE_RESET ((char)0xE2)
|
||||
#define LCD_NOP ((char)0xE3)
|
||||
#define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE)
|
||||
|
||||
/* LCD command codes */
|
||||
#define LCD_CNTL_RESET 0xe2 // Software reset
|
||||
#define LCD_CNTL_POWER 0x2f // Power control
|
||||
#define LCD_CNTL_CONTRAST 0x81 // Contrast
|
||||
#define LCD_CNTL_OUTSCAN 0xc8 // Output scan direction
|
||||
#define LCD_CNTL_SEGREMAP 0xa1 // Segment remap
|
||||
#define LCD_CNTL_DISPON 0xaf // Display on
|
||||
|
||||
#define LCD_CNTL_PAGE 0xb0 // Page address
|
||||
#define LCD_CNTL_HIGHCOL 0x10 // Upper column address
|
||||
#define LCD_CNTL_LOWCOL 0x00 // Lower column address
|
||||
|
||||
|
||||
#endif /* CHARCELL or BITMAP */
|
||||
|
||||
|
||||
/*** generic code ***/
|
||||
|
||||
#ifndef SIMULATOR
|
||||
/*
|
||||
* About /CS,DS,SC,SD
|
||||
|
@ -94,58 +146,20 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Enter a LCD session :
|
||||
*
|
||||
* LCDR &= ~(LCD_CS|LCD_DS|LCD_SD|LCD_SC);
|
||||
*/
|
||||
static void lcd_start (void)
|
||||
|
||||
|
||||
static void lcd_write(bool command, int byte)
|
||||
|
||||
#ifdef ASM_IMPLEMENTATION
|
||||
{
|
||||
lcd_start();
|
||||
|
||||
asm("and.b %0, @(r0,gbr)"
|
||||
:
|
||||
: /* %0 */ "I"(~(LCD_CS|LCD_DS|LCD_SD|LCD_SC)),
|
||||
/* %1 */ "z"(LCDR));
|
||||
}
|
||||
|
||||
/*
|
||||
* Leave a LCD session :
|
||||
*
|
||||
* LCDR |= LCD_CS|LCD_RS|LCD_SD|LCD_SC;
|
||||
*/
|
||||
static void lcd_stop (void)
|
||||
{
|
||||
asm
|
||||
("or.b\t%0,@(r0,gbr)"
|
||||
:
|
||||
: /* %0 */ "I"(LCD_CS|LCD_DS|LCD_SD|LCD_SC),
|
||||
/* %1 */ "z"(LCDR));
|
||||
}
|
||||
|
||||
static void lcd_byte (int byte,bool data)
|
||||
|
||||
/*
|
||||
* char j = 0x80;
|
||||
* if (rs)
|
||||
* do
|
||||
* {
|
||||
* LCDR &= ~(LCD_SC|LCD_SD);
|
||||
* if (j & byte)
|
||||
* LCDR |= LCD_SD;
|
||||
* LCDR |= LCD_SC|LCD_DS;
|
||||
* }
|
||||
* while ((unsigned char)j >>= 1);
|
||||
* else
|
||||
* do
|
||||
* {
|
||||
* LCDR &= ~(LCD_SC|LCD_SD|LCD_DS);
|
||||
* if (j & byte)
|
||||
* LCDR |= LCD_SD;
|
||||
* LCDR |= LCD_SC;
|
||||
* }
|
||||
* while ((unsigned char)j >>= 1);
|
||||
*/
|
||||
{
|
||||
if (data)
|
||||
if (command)
|
||||
asm ("shll8 %0\n"
|
||||
"0: \n\t"
|
||||
"and.b %2,@(r0,gbr)\n\t"
|
||||
|
@ -165,18 +179,17 @@ static void lcd_byte (int byte,bool data)
|
|||
/* %4 */ "I"(LCD_SC|LCD_DS),
|
||||
/* %5 */ "z"(LCDR));
|
||||
else
|
||||
asm
|
||||
("shll8\t%0\n"
|
||||
"0:\n\t"
|
||||
"and.b\t%2,@(r0,gbr)\n\t"
|
||||
"shll\t%0\n\t"
|
||||
"bf\t1f\n\t"
|
||||
"or.b\t%3,@(r0,gbr)\n"
|
||||
"1:\n\t"
|
||||
"or.b\t%4,@(r0,gbr)\n"
|
||||
"add\t#-1,%1\n\t"
|
||||
"cmp/pl\t%1\n\t"
|
||||
"bt\t0b"
|
||||
asm ("shll8 %0\n"
|
||||
"0: \n\t"
|
||||
"and.b %2, @(r0,gbr)\n\t"
|
||||
"shll %0\n\t"
|
||||
"bf 1f\n\t"
|
||||
"or.b %3, @(r0,gbr)\n"
|
||||
"1: \n\t"
|
||||
"or.b %4, @(r0,gbr)\n"
|
||||
"add #-1, %1\n\t"
|
||||
"cmp/pl %1\n\t"
|
||||
"bt 0b"
|
||||
:
|
||||
: /* %0 */ "r"(((unsigned)byte)<<16),
|
||||
/* %1 */ "r"(8),
|
||||
|
@ -184,186 +197,159 @@ static void lcd_byte (int byte,bool data)
|
|||
/* %3 */ "I"(LCD_SD),
|
||||
/* %4 */ "I"(LCD_SC),
|
||||
/* %5 */ "z"(LCDR));
|
||||
}
|
||||
|
||||
static void lcd_data (int data)
|
||||
{
|
||||
lcd_byte (data,1);
|
||||
asm("or.b %0, @(r0,gbr)"
|
||||
:
|
||||
: /* %0 */ "I"(LCD_CS|LCD_DS|LCD_SD|LCD_SC),
|
||||
/* %1 */ "z"(LCDR));
|
||||
}
|
||||
#else
|
||||
{
|
||||
int i;
|
||||
char on,off;
|
||||
|
||||
void lcd_instruction (int instruction)
|
||||
{
|
||||
lcd_byte (instruction,0);
|
||||
}
|
||||
PBDR &= ~LCD_CS; /* enable lcd chip select */
|
||||
|
||||
void lcd_zero (int length)
|
||||
{
|
||||
length *= 8;
|
||||
while (--length >= 0)
|
||||
lcd_data (0);
|
||||
}
|
||||
if ( command ) {
|
||||
on=~(LCD_SD|LCD_SC|LCD_DS);
|
||||
off=LCD_SC;
|
||||
}
|
||||
else {
|
||||
on=~(LCD_SD|LCD_SC);
|
||||
off=LCD_SC|LCD_DS;
|
||||
}
|
||||
|
||||
void lcd_fill (int data,int length)
|
||||
{
|
||||
length *= 8;
|
||||
while (--length >= 0)
|
||||
lcd_data (data);
|
||||
}
|
||||
/* clock out each bit, MSB first */
|
||||
for (i=0x80;i;i>>=1)
|
||||
{
|
||||
PBDR &= on;
|
||||
if (i & byte)
|
||||
PBDR |= LCD_SD;
|
||||
PBDR |= off;
|
||||
}
|
||||
|
||||
void lcd_copy (void *data,int count)
|
||||
{
|
||||
while (--count >= 0)
|
||||
lcd_data (*((char *)data)++);
|
||||
}
|
||||
|
||||
static void lcd_goto (int x,int y)
|
||||
{
|
||||
lcd_instruction (LCD_CURSOR(x,y));
|
||||
PBDR |= LCD_CS; /* disable lcd chip select */
|
||||
}
|
||||
#endif /* ASM_IMPLEMENTATION */
|
||||
|
||||
/*** BACKLIGHT ***/
|
||||
|
||||
static void lcd_toggle_backlight (void)
|
||||
void lcd_backlight(bool on)
|
||||
{
|
||||
PAIOR ^= LCD_BL;
|
||||
if ( on )
|
||||
PAIOR |= LCD_BL;
|
||||
else
|
||||
PAIOR &= ~LCD_BL;
|
||||
}
|
||||
|
||||
static void lcd_turn_on_backlight (void)
|
||||
{
|
||||
PAIOR |= LCD_BL;
|
||||
}
|
||||
|
||||
static void lcd_turn_off_backlight (void)
|
||||
{
|
||||
PAIOR &= ~LCD_BL;
|
||||
}
|
||||
|
||||
/*** ICONS ***/
|
||||
#endif /* SIMULATOR */
|
||||
|
||||
|
||||
|
||||
/*** model specific code */
|
||||
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
|
||||
#ifdef HAVE_NEW_CHARCELL_LCD
|
||||
|
||||
static char lcd_ascii[] =
|
||||
{
|
||||
/*****************************************************************************/
|
||||
/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */
|
||||
/* ************************************************************************/
|
||||
/* 0x */ 0x00,0x01,0x02,0x03,0x00,0x00,0x00,0x00,0x04,0x05,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
/* 1x */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
/* 2x */ 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
|
||||
/* 3x */ 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
|
||||
/* 4x */ 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
|
||||
/* 5x */ 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
|
||||
/* 6x */ 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
|
||||
/* 7x */ 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x20,0x20,0x20,0x20,0x20,
|
||||
/* 8x */ 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
/* 9x */ 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
/* Ax */ 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
/* Bx */ 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
/* Cx */ 0x41,0x41,0x41,0x41,0x41,0x41,0x20,0x43,0x45,0x45,0x45,0x45,0x49,0x49,0x49,0x49,
|
||||
/* Dx */ 0x44,0x4E,0x4F,0x4F,0x4F,0x4F,0x4F,0x20,0x20,0x55,0x55,0x55,0x55,0x59,0x20,0x20,
|
||||
/* Ex */ 0x61,0x61,0x61,0x61,0x61,0x61,0x20,0x63,0x65,0x65,0x65,0x65,0x69,0x69,0x69,0x69,
|
||||
/* Fx */ 0x64,0x6E,0x6F,0x6F,0x6F,0x6F,0x6F,0x20,0x20,0x75,0x75,0x75,0x75,0x79,0x79,0x79
|
||||
static const unsigned char lcd_ascii[] = {
|
||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
|
||||
0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
|
||||
0x10,0x11,0x05,0x13,0x14,0x15,0x16,0x17,
|
||||
0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
|
||||
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
|
||||
0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
|
||||
0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,
|
||||
0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,
|
||||
0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,
|
||||
0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
|
||||
0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,
|
||||
0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
|
||||
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,
|
||||
0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
|
||||
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,
|
||||
0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
0x41,0x41,0x41,0x41,0x41,0x41,0x20,0x43,
|
||||
0x45,0x45,0x45,0x45,0x49,0x49,0x49,0x49,
|
||||
0x44,0x4e,0x4f,0x4f,0x4f,0x4f,0x4f,0x20,
|
||||
0x20,0x55,0x55,0x55,0x55,0x59,0x20,0x20,
|
||||
0x61,0x61,0x61,0x61,0x61,0x61,0x20,0x63,
|
||||
0x65,0x65,0x65,0x65,0x69,0x69,0x69,0x69,
|
||||
0x6f,0x6e,0x6f,0x6f,0x6f,0x6f,0x6f,0x20,
|
||||
0x20,0x75,0x75,0x75,0x75,0x79,0x20,0x79
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
static char lcd_ascii[] =
|
||||
{
|
||||
/*****************************************************************************/
|
||||
/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */
|
||||
/* ************************************************************************/
|
||||
/* 0x */ 0x00,0x01,0x02,0x03,0x00,0x00,0x00,0x00,0x85,0x89,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
/* 1x */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
/* 2x */ 0x24,0x25,0x26,0x37,0x06,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,
|
||||
/* 3x */ 0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,0x41,0x42,0x43,
|
||||
/* 4x */ 0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,
|
||||
/* 5x */ 0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0xA9,0x33,0xCE,0x00,0x15,
|
||||
/* 6x */ 0x00,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,
|
||||
/* 7x */ 0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x24,0x24,0x24,0x24,0x24,
|
||||
/* 8x */ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
/* 9x */ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
/* Ax */ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
/* Bx */ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
/* Cx */ 0x45,0x45,0x45,0x45,0x45,0x45,0x24,0x47,0x49,0x49,0x49,0x49,0x4D,0x4D,0x4D,0x4D,
|
||||
/* Dx */ 0x48,0x52,0x53,0x53,0x53,0x53,0x53,0x24,0x24,0x59,0x59,0x59,0x59,0x5D,0x24,0x24,
|
||||
/* Ex */ 0x65,0x65,0x65,0x65,0x65,0x65,0x24,0x67,0x69,0x69,0x69,0x69,0x6D,0x6D,0x6D,0x6D,
|
||||
/* Fx */ 0x73,0x72,0x73,0x73,0x73,0x73,0x73,0x24,0x24,0x79,0x79,0x79,0x79,0x7D,0x24,0x7D
|
||||
static const unsigned char lcd_ascii[] = {
|
||||
0x00,0x01,0x02,0x03,0x00,0x84,0x85,0x89,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0xec,0xe3,0xe2,0xe1,0xe0,0xdf,0x15,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x24,0x25,0x26,0x37,0x06,0x29,0x2a,0x2b,
|
||||
0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,
|
||||
0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,
|
||||
0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,
|
||||
0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,
|
||||
0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,
|
||||
0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,
|
||||
0x5c,0x5d,0x5e,0xa9,0x33,0xce,0x00,0x15,
|
||||
0x00,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,
|
||||
0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,
|
||||
0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,
|
||||
0x7c,0x7d,0x7e,0x24,0x24,0x24,0x24,0x24,
|
||||
0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
|
||||
0x45,0x45,0x45,0x45,0x45,0x45,0x24,0x47,
|
||||
0x49,0x49,0x49,0x49,0x4d,0x4d,0x4d,0x4d,
|
||||
0x48,0x52,0x53,0x53,0x53,0x53,0x53,0x24,
|
||||
0x24,0x59,0x59,0x59,0x59,0x5d,0x24,0x24,
|
||||
0x65,0x65,0x65,0x65,0x65,0x65,0x24,0x67,
|
||||
0x69,0x69,0x69,0x69,0x6d,0x6d,0x6d,0x6d,
|
||||
0x73,0x72,0x73,0x73,0x73,0x73,0x73,0x24,
|
||||
0x24,0x79,0x79,0x79,0x79,0x7d,0x24,0x7d
|
||||
};
|
||||
#endif /* HAVE_NEW_CHARCELL_LCD */
|
||||
|
||||
#endif
|
||||
void lcd_clear_display(void)
|
||||
{
|
||||
int i;
|
||||
lcd_write(TRUE,LCD_CURSOR(0,0));
|
||||
for (i=0;i<24;i++)
|
||||
lcd_write(FALSE,0);
|
||||
}
|
||||
|
||||
void lcd_puts(int x, int y, char *string)
|
||||
{
|
||||
lcd_write(TRUE,LCD_CURSOR(x,y));
|
||||
while (*string)
|
||||
lcd_data (LCD_ASCII(*string++));
|
||||
lcd_write(FALSE,LCD_ASCII(*string++));
|
||||
}
|
||||
|
||||
void lcd_putns (char *string,int n)
|
||||
void lcd_define_pattern (int which,char *pattern,int length)
|
||||
{
|
||||
while (n--)
|
||||
lcd_data (LCD_ASCII(*string++));
|
||||
int i;
|
||||
lcd_write(TRUE,LCD_PRAM|which);
|
||||
for (i=0;i<length;i++)
|
||||
lcd_write(FALSE,pattern[i]);
|
||||
}
|
||||
|
||||
void lcd_putc (int character)
|
||||
{
|
||||
lcd_data (LCD_ASCII(character));
|
||||
}
|
||||
|
||||
void lcd_pattern (int which,char *pattern,int count)
|
||||
{
|
||||
lcd_instruction (LCD_PRAM|which);
|
||||
lcd_copy ((void *)pattern,count);
|
||||
}
|
||||
|
||||
void lcd_puthex (unsigned int value,int digits)
|
||||
{
|
||||
switch (digits) {
|
||||
case 8:
|
||||
lcd_puthex (value >> 16,4);
|
||||
case 4:
|
||||
lcd_puthex (value >> 8,2);
|
||||
case 2:
|
||||
lcd_puthex (value >> 4,1);
|
||||
case 1:
|
||||
value &= 15;
|
||||
lcd_putc (value+((value < 10) ? '0' : ('A'-10)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#elif HAVE_LCD_BITMAP /* not CHARCELLS */
|
||||
|
||||
#define LCD_SD 1 // PB0 = 1 --- 0001
|
||||
#define LCD_SC 2 // PB1 = 1 --- 0010
|
||||
#define LCD_RS 4 // PB2 = 1 --- 0100
|
||||
#define LCD_CS 8 // PB3 = 1 --- 1000
|
||||
#define LCD_DS LCD_RS
|
||||
|
||||
#define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00)
|
||||
#define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10)
|
||||
#define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20)
|
||||
#define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28)
|
||||
#define LCD_SET_DISPLAY_START_LINE ((char)0x40)
|
||||
#define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81)
|
||||
#define LCD_SET_SEGMENT_REMAP ((char)0xA0)
|
||||
#define LCD_SET_LCD_BIAS ((char)0xA2)
|
||||
#define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4)
|
||||
#define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5)
|
||||
#define LCD_SET_NORMAL_DISPLAY ((char)0xA6)
|
||||
#define LCD_SET_REVERSE_DISPLAY ((char)0xA7)
|
||||
#define LCD_SET_INDICATOR_OFF ((char)0xAC)
|
||||
#define LCD_SET_INDICATOR_ON ((char)0xAD)
|
||||
#define LCD_SET_DISPLAY_OFF ((char)0xAE)
|
||||
#define LCD_SET_DISPLAY_ON ((char)0xAF)
|
||||
#define LCD_SET_PAGE_ADDRESS ((char)0xB0)
|
||||
#define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0)
|
||||
#define LCD_SET_DISPLAY_OFFSET ((char)0xD3)
|
||||
#define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0)
|
||||
#define LCD_SOFTWARE_RESET ((char)0xE2)
|
||||
#define LCD_NOP ((char)0xE3)
|
||||
#define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE)
|
||||
|
||||
/*
|
||||
* All bitmaps have this format:
|
||||
* Bits within a byte are arranged veritcally, LSB at top.
|
||||
|
@ -375,7 +361,7 @@ void lcd_puthex (unsigned int value,int digits)
|
|||
*
|
||||
* Memory copy of display bitmap
|
||||
*/
|
||||
unsigned char display[DISP_X][DISP_Y/8];
|
||||
unsigned char display[LCD_WIDTH][LCD_HEIGHT/8];
|
||||
|
||||
/*
|
||||
* ASCII character generation tables
|
||||
|
@ -386,20 +372,16 @@ unsigned char display[DISP_X][DISP_Y/8];
|
|||
#define ASCII_MIN 0x20 /* First char in table */
|
||||
#define ASCII_MAX 0x7f /* Last char in table */
|
||||
|
||||
extern const unsigned char char_gen_6x8[][5][1];
|
||||
extern const unsigned char char_gen_8x12[][7][2];
|
||||
extern const unsigned char char_gen_12x16[][11][2];
|
||||
|
||||
extern unsigned char char_gen_6x8[][5][1];
|
||||
extern unsigned char char_gen_8x12[][7][2];
|
||||
extern unsigned char char_gen_12x16[][11][2];
|
||||
|
||||
/* All zeros and ones bitmaps for area filling */
|
||||
static const unsigned char zeros[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00 };
|
||||
static const unsigned char ones[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff };
|
||||
|
||||
static int lcd_y; /* Current pixel row */
|
||||
static int lcd_x; /* Current pixel column */
|
||||
static int lcd_size; /* Current font width */
|
||||
static unsigned char zeros[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00 };
|
||||
static unsigned char ones[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff };
|
||||
static char fonts[] = { 6,8,12 };
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
|
@ -434,39 +416,17 @@ void lcd_update (void)
|
|||
int x, y;
|
||||
|
||||
/* Copy display bitmap to hardware */
|
||||
for (y = 0; y < DISP_Y/8; y++)
|
||||
for (y = 0; y < LCD_HEIGHT/8; y++)
|
||||
{
|
||||
lcd_write (TRUE, LCD_CNTL_PAGE | (y & 0xf));
|
||||
lcd_write (TRUE, LCD_CNTL_HIGHCOL);
|
||||
lcd_write (TRUE, LCD_CNTL_LOWCOL);
|
||||
|
||||
for (x = 0; x < DISP_X; x++)
|
||||
for (x = 0; x < LCD_WIDTH; x++)
|
||||
lcd_write (FALSE, display[x][y]);
|
||||
}
|
||||
}
|
||||
|
||||
static void lcd_write (bool command, int value)
|
||||
{
|
||||
int bit;
|
||||
|
||||
/* Enable chip select, set DC if data */
|
||||
PBDR &= ~(PBDR_LCD_CS1|PBDR_LCD_DC);
|
||||
if (!command)
|
||||
PBDR |= PBDR_LCD_DC;
|
||||
|
||||
/* Send each bit, starting with MSB */
|
||||
for (bit = 0x80; bit > 0; bit >>= 1)
|
||||
{
|
||||
PBDR &= ~(PBDR_LCD_SDA|PBDR_LCD_SCK);
|
||||
if (value & bit)
|
||||
PBDR |= PBDR_LCD_SDA;
|
||||
PBDR |= PBDR_LCD_SCK;
|
||||
}
|
||||
|
||||
/* Disable chip select */
|
||||
PBDR |= PBDR_LCD_CS1;
|
||||
}
|
||||
|
||||
#endif /* SIMULATOR */
|
||||
|
||||
/*
|
||||
|
@ -474,33 +434,19 @@ static void lcd_write (bool command, int value)
|
|||
*/
|
||||
void lcd_clear_display (void)
|
||||
{
|
||||
lcd_position (0, 0, 8);
|
||||
memset (display, 0, sizeof display);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set current x,y position and font size
|
||||
* Put a string at specified position and font
|
||||
*/
|
||||
void lcd_position (int x, int y, int size)
|
||||
void lcd_puts(int x, int y, char *str, int font)
|
||||
{
|
||||
if (x >= 0 && x < DISP_X && y >= 0 && y < DISP_Y)
|
||||
{
|
||||
lcd_x = x;
|
||||
lcd_y = y;
|
||||
}
|
||||
|
||||
lcd_size = size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display a string at current position and size
|
||||
*/
|
||||
void lcd_string (const char *str)
|
||||
{
|
||||
int x = lcd_x;
|
||||
int nx = lcd_size;
|
||||
int nx = fonts[font];
|
||||
int ny, ch;
|
||||
const unsigned char *src;
|
||||
unsigned char *src;
|
||||
int lcd_x = x;
|
||||
int lcd_y = y;
|
||||
|
||||
if (nx == 12)
|
||||
ny = 16;
|
||||
|
@ -514,14 +460,14 @@ void lcd_string (const char *str)
|
|||
|
||||
while ((ch = *str++) != '\0')
|
||||
{
|
||||
if (ch == '\n' || lcd_x + nx > DISP_X)
|
||||
if (ch == '\n' || lcd_x + nx > LCD_WIDTH)
|
||||
{
|
||||
/* Wrap to next line */
|
||||
lcd_x = x;
|
||||
lcd_y += ny;
|
||||
}
|
||||
|
||||
if (lcd_y + ny > DISP_Y)
|
||||
if (lcd_y + ny > LCD_HEIGHT)
|
||||
return;
|
||||
|
||||
/* Limit to char generation table */
|
||||
|
@ -546,7 +492,7 @@ void lcd_string (const char *str)
|
|||
* Display a bitmap at (x, y), size (nx, ny)
|
||||
* clear is TRUE to clear destination area first
|
||||
*/
|
||||
void lcd_bitmap (const unsigned char *src, int x, int y, int nx, int ny,
|
||||
void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny,
|
||||
bool clear)
|
||||
{
|
||||
unsigned char *dst;
|
||||
|
@ -573,7 +519,7 @@ void lcd_bitmap (const unsigned char *src, int x, int y, int nx, int ny,
|
|||
for (x = 0; x < nx; x++)
|
||||
{
|
||||
dst = dst2;
|
||||
dst2 += DISP_Y/8;
|
||||
dst2 += LCD_HEIGHT/8;
|
||||
data = 0;
|
||||
y = 0;
|
||||
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
#include "types.h"
|
||||
#include "config.h"
|
||||
|
||||
/* common functions */
|
||||
extern void lcd_init(void);
|
||||
extern void lcd_clear_display(void);
|
||||
extern void lcd_backlight(bool on);
|
||||
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
# define LCD_ICON_BATTERY 0
|
||||
# define LCD_BATTERY_FRAME 0x02
|
||||
|
@ -56,19 +61,15 @@
|
|||
# define LCD_PARAM_SYMBOL 0xF0
|
||||
|
||||
extern void lcd_puts(int x, int y, char *string);
|
||||
extern void lcd_puthex (unsigned int value,int digits);
|
||||
extern void lcd_pattern (int which,char *pattern,int count);
|
||||
extern void lcd_define_pattern (int which,char *pattern,int length);
|
||||
|
||||
#elif HAVE_LCD_BITMAP
|
||||
|
||||
#define LCD_WIDTH 112 /* Display width in pixels */
|
||||
#define LCD_HEIGHT 64 /* Display height in pixels */
|
||||
|
||||
extern void lcd_init (void);
|
||||
extern void lcd_update (void);
|
||||
extern void lcd_clear_display (void);
|
||||
extern void lcd_position (int x, int y, int size);
|
||||
extern void lcd_string (char *str);
|
||||
extern void lcd_puts(int x, int y, char *str, int font);
|
||||
extern void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny,
|
||||
bool clear);
|
||||
extern void lcd_clearrect (int x, int y, int nx, int ny);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue