Browse Source

fix:非spi lcd设备颜色异常问题

Dozingfiretruck 1 year ago
parent
commit
50e997a4b9
2 changed files with 9 additions and 5 deletions
  1. 2 2
      components/lcd/luat_lcd.c
  2. 7 3
      components/lcd/luat_lib_lcd.c

+ 2 - 2
components/lcd/luat_lcd.c

@@ -391,7 +391,7 @@ LUAT_WEAK int luat_lcd_draw(luat_lcd_conf_t* conf, int16_t x1, int16_t y1, int16
 
 int luat_lcd_draw_point(luat_lcd_conf_t* conf, int16_t x, int16_t y, luat_color_t color) {
     luat_color_t tmp = color;
-    if (conf->port != LUAT_LCD_HW_ID_0)
+    if (conf->port < LUAT_LCD_HW_ID_0 || conf->port == LUAT_LCD_SPI_DEVICE)
         tmp = color_swap(color);// 注意, 这里需要把颜色swap了
     return luat_lcd_draw(conf, x, y, x, y, &tmp);
 }
@@ -430,7 +430,7 @@ int luat_lcd_draw_line(luat_lcd_conf_t* conf,int16_t x1, int16_t y1, int16_t x2,
     {
         size_t dots = (x2 - x1 + 1) * (y2 - y1 + 1);//点数量
         luat_color_t* line_buf = (luat_color_t*) luat_heap_malloc(dots * sizeof(luat_color_t));
-        if (conf->port != LUAT_LCD_HW_ID_0)
+        if (conf->port < LUAT_LCD_HW_ID_0 || conf->port == LUAT_LCD_SPI_DEVICE)
             tmp = color_swap(color);// 颜色swap
         if (line_buf) {
             for (i = 0; i < dots; i++)

+ 7 - 3
components/lcd/luat_lib_lcd.c

@@ -35,21 +35,25 @@ typedef struct lcd_reg {
   const luat_lcd_opts_t *lcd_opts;
 }lcd_reg_t;
 
+luat_lcd_opts_t lcd_opts_h050iwv = {
+    .name = "h050iwv",
+};
+
 static const lcd_reg_t lcd_regs[] = {
   {"custom",  &lcd_opts_custom},   //0 固定为第零个
   {"st7735",  &lcd_opts_st7735},
   {"st7735v", &lcd_opts_st7735v},
   {"st7735s", &lcd_opts_st7735s},
   {"st7789",  &lcd_opts_st7789},
-  {"st7796", &lcd_opts_st7796},
+  {"st7796",  &lcd_opts_st7796},
   {"gc9a01",  &lcd_opts_gc9a01},
   {"gc9106l", &lcd_opts_gc9106l},
   {"gc9306x", &lcd_opts_gc9306x},
   {"gc9306",  &lcd_opts_gc9306x},  //gc9306是gc9306x的别名
   {"ili9341", &lcd_opts_ili9341},
   {"ili9486", &lcd_opts_ili9486},
-  {"nv3037", &lcd_opts_nv3037},
-  {"h050iwv",LUAT_NULL},
+  {"nv3037",  &lcd_opts_nv3037},
+  {"h050iwv", &lcd_opts_h050iwv},
   {"", NULL} // 最后一个必须是空字符串
 };