here is my code, I cannot post the ccs driver obviously
visit
www.compysys1.com/workbench
there is a facility for converting bmps to raw data for use with the ks0108
#include "bmp.c"
#include "splash.c"
#byte PORTA= 0x0F80
#byte PORTB= 0x0F81
#byte PORTC= 0x0F82
#byte PORTD= 0x0F83
//board specific definitions for pins
#define lcd_enable PIN_C0 //Enable pin on LCD
#define lcd_cmd PIN_C1 //Data/Command Pin 4 on LCD
#define lcd_rw PIN_C2 //Read/Write Pin 5 on LCD
#define lcd_cs1 PIN_B1 //ChipSelect1 Pin 15 on LCD
#define lcd_cs2 PIN_B2 //ChipSelect2 Pin 16 on LCD
#define lcd_rst PIN_C5 //Reset Pin 17 on LCD
#byte lcd_data = PORTD //ensure PORTD is declared as a byte
#use fast_io(D)
#define LCD_LEFT 1
#define LCD_RIGHT 0
void lcd_init(void);
void lcd_write(int1 half);
void lcd_gotoxy(int8 x, int8 y);
void lcd_clrscr(void);
void lcd_newline(void);
void lcd_progress_bar(int8 x_start, int8 y_start, int8 length, int1 color);
CHAR CONST fonts[475]= { //dec ascii
0x00,0x00,0x00,0x00,0x00, //32 <Space>
0x00,0x00,0x4F,0x00,0x00, //33 !
0x00,0x07,0x00,0x07,0x00, //34 "
0x14,0x7F,0x14,0x7F,0x14, //35 #
0x24,0x2A,0x7F,0x2A,0x12, //36 $
0x23,0x13,0x08,0x64,0x62, //37 %
0x36,0x49,0x55,0x22,0x50, //38 &
0x00,0x05,0x03,0x00,0x00, //39 '
0x1C,0x22,0x41,0x00,0x00, //40 (
0x00,0x00,0x41,0x22,0x1C, //41 )
0x14,0x08,0x3E,0x08,0x14, //42 *
0x08,0x08,0x3E,0x08,0x08, //43 +
0x00,0x50,0x30,0x00,0x00, //44 ,
0x08,0x08,0x08,0x08,0x08, //45 -
0x00,0x60,0x60,0x00,0x00, //46 .
0x20,0x10,0x08,0x04,0x02, //47 /
0x3E,0x51,0x49,0x45,0x3E, //48 0
0x00,0x42,0x7F,0x40,0x00, //49 1
0x42,0x61,0x51,0x49,0x46, //50 2
0x21,0x41,0x45,0x4B,0x31, //51 3
0x18,0x14,0x12,0x7F,0x10, //52 4
0x27,0x45,0x45,0x45,0x39, //53 5
0x3C,0x4A,0x49,0x49,0x30, //54 6
0x01,0x71,0x09,0x05,0x03, //55 7
0x36,0x49,0x49,0x49,0x36, //56 8
0x06,0x49,0x49,0x49,0x3E, //57 9
0x00,0x36,0x36,0x00,0x00, //58 :
0x00,0x56,0x36,0x00,0x00, //59 ;
0x08,0x14,0x22,0x41,0x00, //60 <
0x14,0x14,0x14,0x14,0x14, //61 =
0x00,0x41,0x22,0x14,0x08, //62 >
0x02,0x01,0x51,0x09,0x06, //63 ?
0x32,0x49,0x79,0x41,0x3E, //64 @
0x7E,0x11,0x11,0x11,0x7E, //65 A
0x7F,0x49,0x49,0x49,0x36, //66 B
0x3E,0x41,0x41,0x41,0x22, //67 C
0x7F,0x41,0x41,0x22,0x1C, //68 D
0x7F,0x49,0x49,0x49,0x41, //69 E
0x7F,0x09,0x09,0x09,0x01, //70 F
0x3E,0x41,0x49,0x49,0x7A, //71 G
0x7F,0x08,0x08,0x08,0x7F, //72 H
0x00,0x41,0x7F,0x41,0x00, //73 I
0x20,0x40,0x41,0x3F,0x01, //74 J
0x7F,0x08,0x14,0x22,0x41, //75 K
0x7F,0x40,0x40,0x40,0x40, //76 L
0x7F,0x02,0x0C,0x02,0x7F, //77 M
0x7F,0x04,0x08,0x10,0x7F, //78 N
0x3E,0x41,0x41,0x41,0x3E, //79 O
0x7F,0x09,0x09,0x09,0x06, //80 P
0x3E,0x41,0x51,0x21,0x5E, //81 Q
0x7F,0x09,0x19,0x29,0x46, //82 R
0x46,0x49,0x49,0x49,0x31, //83 S
0x01,0x01,0x7F,0x01,0x01, //84 T
0x3F,0x40,0x40,0x40,0x3F, //85 U
0x1F,0x20,0x40,0x20,0x1F, //86 V
0x3F,0x40,0x38,0x40,0x3F, //87 W
0x63,0x14,0x08,0x14,0x63, //88 X
0x07,0x08,0x70,0x08,0x07, //89 Y
0x61,0x51,0x49,0x45,0x43, //90 Z
0x7F,0x41,0x41,0x00,0x00, //91 [
0x02,0x04,0x08,0x10,0x20, //92 \
0x00,0x00,0x41,0x41,0x7F, //93 ]
0x04,0x02,0x01,0x02,0x04, //94 ^
0x40,0x40,0x40,0x40,0x40, //95 _
0x00,0x01,0x02,0x04,0x00, //96 `
0x20,0x54,0x54,0x54,0x78, //97 a
0x7F,0x48,0x44,0x44,0x38, //98 b
0x38,0x44,0x44,0x44,0x20, //99 c
0x38,0x44,0x44,0x48,0x7F, //100 d
0x38,0x54,0x54,0x54,0x18, //101 e
0x08,0x7E,0x09,0x01,0x02, //102 f
0x0C,0x52,0x52,0x52,0x3E, //103 g
0x7F,0x08,0x04,0x04,0x78, //104 h
0x00,0x44,0x7D,0x40,0x00, //105 i
0x00,0x20,0x40,0x44,0x3D, //106 j
0x7F,0x10,0x28,0x44,0x00, //107 k
0x00,0x41,0x7F,0x40,0x00, //108 l
0x7C,0x04,0x18,0x04,0x78, //109 m
0x7C,0x08,0x04,0x04,0x78, //110 n
0x38,0x44,0x44,0x44,0x38, //111 o
0x7C,0x14,0x14,0x14,0x08, //112 p
0x08,0x14,0x14,0x18,0x7C, //113 q
0x7C,0x08,0x04,0x04,0x08, //114 r
0x48,0x54,0x54,0x54,0x20, //115 s
0x04,0x3F,0x44,0x40,0x20, //116 t
0x3C,0x40,0x40,0x20,0x7C, //117 u
0x1C,0x20,0x40,0x20,0x1C, //118 v
0x3C,0x40,0x30,0x40,0x3C, //119 w
0x44,0x28,0x10,0x28,0x44, //120 x
0x0C,0x50,0x50,0x50,0x3C, //121 y
0x44,0x64,0x54,0x4C,0x44, //122 z
0x08,0x36,0x41,0x00,0x00, //123 {
0x00,0x00,0x7F,0x00,0x00, //124 |
0x00,0x00,0x41,0x36,0x08, //125 }
// 0x00,0x08,0x04,0x08,0x04 //126 ~
0x7E,0x7E,0xFF,0x7E,0x7E //126 ~
};
//position on LCD, x = 0 - 127, y = 0 - 7
int8 x_position, y_position;
#define CS1_MAX_X 63 //chip 1 x range 0 - 63
#define CS2_MAX_X 127 //chip 1 x range 64 - 127
#define DISPLAY_ON 0x3F //LCD Display ON
#define DISPLAY_OFF 0x3E //LCD Display OFF
#define SET_X 0x40 //LCD SET X command, add x - 0 to 63
#define SET_Y 0xB8 //LCD SET Y command, add y - 0 to 7
#define SET_RAM_0 0xC0 //LCD RAM, used for scrolling add x - 0 to 63
void lcd_init(void)
{
//init LCD lines
set_tris_d(0x00);
lcd_data = 0x00;
output_high(lcd_cmd);
output_low(lcd_rw);
output_low(lcd_enable);
output_low(lcd_cs1);
output_low(lcd_cs2);
//reset LCD
output_high(lcd_rst);
delay_us(10);
output_low(lcd_rst);
delay_us(5);
output_high(lcd_rst);
delay_us(10);
//command mode
output_low(lcd_cmd);
lcd_data = DISPLAY_OFF;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
lcd_data = SET_RAM_0;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
lcd_gotoxy(0,0);
lcd_data = DISPLAY_ON;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
x_position = 0;
y_position = 0;
return;
}
void lcd_write(int1 half)
{
delay_us(10);
if(half)
{
output_high(lcd_cs1);
output_low(lcd_cs2);
}
else
{
output_low(lcd_cs1);
output_high(lcd_cs2);
}
delay_us(5);
output_high(lcd_enable);
delay_us(5);
output_low(lcd_enable);
delay_us(5);
return;
}
void lcd_clrscr(void)
{
int8 x,y;
output_low(lcd_cmd);
lcd_data = DISPLAY_OFF;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(y=0; y<8; y++)
{
output_low(lcd_cmd);
lcd_data = SET_Y + y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(x=0; x<64; x++)
{
lcd_data = 0;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
}
}
output_low(lcd_cmd);
lcd_data = DISPLAY_ON;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
lcd_gotoxy(0,0);
return;
}
void lcd_putc( char c)
{
int16 index,count;
int8 x;
switch (c)
{
case '\f' :
lcd_clrscr();
break;
case '\n' :
lcd_newline();
break;
default :
//check there is space to print
if((x_position + 5) < CS2_MAX_X)
{ //print character
index = (int16)(c - 32) * 5;
for(x=0; x<5; x++)
{
lcd_data = fonts[index++];
if(x_position > CS1_MAX_X)
{
lcd_write(LCD_RIGHT);
}
else
{
lcd_write(LCD_LEFT);
}
x_position++;
}
}
if((x_position + 1) < CS2_MAX_X)
{
lcd_data = 0x00;
if(x_position > CS1_MAX_X)
{
lcd_write(LCD_RIGHT);
}
else
{
lcd_write(LCD_LEFT);
}
x_position++;
}
break;
}
return;
}
int8 lcd_read_byte()
{
int8 data;
set_tris_d(0xFF);
output_high(lcd_rw);
if(x_position > 63)
{
output_high(lcd_cs2);
delay_us(2);
output_high(lcd_enable);
delay_us(2);
output_low(lcd_enable);
delay_us(2);
output_high(lcd_enable);
delay_us(6);
data = lcd_data;
output_low(lcd_enable);
delay_us(2);
output_low(lcd_cs2);
}
else
{
output_high(lcd_cs1);
delay_us(2);
output_high(lcd_enable);
delay_us(2);
output_low(lcd_enable);
delay_us(2);
output_high(lcd_enable);
delay_us(6);
data = lcd_data;
output_low(lcd_enable);
delay_us(2);
output_low(lcd_cs1);
}
output_low(lcd_rw);
set_tris_d(0x00);
return data;
}
void lcd_gotoxy( int8 x, int8 y)
{
x_position = x;
y_position = y;
output_low(lcd_cmd);
if(x > 63)
{
x = x - 63;
lcd_data = SET_X + x;
lcd_write(LCD_RIGHT);
lcd_data = SET_X;
lcd_write(LCD_LEFT);
}
else
{
lcd_data = SET_X + x;
lcd_write(LCD_LEFT);
lcd_data = SET_X;
lcd_write(LCD_RIGHT);
}
lcd_data = SET_Y + y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
return;
}
void lcd_newline(void)
{
x_position = 0;
if(y_position < 7) //check for last line
{
y_position ++;
output_low(lcd_cmd);
lcd_data = SET_X;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
lcd_data = SET_Y + y_position;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
}
return;
}
void lcd_load_bmp(void)
{
int8 x,y;
int16 ptr=0;
output_low(lcd_cmd);
lcd_data = DISPLAY_OFF;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(y=0; y<8; y++)
{
output_low(lcd_cmd);
lcd_data = SET_Y + y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(x=0; x<64; x++)
{
lcd_data = bmp[ptr++];
lcd_write(LCD_LEFT);
}
for(x=0; x<64; x++)
{
lcd_data = bmp[ptr++];
lcd_write(LCD_RIGHT);
}
}
output_low(lcd_cmd);
lcd_data = DISPLAY_ON;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
lcd_gotoxy(0,0);
return;
}
void lcd_load_splash(void)
{
int8 x,y;
int16 ptr=0;
output_low(lcd_cmd);
lcd_data = DISPLAY_OFF;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(y=0; y<8; y++)
{
output_low(lcd_cmd);
lcd_data = SET_Y + y;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
for(x=0; x<64; x++)
{
lcd_data = splash[ptr++];
lcd_write(LCD_LEFT);
}
for(x=0; x<64; x++)
{
lcd_data = splash[ptr++];
lcd_write(LCD_RIGHT);
}
}
output_low(lcd_cmd);
lcd_data = DISPLAY_ON;
lcd_write(LCD_LEFT);
lcd_write(LCD_RIGHT);
output_high(lcd_cmd);
lcd_gotoxy(0,0);
return;
}
void lcd_progress_bar(int8 x_start, int8 y_start, int8 length, int1 color)
{
int8 x_end,x;
lcd_gotoxy(x_start, y_start);
x_end = x_start + length;
if(color == 1)
{
lcd_data = 0xFF;
}
else
{
lcd_data = 0x00;
}
//check there is space to print
if((x_position + length) < CS2_MAX_X)
{
for(x=0; x<length; x++)
{
if(x_position > CS1_MAX_X)
{
lcd_write(LCD_RIGHT);
}
else
{
lcd_write(LCD_LEFT);
}
x_position++;
}
}
return;
}