waleed.ahafeez
Joined: 16 Mar 2012 Posts: 10
|
Drivers for KS0713 Family Graphic LCD |
Posted: Fri Apr 20, 2012 12:32 am |
|
|
Code: |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
DRIVERS FOR KS0713 Family Graphic LCDs
Drivers modified by Waleed Bin Abdul Hafeez
APPLICATION ENGINEER
HUNCH AUTOMATION LAHORE PAKISTAN
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#byte pa =0xF80
#bit dt_cs =pa.5 // RA5
#bit dt_rst =pa.4 // RA4
#bit dt_sclk =pa.3 // RA3
#bit dt_sid =pa.2 // RA2
#bit dt_rs =pa.1 // RA1
#bit dt_bl =pa.0 // RA1
BYTE const TABLE5[48][5]=
{0x00,0x00,0x00,0x00,0x00, // 20 space ASCII table for NOKIA LCD: 96 rows * 5 bytes= 480 bytes
0x00,0x00,0x5f,0x00,0x00, // 21 !
0x00,0x07,0x00,0x07,0x00, // 22 "
0x14,0x7f,0x14,0x7f,0x14, // 23 #
0x24,0x2a,0x7f,0x2a,0x12, // 24 $
0x23,0x13,0x08,0x64,0x62, // 25 %
0x36,0x49,0x55,0x22,0x50, // 26 &
0x00,0x05,0x03,0x00,0x00, // 27 '
0x00,0x1c,0x22,0x41,0x00, // 28 (
0x00,0x41,0x22,0x1c,0x00, // 29 )
0x14,0x08,0x3e,0x08,0x14, // 2a *
0x08,0x08,0x3e,0x08,0x08, // 2b +
0x00,0x50,0x30,0x00,0x00, // 2c ,
0x08,0x08,0x08,0x08,0x08, // 2d -
0x00,0x60,0x60,0x00,0x00, // 2e .
0x20,0x10,0x08,0x04,0x02, // 2f /
0x3e,0x51,0x49,0x45,0x3e, // 30 0
0x00,0x42,0x7f,0x40,0x00, // 31 1
0x42,0x61,0x51,0x49,0x46, // 32 2
0x21,0x41,0x45,0x4b,0x31, // 33 3
0x18,0x14,0x12,0x7f,0x10, // 34 4
0x27,0x45,0x45,0x45,0x39, // 35 5
0x3c,0x4a,0x49,0x49,0x30, // 36 6
0x01,0x71,0x09,0x05,0x03, // 37 7
0x36,0x49,0x49,0x49,0x36, // 38 8
0x06,0x49,0x49,0x29,0x1e, // 39 9
0x00,0x36,0x36,0x00,0x00, // 3a :
0x00,0x56,0x36,0x00,0x00, // 3b ;
0x08,0x14,0x22,0x41,0x00, // 3c <
0x14,0x14,0x14,0x14,0x14, // 3d =
0x00,0x41,0x22,0x14,0x08, // 3e >
0x02,0x01,0x51,0x09,0x06, // 3f ?
0x32,0x49,0x79,0x41,0x3e, // 40 @
0x7e,0x11,0x11,0x11,0x7e, // 41 A
0x7f,0x49,0x49,0x49,0x36, // 42 B
0x3e,0x41,0x41,0x41,0x22, // 43 C
0x7f,0x41,0x41,0x22,0x1c, // 44 D
0x7f,0x49,0x49,0x49,0x41, // 45 E
0x7f,0x09,0x09,0x09,0x01, // 46 F
0x3e,0x41,0x49,0x49,0x7a, // 47 G
0x7f,0x08,0x08,0x08,0x7f, // 48 H
0x00,0x41,0x7f,0x41,0x00, // 49 I
0x20,0x40,0x41,0x3f,0x01, // 4a J
0x7f,0x08,0x14,0x22,0x41, // 4b K
0x7f,0x40,0x40,0x40,0x40, // 4c L
0x7f,0x02,0x0c,0x02,0x7f, // 4d M
0x7f,0x04,0x08,0x10,0x7f, // 4e N
0x3E,0x41,0x41,0x41,0x3E,}; // 4f O
BYTE const TABLE6[48][5]={
0x7f,0x09,0x09,0x09,0x06, // 50 P
0x3e,0x41,0x51,0x21,0x5e, // 51 Q
0x7f,0x09,0x19,0x29,0x46, // 52 R
0x46,0x49,0x49,0x49,0x31, // 53 S
0x01,0x01,0x7f,0x01,0x01, // 54 T
0x3f,0x40,0x40,0x40,0x3f, // 55 U
0x1f,0x20,0x40,0x20,0x1f, // 56 V
0x3f,0x40,0x38,0x40,0x3f, // 57 W
0x63,0x14,0x08,0x14,0x63, // 58 X
0x07,0x08,0x70,0x08,0x07, // 59 Y
0x61,0x51,0x49,0x45,0x43, // 5a Z
0x00,0x7f,0x41,0x41,0x00, // 5b [
0x02,0x04,0x08,0x10,0x20, // 5c
0x00,0x41,0x41,0x7f,0x00, // 5d
0x04,0x02,0x01,0x02,0x04, // 5e
0x40,0x40,0x40,0x40,0x40, // 5f
0x00,0x01,0x02,0x04,0x00, // 60
0x20,0x54,0x54,0x54,0x78, // 61 a
0x7f,0x48,0x44,0x44,0x38, // 62 b
0x38,0x44,0x44,0x44,0x20, // 63 c
0x38,0x44,0x44,0x48,0x7f, // 64 d
0x38,0x54,0x54,0x54,0x18, // 65 e
0x08,0x7e,0x09,0x01,0x02, // 66 f
0x0c,0x52,0x52,0x52,0x3e, // 67 g
0x7f,0x08,0x04,0x04,0x78, // 68 h
0x00,0x44,0x7d,0x40,0x00, // 69 i
0x20,0x40,0x44,0x3d,0x00, // 6a j
0x7f,0x10,0x28,0x44,0x00, // 6b k
0x00,0x41,0x7f,0x40,0x00, // 6c l
0x7c,0x04,0x18,0x04,0x78, // 6d m
0x7c,0x08,0x04,0x04,0x78, // 6e n
0x38,0x44,0x44,0x44,0x38, // 6f o
0x7c,0x14,0x14,0x14,0x08, // 70 p
0x08,0x14,0x14,0x18,0x7c, // 71 q
0x7c,0x08,0x04,0x04,0x08, // 72 r
0x48,0x54,0x54,0x54,0x20, // 73 s
0x04,0x3f,0x44,0x40,0x20, // 74 t
0x3c,0x40,0x40,0x20,0x7c, // 75 u
0x1c,0x20,0x40,0x20,0x1c, // 76 v
0x3c,0x40,0x30,0x40,0x3c, // 77 w
0x44,0x28,0x10,0x28,0x44, // 78 x
0x0c,0x50,0x50,0x50,0x3c, // 79 y
0x44,0x64,0x54,0x4c,0x44, // 7a z
0x00,0x08,0x36,0x41,0x00, // 7b
0x00,0x00,0x7f,0x00,0x00, // 7c
0x00,0x41,0x36,0x08,0x00, // 7d
0x10,0x08,0x08,0x10,0x08, // 7e
0x78,0x46,0x41,0x46,0x78}; // 7f
BYTE const font_bold1 [48][8]={
0, 0, 0, 0, 0, 0, 0, 0, //' '
0, 6, 95, 95, 6, 0, 0, 0, //'!'
0, 7, 7, 0, 7, 7, 0, 0, //'"'
20, 127, 127, 20, 127, 127, 20, 0, //'#'
36, 46, 107, 107, 58, 18, 0, 0, //'$'
70, 102, 48, 24, 12, 102, 98, 0, //'%'
48, 122, 79, 93, 55, 122, 72, 0, //'&'
4, 7, 3, 0, 0, 0, 0, 0, //'''
0, 28, 62, 99, 65, 0, 0, 0, //'('
0, 65, 99, 62, 28, 0, 0, 0, //')'
8, 42, 62, 28, 28, 62, 42, 8, //'*'
8, 8, 62, 62, 8, 8, 0, 0, //'+'
0, 128, 224, 96, 0, 0, 0, 0, //','
8, 8, 8, 8, 8, 8, 0, 0, //'-'
0, 0, 96, 96, 0, 0, 0, 0, //'.'
96, 48, 24, 12, 6, 3, 1, 0, //'/'
62, 127, 113, 89, 77, 127, 62, 0, //'0'
64, 66, 127, 127, 64, 64, 0, 0, //'1'
98, 115, 89, 73, 111, 102, 0, 0, //'2'
34, 99, 73, 73, 127, 54, 0, 0, //'3'
24, 28, 22, 83, 127, 127, 80, 0, //'4'
39, 103, 69, 69, 125, 57, 0, 0, //'5'
60, 126, 75, 73, 121, 48, 0, 0, //'6'
3, 3, 113, 121, 15, 7, 0, 0, //'7'
54, 127, 73, 73, 127, 54, 0, 0, //'8'
6, 79, 73, 105, 63, 30, 0, 0, //'9'
0, 0, 102, 102, 0, 0, 0, 0, //':'
0, 128, 230, 102, 0, 0, 0, 0, //';'
8, 28, 54, 99, 65, 0, 0, 0, //'<'
36, 36, 36, 36, 36, 36, 0, 0, //'='
0, 65, 99, 54, 28, 8, 0, 0, //'>'
2, 3, 81, 89, 15, 6, 0, 0, //'?'
62, 127, 65, 93, 93, 31, 30, 0, //'@'
124, 126, 19, 19, 126, 124, 0, 0, //'A'
65, 127, 127, 73, 73, 127, 54, 0, //'B'
28, 62, 99, 65, 65, 99, 34, 0, //'C'
65, 127, 127, 65, 99, 62, 28, 0, //'D'
65, 127, 127, 73, 93, 65, 99, 0, //'E'
65, 127, 127, 73, 29, 1, 3, 0, //'F'
28, 62, 99, 65, 81, 115, 114, 0, //'G'
127, 127, 8, 8, 127, 127, 0, 0, //'H'
0, 65, 127, 127, 65, 0, 0, 0, //'I'
48, 112, 64, 65, 127, 63, 1, 0, //'J'
65, 127, 127, 8, 28, 119, 99, 0, //'K'
65, 127, 127, 65, 64, 96, 112, 0, //'L'
127, 127, 14, 28, 14, 127, 127, 0, //'M'
127, 127, 6, 12, 24, 127, 127, 0, //'N'
28, 62, 99, 65, 99, 62, 28, 0, //'O'
};
BYTE const font_bold2 [48][8]={
65, 127, 127, 73, 9, 15, 6, 0, //'P'
30, 63, 33, 113, 127, 94, 0, 0, //'Q'
65, 127, 127, 9, 25, 127, 102, 0, //'R'
38, 111, 77, 89, 115, 50, 0, 0, //'S'
3, 65, 127, 127, 65, 3, 0, 0, //'T'
127, 127, 64, 64, 127, 127, 0, 0, //'U'
31, 63, 96, 96, 63, 31, 0, 0, //'V'
127, 127, 48, 24, 48, 127, 127, 0, //'W'
67, 103, 60, 24, 60, 103, 67, 0, //'X'
7, 79, 120, 120, 79, 7, 0, 0, //'Y'
71, 99, 113, 89, 77, 103, 115, 0, //'Z'
0, 127, 127, 65, 65, 0, 0, 0, //'['
1, 3, 6, 12, 24, 48, 96, 0, //'\'
0, 65, 65, 127, 127, 0, 0, 0, //']'
8, 12, 6, 3, 6, 12, 8, 0, //'^'
128, 128, 128, 128, 128, 128, 128, 128, //'_'
0, 0, 3, 7, 4, 0, 0, 0, //'`'
32, 116, 84, 84, 60, 120, 64, 0, //'a'
65, 127, 63, 72, 72, 120, 48, 0, //'b'
56, 124, 68, 68, 108, 40, 0, 0, //'c'
48, 120, 72, 73, 63, 127, 64, 0, //'d'
56, 124, 84, 84, 92, 24, 0, 0, //'e'
72, 126, 127, 73, 3, 2, 0, 0, //'f'
152, 188, 164, 164, 248, 124, 4, 0, //'g'
65, 127, 127, 8, 4, 124, 120, 0, //'h'
0, 68, 125, 125, 64, 0, 0, 0, //'i'
96, 224, 128, 128, 253, 125, 0, 0, //'j'
65, 127, 127, 16, 56, 108, 68, 0, //'k'
0, 65, 127, 127, 64, 0, 0, 0, //'l'
124, 124, 24, 56, 28, 124, 120, 0, //'m'
124, 124, 4, 4, 124, 120, 0, 0, //'n'
56, 124, 68, 68, 124, 56, 0, 0, //'o'
132, 252, 248, 164, 36, 60, 24, 0, //'p'
24, 60, 36, 164, 248, 252, 132, 0, //'q'
68, 124, 120, 76, 4, 28, 24, 0, //'r'
72, 92, 84, 84, 116, 36, 0, 0, //'s'
0, 4, 62, 127, 68, 36, 0, 0, //'t'
60, 124, 64, 64, 60, 124, 64, 0, //'u'
28, 60, 96, 96, 60, 28, 0, 0, //'v'
60, 124, 112, 56, 112, 124, 60, 0, //'w'
68, 108, 56, 16, 56, 108, 68, 0, //'x'
156, 188, 160, 160, 252, 124, 0, 0, //'y'
76, 100, 116, 92, 76, 100, 0, 0, //'z'
8, 8, 62, 119, 65, 65, 0, 0, //'{'
0, 0, 0, 119, 119, 0, 0, 0, //'|'
};
char charsel;
void dt_lcd_init(void);
void dt_lcd_clear_screen(void);
void dt_lcd_write_command(char bytefor_command);
void dt_lcd_write_data(char bytefor_data);
void dt_lcd_write_dorc(char bytefor);
void dt_lcd_gotoxy(byte x_col, byte y_row);
void dt_lcd_printchar(byte cvar);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void dt_lcd_init(void)
{
dt_cs=1;
dt_sclk=1;
dt_rst = 0;
delay_ms(10);
dt_rst = 1;
delay_ms(1);
dt_lcd_write_command(0xe2); // reset
dt_lcd_write_command(0xa0); // ADC select: normal
dt_lcd_write_command(0xc0); // SHL select:
dt_lcd_write_command(0xb2); // LCD bias select:
dt_lcd_write_command(0x2c); // Voltage converter ON
delay_ms(1);
dt_lcd_write_command(0x2e); // Voltage regulator ON
delay_ms(1);
dt_lcd_write_command(0x2f); // Voltage follower ON
dt_lcd_write_command(0x25); // Regulator resistor select 0x20..0x27
dt_lcd_write_command(0x81); // Reference voltage register set
dt_lcd_write_command(0x18); // Reference voltage 0..63
dt_lcd_write_command(0x40); // initial display line 0x40..0x7f
dt_lcd_write_command(0xaf); // display ON
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void dt_lcd_clear_screen(void)
{
char xx,yy;
// RAM set to zero
for (yy=0;yy!=8;yy++){
dt_lcd_gotoxy(0,yy);
printf(dt_lcd_printchar," ");
//printf("yy=%u ",yy);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void dt_lcd_write_command(char bytefor_command)
{
dt_cs=0;
//nop;nop;nop;nop;
dt_rs=0;
dt_lcd_write_dorc(bytefor_command);
dt_cs=1;
}
/////////////////////////////////////////////////////////////////////////////////
void dt_lcd_write_data(char bytefor_data)
{
dt_cs=0;
//nop;nop;nop;nop;
dt_rs=1;
dt_lcd_write_dorc(bytefor_data); // write display data
dt_cs=1;
}
//////////////////////////////////////////////////////////////////////////////////
void dt_lcd_write_dorc(char bytefor) // serial write data or command subroutine
{
char caa;
for (caa=8;caa>0;caa--) {
dt_sclk=0;
// delay_us(2);
if ((bytefor&0x80)==0){dt_sid=0;}
else {dt_sid=1;}
//nop;nop;
dt_sclk=1;
bytefor=bytefor<<1;
//nop;nop;
}
}
//////////////////////////////////////////////////////////////////////////////////
void dt_lcd_gotoxy(byte x_col, byte y_row) // Position cursor
{
char hi_col,lo_col;
//x_col+=0x24;
lo_col= (x_col&0x0f);
//printf(" lo_col=%u ",lo_col);
hi_col= ((x_col>>4)&0x0f)|0x10;
//printf(" hi_col=%u ",hi_col);
dt_lcd_write_command(hi_col); // set higher column address
dt_lcd_write_command(lo_col); // set lower column address
dt_lcd_write_command(0xb0|(y_row&0x0f)); // set GDDRAM page address 0..7 (for 8 rows)
//printf(" y_row=%u ",y_row);
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
void dt_lcd_printchar(byte cvar) // Write 1 character to LCD
{
charsel=cvar;
int i;
for ( i = 0; i < 5; i++ ){
if(charsel<0x50) dt_Lcd_Write_data(TABLE5[charsel - 0x20][i] << 1);
else if(charsel>0x4f) dt_Lcd_Write_data(TABLE6[charsel - 0x50][i] << 1);
} // send data to nokia
dt_lcd_write_data(0x00); // 1 byte (always blank)
}
void lcd_printchar(byte cvar) // Write 1 character to LCD
{
charsel=cvar;
int i;
for ( i = 0; i < 8; i++ ){
if(charsel<0x50) dt_Lcd_Write_data(font_bold1[charsel - 0x20][i] << 1);
else if(charsel>0x4f) dt_Lcd_Write_data(font_bold2[charsel - 0x50][i] << 1);
} // send data to nokia
dt_lcd_write_data(0x00); // 1 byte (always blank)
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| [/code] |
|