📄 lcd_driver.c
字号:
/* * linux/drivers/video/lcd_driver.c
* The driver for YXD-240128V6 LCD of stone board. */
static unsigned int lcd_text_start;
static unsigned int lcd_graph_start;
static void lcd_controller_init(); //controller reset,if we connect the rst pin to gpio
static int lcd_busy_check(); //write busy check,the other status,we ignore
static int lcd_cmd_in(); //write cmd code to lcd controller
static int lcd_data_in(); //write data to lcd controller
static void Write_LCD_CmdCode(unsigned char cmd) /* Command only command code write routine */
{
if(!lcd_busy_check())return;
lcd_cmd_in(cmd);
}
static void Write_LCD_CmdData(unsigned char cmd,unsigned char dat1,unsigned char dat2) /* Command whith paramater write (1 byte) routine */
{
if(!lcd_busy_check())return;
lcd_data_in(dat1);
if(!lcd_busy_check())return;
lcd_data_in(dat2);
if(!lcd_busy_check())return;
lcd_cmd_in(cmd);
}
static void lcd_Text_Home_Address(unsigned int addr) //set text home address in extern ram
{
lcd_text_start=addr;
Write_LCD_CmdData(0x40,addr%256,addr/256); //value of addr must be set by user
}
static void lcd_Graph_Home_Address(unsigned int addr) //set graphic home address in extern ram
{
lcd_graph_start=addr;
Write_LCD_CmdData(0x42,addr%256,addr/256);
}
static void lcd_Text_Address(unsigned char x, unsigned char y) //set text address in extern ram
{
unsigned int xy;
xy=y*32+x+lcd_text_start;
Write_LCD_CmdData(0x24,xy%256,xy/256);
}
static void lcd_Graph_Address(unsigned char x,unsigned char y)//set graphic address in extern ram
{
unsigned int xy;
xy=y*32+x+lcd_graph_start;
Write_LCD_CmdData(0x24,xy%256,xy/256);
}
static void lcd_clear_data(void)
{
int i=0;
Write_LCD_Cmd(0x24,0,0);
Write_LCD_Cmd(0xb0);
for(i<0x2000;i++)lcd_data_in(0);
Write_LCD_Cmd(0xb2);
}
static void Init_LCD(void)
{
lcd_controller_init(); //hard ware reset
Write_LCD_Cmd(0x90); //display off
lcd_clear_data(); //clear display ram
Write_LCD_CmdData(0x41,0x20,0x00);/* Text area set = 32 columns */
Write_LCD_CmdData(0x43,0x20,0x00);/* Graphic area set = 32 columns */
Write_LCD_Cmd(0x89);
Write_LCD_Cmd(0xa1); //curse set
Write_LCD_Cmd(0x9c); //enable text and graph
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -