/*
	lcgram.c
	
   PK21xx/Rugged Giant and PK22xx/Little Star Sample Program that illustrates
	the special character generator for the LCD.
*/

#use "default.h"
#use cplc.lib

#if !(BOARD_TYPE==CPLC_BOARD || BOARD_TYPE==L_STAR)
#fatal "This program only runs on a PK21xx/Rugged Giant or a PK22xx/Little Star"
#endif

main()
{
	 // It may be helpful to visualize the characters on an 8x8 grid with the
	 // left most byte representing the top row.

	 /* eg: the right arrow (0x04, 0x02, 0x1f, 0x02, 0x04, 0x00, 0x00, 0x00)

	       00000100 = 0x04
	       00000010 = 0x02
	       00011111 = 0x1f
	       00000010 = 0x02
	       00000100 = 0x04
	       00000000 = 0x00
	       00000000 = 0x00
	       00000000 = 0x00
	 */
	 
    char testchars[] =
    {
         64,                 // 64 bytes to follow
        0x04, 0x02, 0x1f, 0x02, 0x04, 0x00, 0x00, 0x00, // 08 right arrow
        0x00, 0x00, 0x00, 0x04, 0x04, 0x15, 0x0e, 0x04, // 09 down arrow
        0x04, 0x0e, 0x15, 0x04, 0x04, 0x00, 0x00, 0x00, // 02 up arrow
        0x04, 0x08, 0x1f, 0x08, 0x04, 0x00, 0x00, 0x00, // 0b left arrow
        0x08, 0x0c, 0x0e, 0x0f, 0x0e, 0x0c, 0x08, 0x00, // 0c arrow cursor
        0x02, 0x07, 0x02, 0x0a, 0x0a, 0x08, 0x1c, 0x08, // 0d up down symbol
        0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, // 0e vertical line
        0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00  // 0f horizontal line
    };
    
    int i;
    
    uplc_init();
    lc_cgram(testchars);     // generate the special characters

    for (i = 0; i < 8; i++) 
        lc_putc(i);

    while (1) 
        runwatch();
}
