2013-01-08 22:40:58 +08:00
|
|
|
/*
|
2021-03-21 23:31:45 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2013-01-08 22:40:58 +08:00
|
|
|
*
|
2021-03-21 23:31:45 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2013-01-08 22:40:58 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2011-03-05 lgnq ZYMG12864C3 LCD driver
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
2023-10-18 20:50:30 +08:00
|
|
|
#include <rtdevice.h>
|
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
#include "lcd.h"
|
|
|
|
#include "font.h"
|
|
|
|
|
|
|
|
static struct rt_device_graphic_info _lcd_info;
|
|
|
|
static rt_uint8_t gui_disp_buf[GUI_LCM_YMAX/8][GUI_LCM_XMAX];
|
|
|
|
const unsigned char BIT_MASK[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
|
|
|
/* simple font: ' ', '0'~'9','a'~'z','A'~'Z' */
|
|
|
|
extern const unsigned char FONTTYPE8_8[][8];
|
|
|
|
|
|
|
|
rt_uint32_t x;
|
|
|
|
rt_uint32_t y;
|
|
|
|
|
|
|
|
void power_delay(void)
|
|
|
|
{
|
|
|
|
rt_uint32_t i = 0x4ffff;
|
|
|
|
while(i--)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
void delay(void)
|
|
|
|
{
|
|
|
|
rt_uint8_t i = 0x8;
|
|
|
|
while(i--)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset_delay(void)
|
|
|
|
{
|
|
|
|
rt_uint8_t i = 0xff;
|
|
|
|
while(i--)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_write_cmd(unsigned char command)
|
|
|
|
{
|
|
|
|
rt_uint8_t i;
|
|
|
|
|
|
|
|
LCD_PS_LOW();
|
|
|
|
LCD_CS_LOW();
|
|
|
|
LCD_CD_LOW();
|
|
|
|
for (i=0; i<8; i++)
|
|
|
|
{
|
|
|
|
if (command & (0x80 >> i))
|
|
|
|
LCD_DATA_HIGH();
|
|
|
|
else
|
|
|
|
LCD_DATA_LOW();
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
LCD_CLK_LOW();
|
|
|
|
delay();
|
|
|
|
LCD_CLK_HIGH();
|
|
|
|
delay();
|
|
|
|
}
|
|
|
|
LCD_CS_HIGH();
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_write_data(unsigned char data)
|
|
|
|
{
|
|
|
|
rt_uint8_t i;
|
|
|
|
|
|
|
|
LCD_PS_LOW();
|
|
|
|
LCD_CS_LOW();
|
|
|
|
LCD_CD_HIGH();
|
|
|
|
for (i=0; i<8; i++)
|
|
|
|
{
|
|
|
|
if (data & (0x80 >> i))
|
|
|
|
LCD_DATA_HIGH();
|
|
|
|
else
|
|
|
|
LCD_DATA_LOW();
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
LCD_CLK_LOW();
|
|
|
|
delay();
|
|
|
|
LCD_CLK_HIGH();
|
|
|
|
delay();
|
|
|
|
}
|
|
|
|
LCD_CS_HIGH();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RT_USING_RTGUI
|
|
|
|
#include <rtgui/driver.h>
|
|
|
|
#include <rtgui/color.h>
|
|
|
|
|
|
|
|
static void rt_hw_lcd_update(struct rt_device_rect_info *rect_info)
|
|
|
|
{
|
|
|
|
rt_uint8_t i,j = GUI_LCM_XMAX;
|
2021-03-21 23:31:45 +08:00
|
|
|
rt_uint8_t* p = (rt_uint8_t*)gui_disp_buf;
|
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
for (i=0; i<GUI_LCM_PAGE; i++)
|
2021-03-21 23:31:45 +08:00
|
|
|
{
|
|
|
|
lcd_write_cmd(SET_PAGE_ADDR_0|i);
|
|
|
|
lcd_write_cmd(SET_COLH_ADDR_0);
|
2013-01-08 22:40:58 +08:00
|
|
|
lcd_write_cmd(SET_COLL_ADDR_0);
|
|
|
|
j = GUI_LCM_XMAX;
|
|
|
|
while (j--)
|
|
|
|
{
|
|
|
|
lcd_write_data(*p++);
|
|
|
|
delay();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static rt_uint8_t * rt_hw_lcd_get_framebuffer(void)
|
|
|
|
{
|
|
|
|
return(rt_uint8_t *)gui_disp_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rt_hw_lcd_set_pixel(rtgui_color_t *c, int x, int y)
|
|
|
|
{
|
|
|
|
rt_uint8_t page;
|
|
|
|
page = y/8;
|
|
|
|
|
|
|
|
if (*c == rtgui_color_to_565(black))
|
|
|
|
gui_disp_buf[page][x] |= 1<<(y%8);
|
2021-03-21 23:31:45 +08:00
|
|
|
else
|
2013-01-08 22:40:58 +08:00
|
|
|
if (*c == rtgui_color_to_565(white))
|
|
|
|
gui_disp_buf[page][x] &= ~(1<<(y%8));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rt_hw_lcd_get_pixel(rtgui_color_t *c, int x, int y)
|
|
|
|
{
|
|
|
|
rt_uint8_t page;
|
|
|
|
page = y/8;
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
if (gui_disp_buf[page][x] & (1<<(y%8)))
|
|
|
|
*c = black;
|
|
|
|
else
|
|
|
|
*c = white;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rt_hw_lcd_draw_hline(rtgui_color_t *c, int x1, int x2, int y)
|
|
|
|
{
|
|
|
|
rt_uint8_t page;
|
2021-03-21 23:31:45 +08:00
|
|
|
rt_uint8_t i;
|
2013-01-08 22:40:58 +08:00
|
|
|
page = y/8;
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
for (i=x1; i<x2; i++)
|
|
|
|
{
|
|
|
|
if (*c == rtgui_color_to_565(black))
|
|
|
|
gui_disp_buf[page][i] |= 1<<(y%8);
|
2021-03-21 23:31:45 +08:00
|
|
|
else
|
2013-01-08 22:40:58 +08:00
|
|
|
if (*c == rtgui_color_to_565(white))
|
2021-03-21 23:31:45 +08:00
|
|
|
gui_disp_buf[page][i] &= ~(1<<(y%8));
|
2013-01-08 22:40:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rt_hw_lcd_draw_vline(rtgui_color_t *c, int x, int y1, int y2)
|
|
|
|
{
|
|
|
|
rt_uint8_t y;
|
|
|
|
|
|
|
|
for (y = y1; y < y2; y ++)
|
|
|
|
{
|
|
|
|
rt_hw_lcd_set_pixel(c, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rt_hw_lcd_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y)
|
|
|
|
{
|
2021-03-21 23:31:45 +08:00
|
|
|
rt_uint8_t coll;
|
|
|
|
rt_uint8_t colh;
|
|
|
|
rt_uint8_t page;
|
|
|
|
rt_uint8_t i;
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
page = y/8;
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
for (i=x1; i<x2; i++)
|
|
|
|
{
|
|
|
|
gui_disp_buf[page][i] |= 1<<(y%8);
|
|
|
|
coll = i & 0x0f;
|
|
|
|
colh = i >> 4;
|
|
|
|
lcd_write_cmd(SET_PAGE_ADDR_0 | page);
|
|
|
|
lcd_write_cmd(SET_COLH_ADDR_0 | colh);
|
|
|
|
lcd_write_cmd(SET_COLL_ADDR_0 | coll);
|
|
|
|
lcd_write_data(gui_disp_buf[page][i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct rtgui_graphic_driver_ops _lcd_ops =
|
|
|
|
{
|
|
|
|
rt_hw_lcd_set_pixel,
|
|
|
|
rt_hw_lcd_get_pixel,
|
|
|
|
rt_hw_lcd_draw_hline,
|
|
|
|
rt_hw_lcd_draw_vline,
|
|
|
|
rt_hw_lcd_draw_raw_hline
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void lcd_io_init()
|
|
|
|
{
|
|
|
|
/* Release the analog input function*/
|
|
|
|
FM3_GPIO->ADE =0x03;
|
|
|
|
/*Select CPIO function*/
|
|
|
|
LCD_CS_PFR &= ~LCD_CS;
|
|
|
|
/*Make pin output*/
|
|
|
|
LCD_CS_DDR |= LCD_CS;
|
|
|
|
/*Select CPIO function*/
|
|
|
|
LCD_CD_PFR &= ~LCD_CD;
|
|
|
|
/*Make pin output*/
|
|
|
|
LCD_CD_DDR |= LCD_CD;
|
|
|
|
/*Select CPIO function*/
|
|
|
|
LCD_PS_PFR &= ~LCD_PS;
|
|
|
|
/*Make pin output*/
|
2021-03-21 23:31:45 +08:00
|
|
|
LCD_PS_DDR |= LCD_PS;
|
2013-01-08 22:40:58 +08:00
|
|
|
/*Select CPIO function*/
|
|
|
|
LCD_CLK_PFR &= ~LCD_CLK;
|
|
|
|
/*Make pin output*/
|
|
|
|
LCD_CLK_DDR |= LCD_CLK;
|
|
|
|
/*Select CPIO function*/
|
|
|
|
LCD_DATA_PFR &= ~LCD_DATA;
|
|
|
|
/*Make pin output*/
|
|
|
|
LCD_DATA_DDR |= LCD_DATA;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* RT-Thread Device Interface */
|
|
|
|
static rt_err_t rt_lcd_init (rt_device_t dev)
|
|
|
|
{
|
|
|
|
lcd_io_init();
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
power_delay();
|
|
|
|
lcd_write_cmd(DISPLAY_OFF);
|
|
|
|
reset_delay();
|
|
|
|
// Resetting circuit
|
|
|
|
lcd_write_cmd(RESET_LCD);
|
|
|
|
reset_delay();
|
|
|
|
// LCD bias setting
|
|
|
|
lcd_write_cmd(SET_LCD_BIAS_9);
|
|
|
|
reset_delay();
|
|
|
|
// ADC selection: display from left to right
|
2021-03-21 23:31:45 +08:00
|
|
|
lcd_write_cmd(SET_ADC_NORMAL);
|
2013-01-08 22:40:58 +08:00
|
|
|
reset_delay();
|
|
|
|
// Common output state selection: display from up to down
|
|
|
|
lcd_write_cmd(COM_SCAN_DIR_REVERSE);
|
|
|
|
reset_delay();
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
lcd_write_cmd(POWER_BOOSTER_ON);
|
|
|
|
power_delay(); // 50ms requried
|
|
|
|
lcd_write_cmd(POWER_REGULATOR_ON);
|
|
|
|
power_delay(); // 50ms
|
|
|
|
lcd_write_cmd(POWER_FOLLOWER_ON);
|
|
|
|
power_delay(); // 50ms
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
// Setting the built-in resistance radio for regulation of the V0 voltage
|
|
|
|
// Electronic volume control
|
|
|
|
// Power control setting
|
|
|
|
lcd_write_cmd(SET_ELECVOL_REG|0x05);
|
|
|
|
delay();
|
|
|
|
lcd_write_cmd(SET_ELECVOL_MODE);
|
|
|
|
delay();
|
|
|
|
lcd_write_cmd(SET_ELECVOL_REG);
|
|
|
|
delay();
|
|
|
|
// LCD_Clear();
|
|
|
|
delay();
|
|
|
|
lcd_write_cmd(SET_PAGE_ADDR_0);
|
|
|
|
delay();
|
|
|
|
lcd_write_cmd(SET_COLH_ADDR_0);
|
|
|
|
delay();
|
|
|
|
lcd_write_cmd(SET_COLL_ADDR_0);
|
|
|
|
delay();
|
|
|
|
lcd_write_cmd(DISPLAY_ON);
|
|
|
|
delay();
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
lcd_write_cmd(DISPLAY_ALL_ON);
|
|
|
|
delay();
|
|
|
|
lcd_write_cmd(DISPLAY_OFF);
|
|
|
|
delay();
|
|
|
|
lcd_write_cmd(DISPLAY_ON);
|
|
|
|
delay();
|
|
|
|
lcd_write_cmd(DISPLAY_ALL_NORMAL);
|
|
|
|
delay();
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
return RT_EOK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Function Name : LCD_FillAll
|
|
|
|
* Description : Fill the whole LCD.
|
|
|
|
* Input : None
|
|
|
|
* Output : None
|
|
|
|
* Return : None
|
|
|
|
*******************************************************************************/
|
2021-03-21 23:31:45 +08:00
|
|
|
void LCD_FillAll(unsigned char* buffer)
|
2013-01-08 22:40:58 +08:00
|
|
|
{
|
|
|
|
unsigned char i,j = GUI_LCM_XMAX;
|
2021-03-21 23:31:45 +08:00
|
|
|
unsigned char* p = buffer;
|
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
for (i=0; i<GUI_LCM_PAGE; i++)
|
2021-03-21 23:31:45 +08:00
|
|
|
{
|
|
|
|
lcd_write_cmd(SET_PAGE_ADDR_0|i);
|
|
|
|
lcd_write_cmd(SET_COLH_ADDR_0);
|
2013-01-08 22:40:58 +08:00
|
|
|
lcd_write_cmd(SET_COLL_ADDR_0);
|
|
|
|
j = GUI_LCM_XMAX;
|
|
|
|
while (j--)
|
|
|
|
{
|
|
|
|
lcd_write_data(*p++);
|
|
|
|
delay();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Function Name : LCD_ClearSCR
|
|
|
|
* Description : clean screen
|
|
|
|
* Input : None
|
|
|
|
* Output : None
|
|
|
|
* Return : None
|
|
|
|
*******************************************************************************/
|
|
|
|
void LCD_ClearSCR(void)
|
|
|
|
{
|
|
|
|
unsigned char i, j;
|
|
|
|
|
|
|
|
for(i=0; i<GUI_LCM_PAGE; i++)
|
2021-03-21 23:31:45 +08:00
|
|
|
{
|
|
|
|
for(j = 0; j < GUI_LCM_XMAX; j++)
|
2013-01-08 22:40:58 +08:00
|
|
|
gui_disp_buf[i][j] = 0;
|
|
|
|
}
|
|
|
|
LCD_FillAll((unsigned char*)gui_disp_buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Function Name : LCD_UpdatePoint
|
2021-03-21 23:31:45 +08:00
|
|
|
* Description : refresh the point in screen
|
2013-01-08 22:40:58 +08:00
|
|
|
* Input : x X-coordinate
|
|
|
|
y Y-coordinate
|
|
|
|
* Output : None
|
|
|
|
* Return : None
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void LCD_UpdatePoint(unsigned int x, unsigned int y)
|
|
|
|
{
|
|
|
|
unsigned char coll, colh, page;
|
|
|
|
page = y / 8;
|
|
|
|
coll = x & 0x0f;
|
|
|
|
colh = x >> 4;
|
2021-03-21 23:31:45 +08:00
|
|
|
|
|
|
|
lcd_write_cmd(SET_PAGE_ADDR_0 | page); // page no.
|
|
|
|
lcd_write_cmd(SET_COLH_ADDR_0 | colh); // fixed col first addr
|
2013-01-08 22:40:58 +08:00
|
|
|
lcd_write_cmd(SET_COLL_ADDR_0 | coll);
|
|
|
|
lcd_write_data(gui_disp_buf[page][x]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Function Name : LCD_PutChar
|
2021-03-21 23:31:45 +08:00
|
|
|
* Description : output a char to screen
|
2013-01-08 22:40:58 +08:00
|
|
|
(the char only can be ' ','0'~'9','A'~'Z','a'~'z')
|
|
|
|
* Input : x X-coordinate
|
|
|
|
y Y-coordinate
|
|
|
|
ch character
|
|
|
|
* Output : None
|
|
|
|
* Return : 1 Success
|
|
|
|
0 Fail
|
|
|
|
****************************************************************************/
|
|
|
|
unsigned char LCD_PutChar(unsigned long x, unsigned long y, unsigned char ch)
|
2021-03-21 23:31:45 +08:00
|
|
|
{
|
2013-01-08 22:40:58 +08:00
|
|
|
unsigned char data;
|
|
|
|
unsigned char i, j;
|
|
|
|
|
|
|
|
if( x >=(GUI_LCM_XMAX-8) ) return(0);
|
|
|
|
if( y >=(GUI_LCM_YMAX-8) ) return(0);
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
if(ch == 0x20)
|
|
|
|
ch -= 0x20;
|
|
|
|
else if((ch >= 0x30)&&(ch <= 0x39))
|
|
|
|
ch -= 0x2f;
|
|
|
|
else if((ch >= 0x41)&&(ch <= 0x5a))
|
|
|
|
ch -= 0x36;
|
|
|
|
else if((ch >= 0x61)&&(ch <= 0x7a))
|
|
|
|
ch -= 0x3C;
|
|
|
|
else
|
|
|
|
return(0);
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
for(i = 0; i < 8; i++)
|
2021-03-21 23:31:45 +08:00
|
|
|
{
|
2013-01-08 22:40:58 +08:00
|
|
|
data = FONTTYPE8_8[ch][i];
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
for(j = 0; j < 8; j++)
|
2021-03-21 23:31:45 +08:00
|
|
|
{
|
2013-01-08 22:40:58 +08:00
|
|
|
if( (data&BIT_MASK[j]) == 0)
|
|
|
|
gui_disp_buf[y / 8][x] &= (~(0x01 << ( y % 8)));
|
2021-03-21 23:31:45 +08:00
|
|
|
else
|
2013-01-08 22:40:58 +08:00
|
|
|
gui_disp_buf[y / 8][x] |= (0x01 <<( y % 8));
|
|
|
|
LCD_UpdatePoint(x, y);
|
|
|
|
x ++;
|
|
|
|
}
|
2021-03-21 23:31:45 +08:00
|
|
|
x -= 8;
|
|
|
|
y++;
|
2013-01-08 22:40:58 +08:00
|
|
|
}
|
2021-03-21 23:31:45 +08:00
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Function Name : LCD_PutString
|
2021-03-21 23:31:45 +08:00
|
|
|
* Description : output string to screen
|
2013-01-08 22:40:58 +08:00
|
|
|
* Input : x X-coordinate
|
|
|
|
y Y-coordinate
|
|
|
|
str pointer to string
|
|
|
|
* Output : None
|
|
|
|
* Return : None
|
|
|
|
****************************************************************************/
|
|
|
|
void LCD_PutString(unsigned long x, unsigned long y, char *str)
|
2021-03-21 23:31:45 +08:00
|
|
|
{
|
2013-01-08 22:40:58 +08:00
|
|
|
while(1)
|
2021-03-21 23:31:45 +08:00
|
|
|
{
|
2013-01-08 22:40:58 +08:00
|
|
|
if( (*str)=='\0' ) break;
|
|
|
|
if( LCD_PutChar(x, y, *str++) == 0 ) break;
|
2021-03-21 23:31:45 +08:00
|
|
|
x += 6;
|
2013-01-08 22:40:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-16 13:23:03 +08:00
|
|
|
static rt_err_t rt_lcd_control (rt_device_t dev, int cmd, void *args)
|
2013-01-08 22:40:58 +08:00
|
|
|
{
|
2021-03-21 23:31:45 +08:00
|
|
|
switch (cmd)
|
|
|
|
{
|
|
|
|
#ifdef RT_USING_RTGUI
|
|
|
|
case RTGRAPHIC_CTRL_RECT_UPDATE:
|
|
|
|
rt_hw_lcd_update(args);
|
|
|
|
break;
|
|
|
|
case RTGRAPHIC_CTRL_POWERON:
|
|
|
|
break;
|
|
|
|
case RTGRAPHIC_CTRL_POWEROFF:
|
|
|
|
break;
|
|
|
|
case RTGRAPHIC_CTRL_GET_INFO:
|
|
|
|
rt_memcpy(args, &_lcd_info, sizeof(_lcd_info));
|
|
|
|
break;
|
|
|
|
case RTGRAPHIC_CTRL_SET_MODE:
|
|
|
|
break;
|
2013-01-08 22:40:58 +08:00
|
|
|
#else
|
|
|
|
case RT_DEVICE_CTRL_LCD_DISPLAY_ON:
|
|
|
|
lcd_write_cmd(DISPLAY_ON);
|
|
|
|
break;
|
|
|
|
case RT_DEVICE_CTRL_LCD_DISPLAY_OFF:
|
|
|
|
lcd_write_cmd(DISPLAY_OFF);
|
|
|
|
break;
|
|
|
|
case RT_DEVICE_CTRL_LCD_PUT_STRING:
|
|
|
|
LCD_PutString(x, y, (char*)args);
|
|
|
|
break;
|
|
|
|
case RT_DEVICE_CTRL_LCD_CLEAR_SCR:
|
|
|
|
LCD_ClearSCR();
|
|
|
|
break;
|
2021-03-21 23:31:45 +08:00
|
|
|
#endif
|
|
|
|
}
|
2013-01-08 22:40:58 +08:00
|
|
|
|
2021-03-21 23:31:45 +08:00
|
|
|
return RT_EOK;
|
2013-01-08 22:40:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void rt_hw_lcd_init(void)
|
|
|
|
{
|
2021-03-21 23:31:45 +08:00
|
|
|
rt_device_t lcd = rt_malloc(sizeof(struct rt_device));
|
|
|
|
if (lcd == RT_NULL) return; /* no memory yet */
|
|
|
|
|
|
|
|
_lcd_info.bits_per_pixel = 16;
|
|
|
|
_lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
|
|
|
|
_lcd_info.framebuffer = RT_NULL;
|
|
|
|
_lcd_info.width = LCD_WIDTH;
|
|
|
|
_lcd_info.height = LCD_HEIGHT;
|
|
|
|
|
|
|
|
/* init device structure */
|
|
|
|
lcd->type = RT_Device_Class_Unknown;
|
|
|
|
lcd->init = rt_lcd_init;
|
|
|
|
lcd->open = RT_NULL;
|
|
|
|
lcd->close = RT_NULL;
|
|
|
|
lcd->control = rt_lcd_control;
|
2013-01-08 22:40:58 +08:00
|
|
|
#ifdef RT_USING_RTGUI
|
2021-03-21 23:31:45 +08:00
|
|
|
lcd->user_data = (void*)&_lcd_ops;
|
|
|
|
#endif
|
|
|
|
/* register lcd device to RT-Thread */
|
|
|
|
rt_device_register(lcd, "lcd", RT_DEVICE_FLAG_RDWR);
|
2013-01-08 22:40:58 +08:00
|
|
|
}
|