📄 lcm.c
字号:
#include <avr/io.h>
#include <avr/delay.h>
#include <avr/pgmspace.h>
//#include <avr/stdint.h>
#include "main.h"
#include "LCM.h"
#include "dataflash.h"
typedef unsigned long int uint32_t;
//#include "main.h"
uchar Row_RAM[32];
static uchar Column_RAM[32];
//const char LCM_RAM[] PROGMEM ="496045420";
/*uchar const LCM_RAM[128]=
{
0x00,0x00,0x00,0x04,0x07,0xBE,0x74,0x84,0x55,0x04,0x56,0x74,0x55,0x54,0x55,0x54,
0x55,0x54,0x75,0x74,0x57,0x04,0x04,0x04,0x04,0x04,0x04,0x14,0x04,0x08,0x00,0x00,// 11:52:56
0x00,0x00,0x00,0x08,0x7B,0xFC,0x48,0x10,0x50,0x10,0x53,0xD0,0x62,0x50,0x52,0x50,
0x4A,0x50,0x4B,0xD0,0x6A,0x50,0x50,0x10,0x40,0x10,0x40,0x50,0x40,0x20,0x00,0x00,// 11:52:56
0x00,0x00,0x10,0x40,0x10,0x50,0x10,0x88,0x11,0xFC,0x7C,0x04,0x10,0x88,0x11,0xFC,
0x12,0x20,0x10,0x24,0x15,0xFE,0x18,0x50,0x60,0x90,0x01,0x08,0x06,0x06,0x00,0x00,// 11:52:56
0x00,0x00,0x08,0x40,0x08,0x40,0x08,0x88,0x7D,0xFC,0x08,0x04,0x09,0x08,0x0D,0xFC,
0x1A,0x20,0x68,0x24,0x0B,0xFE,0x08,0x50,0x08,0x90,0x29,0x08,0x12,0x06,0x00,0x00,// 11:52:56
};*/
uint32_t Hex_Bcd(uint16_t hex_byte)
{
uint16_t i1, i2, i3,i4;
uint32_t j1,j2;
i1 = hex_byte%10000;
i2 = hex_byte%1000;
i3 = hex_byte%100;
j1 = (uint32_t)hex_byte/10000 <<16;
j1 =j1 | i1/1000<<12;
j1 =j1 | i2/100 <<8;
j1 =j1 | i3/10 <<4;
j1 =j1 | i3%10;
asm("nop");
return(j1);
}
void delay(unsigned int t) // 延时子程序
{
unsigned int k,n;
for(k=0;k<t;k++)
{
for(n=0;n<10;n++)
{
asm("nop");
}
}
}
void send()
{
asm("nop");
asm("nop");
LCM_SCL_S;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
LCM_SCL_C;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
LCM_SCL_S;
asm("nop");
asm("nop");
}
void wbyted(unsigned char dat)
{
unsigned char i,p;
LCM_SCL_S;
asm("nop");
asm("nop");
LCM_CS_C;
asm("nop");
asm("nop");
LCM_RS_S; //A0
asm("nop");
asm("nop");
for(i=0;i<8;i++)
{
p=dat&0x80;
if(p==0x80)
{
LCM_SI_S;
asm("nop");
asm("nop");
send();
}
else
{
LCM_SI_C;
asm("nop");
asm("nop");
send();
}
dat=dat<<1;
}
LCM_CS_S; //addition
asm("nop");
}
void wbytec(unsigned char cmd)
{
unsigned char i,p;
LCM_SCL_S;
asm("nop");
asm("nop");
LCM_CS_C;
asm("nop");
asm("nop");
LCM_RS_C;
asm("nop");
asm("nop");
for(i=0;i<8;i++)
{
p=cmd&0x80;
if(p==0x80)
{
LCM_SI_S;
asm("nop");
asm("nop");
send();
}
else
{
LCM_SI_C;
asm("nop");
asm("nop");
send();
}
cmd=cmd<<1;
}
LCM_CS_S; //addition
asm("nop");
}
void lcm_reset()
{
LCM_CS_C;
asm("nop");
asm("nop");
LCM_RST_C;
asm("nop");
asm("nop");
delay(10);
LCM_RST_S;
asm("nop");
asm("nop");
wbytec(0xe2); //reset;
wbytec(0xa2); //设置BIAS 1/7; =1/6
wbytec(0xc8);
wbytec(0x2c); //VC ON;
delay(20);
wbytec(0x2e); //VR ON;
delay(20);
wbytec(0x2f); //VF ON;
delay(20);
wbytec(0x81); //设置电压调整
wbytec(0x31);
wbytec(0x23); //设置电阻分压
wbytec(0xaf); //lcd显示;
wbytec(0x60); //显示从COM33开始;
asm("nop");
}
void display_up(uint8_t counter)
{
unsigned char j;
for(j=0;j<counter;j++) //129
{
//wbyted(0xA1);
//wbyted(LCM_RAM[j]);
asm("nop");
wbyted(DF_READ_BUFFER[j]);
}
}
void display_down16(uint8_t counter)
{
unsigned char j;
for(j=0;j<counter;j++) //129
{
//wbyted(0xA1);
//wbyted(LCM_RAM[j]);
asm("nop");
wbyted(DF_READ_BUFFER[j+16]);
}
}
void display_down8(uint8_t counter)
{
unsigned char j;
for(j=0;j<counter;j++) //129
{
//wbyted(0xA1);
//wbyted(LCM_RAM[j]);
asm("nop");
wbyted(DF_READ_BUFFER[j+8]);
}
}
void lcm_16x16(uint8_t page, uint16_t column, uint16_t word_no)
{
uint32_t k001;
uint16_t k002;
uint8_t k003,k004,k005;
if(word_no < 0x2021)
{
lcm_8x16(0xb1, column, 0x20);
lcm_8x16(0xb1, (column+8), 0x20);
}
else if(word_no < 0xA1CA)
{
k004= (uint8_t)((column>>8)&0xff);
k005= (uint8_t)(column&0xff);
k002 = word_no -0xa1a2;
k001 = (uint32_t)k002 *0x20 +0x600;
k002 = (uint16_t) (k001/0x100);
k003 = (uint8_t)(k001%0x100);
asm("nop");
read_array_to_ram(k002,k003,0x20);
asm("nop");
wbytec(page);
wbytec(k004);
wbytec(k005);
asm("nop");
display_up(16);
wbytec(page+1);
wbytec(k004);
wbytec(k005);
asm("nop");
display_down16(16);
asm("nop");
}
else if(word_no < 0xA3C0)
{
k004= (uint8_t)((column>>8)&0xff);
k005= (uint8_t)(column&0xff);
k002 = word_no -0xa3a1;
k001 = (uint32_t)k002 *0x20 +0xb00;
k002 = (uint16_t) (k001/0x100);
k003 = (uint8_t)(k001%0x100);
asm("nop");
read_array_to_ram(k002,k003,0x20);
asm("nop");
wbytec(page);
wbytec(k004);
wbytec(k005);
asm("nop");
display_up(16);
wbytec(page+1);
wbytec(k004);
wbytec(k005);
asm("nop");
display_down16(16);
asm("nop");
}
else if(word_no < 0xb0a0)
{
lcm_8x16(0xb1, column, 0x20);
lcm_8x16(0xb1, (column+8), 0x20);
}
else if(word_no > 0xf800)
{
lcm_8x16(0xb1, column, 0x20);
lcm_8x16(0xb1, (column+8), 0x20);
}
else
{
k004= (uint8_t)((column>>8)&0xff);
k005= (uint8_t)(column&0xff);
k002 = ((word_no >>8)-0xb0)*94 + (word_no &0x00ff) -0xa1;
k001 = (uint32_t)k002 *0x20 +0x1000;
k002 = (uint16_t) (k001/0x100);
k003 = (uint8_t)(k001%0x100);
asm("nop");
read_array_to_ram(k002,k003,0x20);
asm("nop");
wbytec(page);
wbytec(k004);
wbytec(k005);
asm("nop");
display_up(16);
wbytec(page+1);
wbytec(k004);
wbytec(k005);
asm("nop");
display_down16(16);
asm("nop");
}
}
void lcm_8x16(uint8_t page, uint16_t column, uint8_t char_no)
{
uint32_t k001;
uint16_t k006;
uint8_t k002,k003,k004,k005;
k002= (char_no-0x20);
k006= (uint16_t)k002*0x10;
k002 = (uint8_t) (k006/0x100);
k003 = (uint8_t)(k006%0x100);
k004 = (uint8_t)(column>>8);
k005 = (uint8_t)(column &0xff);
asm("nop");
read_array_to_ram(k002,k003,0x10);
asm("nop");
wbytec(page);
wbytec(k004);
wbytec(k005);
display_up(8);
wbytec(page+1);
wbytec(k004);
wbytec(k005);
asm("nop");
display_down8(8);
asm("nop");
}
void display_clr()
{
unsigned char j;
for(j=0;j<129;j++) //129
{
asm("nop");
// wbyted(0x10);
wbyted(0x0);
}
}
void lcm_clr()
{
uint8_t i;
asm("nop");
for(i=0; i<8; i++)
{
wbytec(0xb0+i);
wbytec(0x10);
wbytec(0x00);
display_clr();
}
asm("nop");
}
void show_company(void)
{
uint16_t ii;
uint16_t ip;
uint32_t is;
uint8_t gh,gm,gl,i;
Error_B_1;
if(Card_Show_Time <5) //card freshed show name
{
asm("nop");
if(Clr_LCD_Flag)
{
asm("nop");
wbytec(0xb1);
wbytec(0x10);
wbytec(0x00);
display_clr();
wbytec(0xb1);
wbytec(0x10);
wbytec(0x10);
display_clr();
wbytec(0xb2);
wbytec(0x10);
wbytec(0x00);
display_clr();
Clr_LCD_Flag=0;
}
if(Buz_uc_flag) //the name code not charged, don't show any
{
asm("nop");
}
else
{
is = Hex_Bcd(Record_List_No);
gh =(uint8_t) (is >>16);
gm = (uint8_t)( is >>8);
gl =(uint8_t)(is &0x00ff);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -