How to implement a LCD interface in AWTK
In this issue, the editor will bring you about how to achieve a LCD interface in AWTK. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
1. LCD based on register
On the low-end embedded platform, there is only a few dozen KB of memory, and there is not enough memory to use framebuffer, so coordinate and color data are usually written directly to the register. Lcd_reg.inc provides register-based LCD. When using it to implement LCD for different platforms, you only need to provide two macros:
Set_window_func sets the area in which color data is to be written, which can greatly improve work efficiency compared to setting coordinates each time.
Write_data_func writes color data.
Here is the implementation of LCD on STMF103ze. Here, set_window_func is defined as TFT_SetWindow and write_data_func is defined as TFT_WriteData:
# include "tftlcd.h" # include "tkc/mem.h" # include "lcd/lcd_reg.h" typedef uint16_t pixel_t # define LCD_FORMAT BITMAP_FMT_BGR565#define pixel_from_rgb (r, g) B)\ (r) > 3) > 2) > 3)) # define pixel_to_rgba (p)\ {(0xff & (p > 11) > 5) 3) > 2) > 3)) # define pixel_to_rgba (p) \ {(0xff & (p > > 11) > 5)