📄 lcm320240.c
字号:
#include "LCM320240.h"
//"config.h"
void LCMFirst(void)
{
uint8 str[]="北京恒银金融科技有限公司";
uint8 str2[]="后台维护系统";
uint8 str3[]="~~~~~~~~~~~~~~~~~~~~";
LCD_CmdWrite(0x00,0xCD);
LCD_CmdWrite(0x60,0x08); //列
LCD_CmdWrite(0x70,0x010); //行
LCM_String(str);
LCD_CmdWrite(0x60,0x00); //列
LCD_CmdWrite(0x70,0x020); //行
LCM_String(str3);
LCD_CmdWrite(0x60,0x0e); //列
LCD_CmdWrite(0x70,0x070); //行
LCM_String(str2);
///
}
void LCD_CmdWrite(uint8 cmd,uint8 data)
{
LCD_ChkBusy();
IO0CLR=BUSY;
LCD_Cmd = cmd;
//.................................................................
LCD_ChkBusy();
LCD_Cmd = data;
}
void delay(int i)
{
int k ;
for ( k=0 ; k < i ; k++ );
}
//====================================================================//
// //
//====================================================================//
void LCD_Initial(void)
{
LCD_CmdWrite(0x00,0xCD); // LCD Control Register(LCR)
LCD_CmdWrite(0x01,0xf1); // Misc.Register(MIR)
LCD_CmdWrite(0x02,0x10); // Advance Power Setup Register(APSR)
LCD_CmdWrite(0x03,0x80); // Advance Display Setup Regiser(ADSR)
LCD_CmdWrite(0x10,0x6f); // Cursor Control Register(CCR)
LCD_CmdWrite(0x11,0x20); // Distance of Word or Lines Register(DWLR)
LCD_CmdWrite(0x12,0x91); // Memory Access Mode Register(AWRR)
LCD_CmdWrite(0x20,0x27); // Active Window Right Register(AWRR)
LCD_CmdWrite(0x30,0xEF); // Active Window Bottom Register(AWBR)
LCD_CmdWrite(0x40,0x00); // Active Window Left Register(AWLR)
LCD_CmdWrite(0x50,0x00); // Active Window Top Register(AWTR)
LCD_CmdWrite(0x21,0x27); // Display Window Right Register(DWRR)
LCD_CmdWrite(0x31,0xEF); // Display Window Bottom Register(DWBR)
LCD_CmdWrite(0x41,0x00); // Display Window Left Register(DWLR)
LCD_CmdWrite(0x51,0x00); // Display Window Top Register(DWTR)
LCD_CmdWrite(0x60,0x00); // Cursor Position X Register(CPXR)
LCD_CmdWrite(0x61,0x00); // Begin Segment Position Register(BGSG)
LCD_CmdWrite(0x70,0x00); // Cursor Position Y Register(CPYR)
LCD_CmdWrite(0x71,0x00); // Shift action range,Begin Commom Register(BGCM)
LCD_CmdWrite(0x72,0xEF); // Shift action range,End Commom Register(EDCM)
LCD_CmdWrite(0x80,0x33); // Blink Time Register(BTR)
LCD_CmdWrite(0x81,0x00); // Frame Rate Polarity Change at Common_FA Register(FDCA)
LCD_CmdWrite(0x91,0x00); // Frame Rate Polarity Change at Common_FB Register(FDCB)
LCD_CmdWrite(0x90,0x04); // Shift Clock Control Register(SCCR)
LCD_CmdWrite(0xA0,0x11); // Interrupt Setup & Status Register(FRCB)
LCD_CmdWrite(0xA1,0x00); // Key Scan Control Register(KSCR)
LCD_CmdWrite(0xA2,0x00); // Key Scan Data Register(KSDR)
LCD_CmdWrite(0xA3,0x00); // Key Scan Data Expand Register(KSER)
LCD_CmdWrite(0xB0,0x27); // Interrupt Column Setup Register(INTX)
LCD_CmdWrite(0xB1,0xEF); // Interrupt Row Setup Register(INTY)
LCD_CmdWrite(0xC0,0xD0); // Touch Panel Control Register(TPCR)
LCD_CmdWrite(0xC1,0x0A); // ADC Status Register(ADCS)
LCD_CmdWrite(0xC8,0x80); // Touch Panel Segment High Byte Data Register(TPXR)
LCD_CmdWrite(0xC9,0x80); // Touch Panel Common High Byte Data Register(TPYR)
LCD_CmdWrite(0xCA,0x00); // Touch Panel Segment/Common Low Byte Data Register(TPZR)
LCD_CmdWrite(0xD0,0x0C); // LCD Contrast Control Register (LCCR)
LCD_CmdWrite(0xE0,0x00); // Pattern Data Register(PDR)
LCD_CmdWrite(0xF0,0xA0); // Font Control Register(FCR)
LCD_CmdWrite(0xF1,0x0F); // Font Size Control Register
}
/***************************************************************/
/***************************************************************/
//****************************清屏
void LCD_Clearzf(void)
{
unsigned int i,j;
i=0;
j=0;
while(j <8)
{
while(i<15)
{
LCD_DataWrite(0xb0);
LCD_DataWrite(0xa0);
i++;
}
i=0;
j++;
}
}
void LCD_Clear(void)
{
uint8 READ_REG;
LCD_CmdWrite(0xE0,0x00);
READ_REG = 0x0A;
READ_REG&=0xF7;
READ_REG|=0x08;
LCD_CmdWrite(0xF0,READ_REG);
delay(1000);
}
/////////////////////////////
//******************************
void LCD_DataWrite(uint8 WrData)
{
delay(INT);
LCD_ChkBusy();
LCD_DATA = WrData;
}
//--- RA8803 Reset ---------------------------------------------------
void LCD_Reset(void)
{
//IO0SET=READY ; // LCD_RSWWRRRD/CS1/CS2 normal - skeep high.
IO0CLR =CS1; // RA8803 Chip Enable.
delay(2000);
IO0CLR =RST; // LCD RESET-pin active low.
delay(21000); // Reset 250ms
IO0SET=RST; // LCD RESET-pin Noraml high.
delay(2000);
IO0SET=CS1;
}
void LCM_String(unsigned char * str)
{
uint8 data;
data=*str;
while(data!='\0')
{
LCD_DataWrite(data);
str++;
data=*str;
}
}
//****************************
unsigned char LCD_CmdRead(unsigned char cmdReg)
{
uint8 data;
LCD_ChkBusy(); // 判断 RA8803 是否忙碌中
//LCD_cmdReg = cmdReg; // 写入缓存器的地址
//IO0CLR=CS1; // 致能 RA8803 读写动作
//IO0SET=RD; // 禁能读取动作
//IO0CLR=RS ; // 设定为写入数据至缓存器模式
// 开始写入缓存器的地址
LCD_Cmd = cmdReg;
//IO0SET=RS;
//IO0SET=CS1; // 致能 RA8803 读写动作
//…………………………………………………………………………………………………………………………………//
LCD_Cmd = 0xff;
//IO0CLR=CS1; // 致能 RA8803 读写动作
//LCD_WR = 1; // 禁能写入动作
//IO0CLR=RS; // 设定从缓存器读取数据模式
//IO0CLR=RD; // 开始读取缓存器的数据
data= LCD_Cmd;
//IO0SET=RD; // 致能读取缓存器
//IO0SET=RS;
//IO0SET=CS1; // 禁能 RA8803 读写动作
return data; // 回传读取缓存器的数据
}
//////////////////////////////////////////////////////////
//*******************************************************************************//
//*** 检查忙碌旗标 子程序 *******************************************************//
//*******************************************************************************//
void LCD_ChkBusy(void)
{
uint8 data;
data=IO0PIN&BUSY;
do
{
}
while(data == 1);
}
//////////////////////////////////////////////////////////
void LCMtest(void)
{
uint8 sst[]="五十多名学生涉嫌高考移民,日前被取消在京高考资格。他们都拥有北京某学口";
LCD_CmdWrite(0x20,0x27); //右
LCD_CmdWrite(0x30,0xce); //底
LCD_CmdWrite(0x40,0x40); //左
LCD_CmdWrite(0x50,0x30); //顶
/////////////////////////
LCD_CmdWrite(0x00,0xCD);
LCD_CmdWrite(0xF0,0xA0); // Font Control Register(FCR)
LCD_CmdWrite(0x60,0x0a); //列
LCD_CmdWrite(0x70,0x30); //行
LCM_String(sst);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -