📄 lcd.c
字号:
#include "em78p860.h"
#define DISPLAY_LINE_LEN 20
indir char lcd_current_addr;
const char lcd_word_table1[]=
{
0,0x00,0x00,0x00,0x00,0x00, //space ,ASCII is 0x20,32
1,0x00,0x00,0x79,0x00,0x00,//00000000b,00000000b,01111001,0000000,0000000, //!
2,0x00,0x70,0x00,0x60,0x00,//00000000b,01110000b,00000000,0110000,00000000,//"
3,0x14,0x7f,0x14,0x7f,0x14,//00010100,01111111,00010100,01111111,00010100,//#
4,0x12,0x2a,0x7f,0x2a,0x24,//00010010,00101010,01111111,00101010,00100100,//$
5,0x62,0x64,0x08,0x03,0x23,//01100010,01100100,00001000,00010011,00100011,//%
6,0x36,0x49,0x35,0x02,0x0d,//00110110,01001001,00110101,00000010,00001101,//&
7,0x00,0x50,0x60,0x00,0x00,//00000000,01010000,01100000,00000000,00000000,//'
8,0x00,0x1c,0x22,0x00,0x00,//00000000,00011100,00100010,00000000,00000000,//(
9,0x00,0x1c,0x22,0x41,0x00,//00000000,00011100,00100010,01000001,00000000,//)
10,0x22,0x14,0x7f,0x14,0x22,//00100010,00010100,01111111,00010100,00100010,//*
11,0x08,0x08,0x3e,0x08,0x08,//00001000,00001000,00111110,00001000,00001000,//+
12,0x00,0x05,0x06,0x00,0x00,//00000000,00000101,00000110,00000000,00000000,//,
13,0x08,0x08,0x08,0x08,0x08,//00001000,00001000,00001000,00001000,00001000//-
14,0x00,0x03,0x03,0x00,0x00,//00000000,00000011,00000011,00000000,00000000,//.
15,0x02,0x0c,0x08,0x10,0x10,//00000010,00001100,00001000,00010000,00100000,// /
16,0x3e,0x45,0x49,0x51,0x3e,//00111110,01000101,01001001,01010001,00111110,//0
17,0x00,0x21,0x3f,0x01,0x00,//00000000,00100001,01111111,00000001,00000000,//:1
18,0x21,0x43,0x45,0x49,0x31,//00100001,01000011,01000101,01001001,00110001//:2
19,0x42,0x41,0x51,0x61,0x46,//01000010,01000001,01010001,01101001,01000110,//:3
20,0x0c,0x14,0x24,0x7f,0x04,//00001100,00010100,00100100,01111111,00000100,//:4
};
const char lcd_word_table2[]=
{
21,0x72,0x51,0x51,0x51,0x4e,//01110010,01010001,01010001,01010001,01001110//:5
22,0x1e,0x29,0x49,0x49,0x06,//00011110,00101001,01001001,01001001,00000110//:6
23,0x40,0x40,0x47,0x58,0x60,//01000000,01000000,01000111,01011000,01100000//:7
24,0x36,0x49,0x49,0x49,0x36,//00110110,01001001,01001001,01001001,00110110//:8
25,0x30,0x49,0x49,0x4a,0x3c,//00110000,01001001,01001001,01001010,00111100,//:9
26,0x00,0x36,0x36,0x00,0x00,//00000000,00110110,00110110,00000000,00000000,//:
27,0x00,0x35,0x36,0x00,0x00,//00000000,00110101,00110110,00000000,00000000,//;
28,0x08,0x14,0x22,0x21,0x00,//00001000,00010100,00100010,00100001,00000000,//<
29,0x34,0x34,0x34,0x34,0x34,//00110100,00110100,00110100,00110100,00110100,//==
30,0x00,0x21,0x22,0x14,0x08,//00000000,00100001,00100010,00010100,00001000,//>
31,0x20,0x40,0x45,0x48,0x30,//00100000,01000000,01000101,01001000,00110000,//?
32,0x3e,0x41,0x5d,0x55,0x3c,//00111110,01000001,01011101,01010101,00111100,//@
33,0x1f,0x24,0x44,0x24,0x1f,//00011111,00100100,01000100,00100100,00011111,//A
34,0x7f,0x49,0x49,0x49,0x36,//01111111,01001001,01001001,01001001,00110110,//B
35,0x3e,0x41,0x41,0x41,0x22,//00111110,01000001,01000001,01000001,00100010,//C
36,0x7f,0x49,0x41,0x22,0x1c,//01111111,01000001,01000001,00100010,00011100,//D
37,0x7f,0x49,0x49,0x49,0x41,//01111111,01001001,01001001,01001001,01000001,//E
38,0x7f,0x48,0x48,0x48,0x40,//01111111,01001000,01001000,01001000,01000000,//F
39,0x3e,0x41,0x49,0x49,0x2f,//00111110,01000001,01001001,01001001,00101111,//G
40,0x00,0x41,0x7f,0x41,0x00,//00000000,01000001,01111111,01000001,00000000,//I
41,0x02,0x41,0x41,0x7e,0x40,//00000010,01000001,01000001,01111110,01000000,//J
};
const char lcd_word_table3[]=
{
42,0x7f,0x08,0x14,0x22,0x41,//01111111,00001000,00010100,00100010,01000001,//K
43,0x7f,0x01,0x01,0x01,0x01,//01111111,00000001,00000001,00000001,00000001,//L
44,0x7f,0x20,0x18,0x40,0x7f,//01111111,00100000,00011000,00100000,01111111,//M
45,0x7f,0x10,0x08,0x04,0x7f,//01111111,00010000,00001000,00000100,01111111,//N
46,0x3e,0x41,0x41,0x41,0x3e,//00111110,01000001,01000001,01000001,00111110,//O
47,0x7f,0x48,0x48,0x48,0x30,//11111111,01001000,01001000,01001000,00110000,//P
48,0x3e,0x41,0x45,0x42,0x3d,//00111110,01000001,01000101,01000010,00111101,//Q
49,0x7f,0x48,0x4c,0x4a,0x31,//01111111,01001000,01001100,01001010,00110001,//R
50,0x7f,0x48,0x4c,0x4a,0x31,//00110010,01001001,01001001,01001001,00100110,//S
51,0x40,0x40,0x7f,0x40,0x40,//01000000,01000000,01111111,01000000,01000000,//T
52,0x7e,0x01,0x01,0x01,0x7e,//01111110,00000001,00000001,00000001,01111110,//U
53,0x7c,0x02,0x01,0x02,0x74,//01111100,00000010,00000001,00000010,01111100,//V
54,0x7e,0x01,0x0e,0x01,0x7e,//01111110,00000001,00001110,00000001,01111110,//W
55,0x63,0x34,0x08,0x14,0x33,//01100011,00110100,00001000,00010100,01100011,//X
56,0x60,0x10,0x0f,0x10,0x60,//01100000,00010000,00001111,00010000,01100000,//Y
57,0x43,0x45,0x49,0x51,0x61,//01000011,01000101,01001001,01010001,01100001,//Z
58,0x00,0x7f,0x41,0x41,0x00,//00000000,01111111,01000001,01000001,00000000,//[
59,0x20,0x10,0x08,0x04,0x02,//00100000,00010000,00001000,00000100,00000010,//\//
60,0x00,0x41,0x41,0x7f,0x00,//00000000,01000001,01000001,01111111,00000000,//]
61,0x10,0x20,0x40,0x20,0x10,//00010000,00100000,01000000,00100000,00010000,//^
62,0x01,0x01,0x01,0x01,0x01 //00000001,00000001,00000001,00000001,00000001,//_
};
void init_lcd()
{
// char regdata;
regdata=IOCA;
regdata|=0xC0;
IOCA=regdata;
regdata=IOCE;
regdata|=0x28;
regdata&=~(0x14);
IOCE=regdata;
regdata=RE;
regdata|=0x06;
RE=regdata;
}
//because port mulriple using key scan and lcd com
//P6S=1---LCD P6S=0--------key scan
void change_port6_function(char flag)
{
regdata=IOCE;
if(flag)
regdata|=0x20;
else
regdata&=~0x20;
IOCE=regdata;
}
//control RE bit1 and bit2
void turn_off_lcd()
{
regdata=RE;
regdata&=~0x06;
RE=regdata;
}
void blank_lcd()
{
regdata=RE;
regdata&=~0x04;
regdata|=0x02;
RE=regdata;
}
void enable_lcd()
{
regdata|=0x06;
RE=regdata;
}
void lcd_clear()
{
uchar i;
for(i=0;i<0x3b;i++)
{
IOCB=i;
IOCC=0x00;
}
for(i=0x40;i<0x7b;i++)
{
IOCB=i;
IOCC=0x00;
}
}
/*
* pos is LCD main display erea, from 0---19
*/
void lcd_display(uchar pos,const char *str, uchar len)
{
char addr;
char index;
char i=0,j=0;
char data;
char tmp;
while(len)
{
if( pos <DISPLAY_LINE_LEN/2)
{
if(pos%2)
{//odd
addr =(10-pos)*5 + ((pos-1)/2)*5 ;
}
else
{
//even
addr =(pos/2)*5 ;
}
}
else
{
if(pos%2)
{
//odd
addr= ((DISPLAY_LINE_LEN-pos-1)/2)*5;
}
else
{
//even
addr =(((pos-10)/2)+1)*5+20;
}
}
// index=index_lcd_table(str[i]);
_asm
{
mov a,%i
mov 0x14,a
mov a, %str
mov 0x4,a
mov a,0x0
add a,0x14
mov %data,a
}
// data=*(str +i);
// index=data-0x35;
// index='b'-0x20;
for(j=1;j<6;j++)
{
IOCB=addr +j-1;
if(pos%2)
{
if(data>31 &&data <52)
{
index=data-32;
IOCC=lcd_word_table1[index*6 +(6-j)];
}
else if(data >51 &&data<74)
{
index=data-53;
IOCC=lcd_word_table2[index*6 +(6-j)];
}
else if(data >73 &&data<95)
{
index=data-74;
IOCC=lcd_word_table3[index*6 +(6-j)];
}
}
else
{
// IOCC=lcd_word_table[index*6 +j];
if(data>31 &&data <52)
{
index=data-32;
IOCC=lcd_word_table1[index*6 +j];
}
else if(data >51 &&data<74)
{
index=data-53;
IOCC=lcd_word_table2[index*6 +j];
}
else if(data >73 &&data<95)
{
index=data-74;
IOCC=lcd_word_table3[index*6 +j];
}
}
}
++pos;
--len;
++i;
}
}
void lcd_append_str(const char *str,uchar len)
{
char pos;
pos =DISPLAY_LINE_LEN- lcd_current_addr;
lcd_display(pos,str,len);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -