Pārlūkot izejas kodu

change: lcd库支持设置色深

Wendal Chen 4 gadi atpakaļ
vecāks
revīzija
98df9c93a5

+ 1 - 1
components/lcd/luat_lcd.c

@@ -182,7 +182,7 @@ int luat_lcd_set_color(uint32_t back, uint32_t fore){
     return 0;
 }
 
-int luat_lcd_draw(luat_lcd_conf_t* conf, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t* color) {
+int luat_lcd_draw(luat_lcd_conf_t* conf, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, luat_color_t* color) {
     return conf->opts->draw(conf, x1, y1, x2, y2, color);
 }
 

+ 17 - 5
components/lcd/luat_lcd.h

@@ -23,6 +23,18 @@
 #define GRAY187          0XBDD7
 #define GRAY240          0XF79E
 
+#define LUAT_LCD_COLOR_DEPTH 32
+
+#if (LUAT_LCD_COLOR_DEPTH == 32) 
+#define luat_color_t uint32_t
+#elif (LUAT_LCD_COLOR_DEPTH == 16)
+#define luat_color_t uint16_t
+#elif (LUAT_LCD_COLOR_DEPTH == 8)
+#define luat_color_t uint8_t
+#else
+#error "no supprt color depth"
+#endif
+
 struct luat_lcd_opts;
 
 typedef struct luat_lcd_conf {
@@ -44,7 +56,7 @@ typedef struct luat_lcd_opts {
     const char* name;
     int (*init)(luat_lcd_conf_t* conf);
     int (*close)(luat_lcd_conf_t* conf);
-    int (*draw)(luat_lcd_conf_t* conf, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t* color);
+    int (*draw)(luat_lcd_conf_t* conf, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, luat_color_t* color);
     int (*sleep)(luat_lcd_conf_t* conf);
     int (*wakeup)(luat_lcd_conf_t* conf);
 } luat_lcd_opts_t;
@@ -63,12 +75,12 @@ int luat_lcd_sleep(luat_lcd_conf_t* conf);
 int luat_lcd_wakeup(luat_lcd_conf_t* conf);
 int luat_lcd_set_address(luat_lcd_conf_t* conf,uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
 int luat_lcd_set_color(uint32_t back, uint32_t fore);
-int luat_lcd_draw(luat_lcd_conf_t* conf, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t* color);
+int luat_lcd_draw(luat_lcd_conf_t* conf, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, luat_color_t* color);
 int luat_lcd_clear(luat_lcd_conf_t* conf,uint32_t color);
 int luat_lcd_draw_point(luat_lcd_conf_t* conf, uint16_t x, uint16_t y, uint32_t color);
-int luat_lcd_draw_line(luat_lcd_conf_t* conf,uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,uint32_t color);
-int luat_lcd_draw_rectangle(luat_lcd_conf_t* conf,uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2,uint32_t color);
-int luat_lcd_draw_circle(luat_lcd_conf_t* conf,uint16_t x0, uint16_t y0, uint8_t r,uint32_t color);
+int luat_lcd_draw_line(luat_lcd_conf_t* conf,uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color);
+int luat_lcd_draw_rectangle(luat_lcd_conf_t* conf,uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color);
+int luat_lcd_draw_circle(luat_lcd_conf_t* conf,uint16_t x0, uint16_t y0, uint8_t r, uint32_t color);
 
 void luat_lcd_execute_cmds(luat_lcd_conf_t* conf, uint32_t* cmds, uint32_t count);
 

+ 1 - 1
components/lcd/luat_lcd_custom.c

@@ -55,7 +55,7 @@ static int custom_init(luat_lcd_conf_t* conf) {
 };
 
 // TODO 这里的color是ARGB, 需要转为lcd所需要的格式
-static int custom_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint32_t* color) {
+static int custom_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, luat_color_t* color) {
     uint16_t i = 0, j = 0;
     uint32_t size = 0, size_remain = 0;
     uint8_t *fill_buf = NULL;

+ 1 - 1
components/lcd/luat_lcd_gc9106l.c

@@ -119,7 +119,7 @@ static int gc9106l_init(luat_lcd_conf_t* conf) {
 };
 
 // TODO 这里的color是ARGB, 需要转为lcd所需要的格式
-static int gc9106l_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint32_t* color) {
+static int gc9106l_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, luat_color_t* color) {
     uint16_t i = 0, j = 0;
     uint32_t size = 0, size_remain = 0;
     uint8_t *fill_buf = NULL;

+ 1 - 1
components/lcd/luat_lcd_gc9306.c

@@ -187,7 +187,7 @@ static int gc9306_init(luat_lcd_conf_t* conf) {
 };
 
 // TODO 这里的color是ARGB, 需要转为lcd所需要的格式
-static int gc9306_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint32_t* color) {
+static int gc9306_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, luat_color_t* color) {
     uint16_t i = 0, j = 0;
     uint32_t size = 0, size_remain = 0;
     uint8_t *fill_buf = NULL;

+ 1 - 1
components/lcd/luat_lcd_gc9a01.c

@@ -286,7 +286,7 @@ static int gc9a01_init(luat_lcd_conf_t* conf) {
 };
 
 // TODO 这里的color是ARGB, 需要转为lcd所需要的格式
-static int gc9a01_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint32_t* color) {
+static int gc9a01_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, luat_color_t* color) {
     uint16_t i = 0, j = 0;
     uint32_t size = 0, size_remain = 0;
     uint8_t *fill_buf = NULL;

+ 1 - 1
components/lcd/luat_lcd_ili9341.c

@@ -163,7 +163,7 @@ static int ili9341_init(luat_lcd_conf_t* conf) {
 };
 
 // TODO 这里的color是ARGB, 需要转为lcd所需要的格式
-static int ili9341_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint32_t* color) {
+static int ili9341_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, luat_color_t* color) {
     uint16_t i = 0, j = 0;
     uint32_t size = 0, size_remain = 0;
     uint8_t *fill_buf = NULL;

+ 1 - 1
components/lcd/luat_lcd_st7735.c

@@ -149,7 +149,7 @@ static int st7735_init(luat_lcd_conf_t* conf) {
 };
 
 // TODO 这里的color是ARGB, 需要转为lcd所需要的格式
-static int st7735_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint32_t* color) {
+static int st7735_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, luat_color_t* color) {
     uint16_t i = 0, j = 0;
     uint32_t size = 0, size_remain = 0;
     uint8_t *fill_buf = NULL;

+ 1 - 1
components/lcd/luat_lcd_st7789.c

@@ -137,7 +137,7 @@ static int st7789_init(luat_lcd_conf_t* conf) {
 };
 
 // TODO 这里的color是ARGB, 需要转为lcd所需要的格式
-static int st7789_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, uint32_t* color) {
+static int st7789_draw(luat_lcd_conf_t* conf, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end, luat_color_t* color) {
     uint16_t i = 0, j = 0;
     uint32_t size = 0, size_remain = 0;
     uint8_t *fill_buf = NULL;