rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Mon Feb 09, 2004 8:38 am |
|
|
The "average" LCD (or VFD) display has 64 CGRam locations and each custom character is made from 8 CGRam locations. One word per row for both the 5x7 and 5x8 pixel types.
This is what I did and it works on several different brands of LCD and a Noritake VFD (the Noritake VFD seems to be the most fickle of the bunch).
Code: |
/*******************************************************************************
* Battery icons
******************************************************************************/
const int8 lcd_characters[] = {
0x04, 0x0E, 0x0A, 0x0A, 0x0A, 0x0E, 0x0E, 0x00, // 25%
0x04, 0x0E, 0x0A, 0x0A, 0x0E, 0x0E, 0x0E, 0x00, // 50%
0x04, 0x0E, 0x0A, 0x0E, 0x0E, 0x0E, 0x0E, 0x00, // 75%
0x04, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x00, // 100%
0x04, 0x0E, 0x0A, 0x0A, 0x0A, 0x0A, 0x0E, 0x00, // LOW
0x04, 0x0A, 0x15, 0x04, 0x04, 0x04, 0x04, 0x04, // UP
0x1C, 0x14, 0x1C, 0x07, 0x04, 0x06, 0x04, 0x00, // degF
0x1C, 0x14, 0x1C, 0x07, 0x04, 0x04, 0x07, 0x00}; // degC
...
more code
...
void lcd_init ()
{
int8 i;
#use fast_io(B)
set_tris_lcd (LCD_WRITE);
lcd.rs = 0;
lcd.rw = 0;
lcd.enable = 0;
delay_ms (15);
for (i = 1; i <= 3; ++i)
{
lcd_send_nibble (3);
delay_ms (5);
}
lcd_send_nibble (2);
for (i = 0; i <= 3; ++i)
lcd_send_byte (0, LCD_INIT_STRING[i]);
delay_us (100);
lcd_clear ();
// program battery indicator graphics into CG RAM
lcd_send_byte (0, 0x40);
for (i = 0; i < 64; i++)
{
delay_us(100);
lcd_send_byte (1, lcd_characters[i]);
}
lcd_on ();
}
|
Most of the lcd_init() routine is taken from the lcd example code provided by CCS.
The last loop loads in the CGRam characters. The 100us delay is pretty long for this application but since I modified the lcd_send_byte() code so that it doesn't read back status, some LCDs need a little longer to complete their internal processes.
For your application, if you can group your custom characters into 8 groups of 8 you might be able to load and reload as needed without too much delay aparent to the end user. _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|