屏幕链接:http://www.lcdwiki.com/zh/4.0inch_SPI_Module_ILI9486
这个驱动,困扰我很久,来源是原子的LCD驱动修改的。上面链接里,屏幕商家做的程序可以正常显示LCD
但是LVGL里面不能使用。
void LCD_WR_REG(u8 data)
{
LCD_CS_CLR;
LCD_RS_CLR;
SPI2_ReadWriteByte(data);
LCD_CS_SET;
}
void LCD_WR_DATA(u8 data)
{
LCD_CS_CLR;
LCD_RS_SET;
SPI2_ReadWriteByte(data);
LCD_CS_SET;
}
void LCD_SetWindows(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(xStar>>8);
LCD_WR_DATA(0x00FF&xStar);
LCD_WR_DATA(xEnd>>8);
LCD_WR_DATA(0x00FF&xEnd);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(yStar>>8);
LCD_WR_DATA(0x00FF&yStar);
LCD_WR_DATA(yEnd>>8);
LCD_WR_DATA(0x00FF&yEnd);
LCD_WriteRAM_Prepare(); //开始写入GRAM
}
// Write 8 bits to TFT
#define tft_Write_8(C) LCD_WR_DATA(C)
//0000 0000 1111 1000 F8 5
//0000 0000 1111 1100 FC 6
//0000 0000 1111 1000 F8 5
// Convert 16 bit colour to 18 bit and write in 3 bytes
#define tft_Write_16(C) LCD_WR_DATA(((C) & 0xF800)>>8); \
LCD_WR_DATA(((C) & 0x07E0)>>3); \
LCD_WR_DATA(((C) & 0x001F)<<3)
// Future option for transfer without wait
#define tft_Write_16N(C) tft_Write_16(C)
// Convert swapped byte 16 bit colour to 18 bit and write in 3 bytes
#define tft_Write_16S(C) LCD_WR_DATA((C) & 0xF8); \
LCD_WR_DATA(((C) & 0xE000)>>11 | ((C) & 0x07)<<5); \
LCD_WR_DATA(((C) & 0x1F00)>>5)
//OK,测试可用,比点填充速度快
void lB_LCD_Color_Fill(u16 x1,u16 y1,u16 x2,u16 y2, u16 *color_p)
{
uint32_t len=0;
uint16_t height,width;
width = x2 - x1 + 1;
height = y2 - y1 + 1;
len=width*height;
LCD_SetWindows(x1,y1,x2,y2);
while ( len-- ) {tft_Write_16(*color_p); color_p++;}
}
//OK 可以使用成功,颜色也对!
void LB_LCD_DrawPoint3(u16 x,u16 y,u16 color)
{
LCD_SetCursor(x,y);//设置光标位置
uint8_t colortmp[3];
colortmp[0]=((color & 0xF800)>>8);
colortmp[1]=((color & 0x07E0)>>3);
colortmp[2]=((color & 0x001F)<<3);
//18Bit
LCD_WR_DATA(colortmp[0]);//RED
LCD_WR_DATA(colortmp[1]);//GREEN
LCD_WR_DATA(colortmp[2]);//BLUE
}
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
lB_LCD_Color_Fill(area->x1, area->y1, area->x2, area->y2, &color_p->full);
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
于22.03.28
声明:
本文采用
BY-NC-SA
协议进行授权,如无注明均为原创,转载请注明转自
走着的小站
本文地址: ili9486 SPI LCD屏幕LVGL驱动程序
本文地址: ili9486 SPI LCD屏幕LVGL驱动程序