Browse Source

add:lcd多加几个型号支持

Dozingfiretruck 1 year ago
parent
commit
c48867ffa1
3 changed files with 50 additions and 24 deletions
  1. 1 0
      components/lcd/luat_lcd.h
  2. 14 0
      components/lcd/luat_lcd_h050iwv.c
  3. 35 24
      components/lcd/luat_lib_lcd.c

+ 1 - 0
components/lcd/luat_lcd.h

@@ -111,6 +111,7 @@ extern luat_lcd_opts_t lcd_opts_st7735v;
 extern luat_lcd_opts_t lcd_opts_st7789;
 extern luat_lcd_opts_t lcd_opts_st7796;
 extern luat_lcd_opts_t lcd_opts_nv3037;
+extern luat_lcd_opts_t lcd_opts_h050iwv;
 
 static inline luat_color_t color_swap(luat_color_t color) {
     luat_color_t tmp = (color >> 8) + ((color & 0xFF) << 8);

+ 14 - 0
components/lcd/luat_lcd_h050iwv.c

@@ -0,0 +1,14 @@
+#include "luat_base.h"
+#include "luat_lcd.h"
+#include "luat_gpio.h"
+#include "luat_spi.h"
+#include "luat_mem.h"
+#include "luat_rtos.h"
+
+#define LUAT_LOG_TAG "h050iwv"
+#include "luat_log.h"
+
+luat_lcd_opts_t lcd_opts_h050iwv = {
+    .name = "h050iwv",
+};
+

+ 35 - 24
components/lcd/luat_lib_lcd.c

@@ -35,10 +35,18 @@ typedef struct lcd_reg {
   const luat_lcd_opts_t *lcd_opts;
 }lcd_reg_t;
 
-luat_lcd_opts_t lcd_opts_h050iwv = {
-    .name = "h050iwv",
+luat_lcd_opts_t lcd_opts_nv3052c = {
+    .name = "nv3052c",
+};
+luat_lcd_opts_t lcd_opts_hx8282 = {
+    .name = "hx8282",
+};
+luat_lcd_opts_t lcd_opts_st7701s = {
+    .name = "st7701s",
+};
+luat_lcd_opts_t lcd_opts_st7701sn = {
+    .name = "st7701sn",
 };
-
 static const lcd_reg_t lcd_regs[] = {
   {"custom",  &lcd_opts_custom},   //0 固定为第零个
   {"st7735",  &lcd_opts_st7735},
@@ -54,6 +62,10 @@ static const lcd_reg_t lcd_regs[] = {
   {"ili9486", &lcd_opts_ili9486},
   {"nv3037",  &lcd_opts_nv3037},
   {"h050iwv", &lcd_opts_h050iwv},
+  {"nv3052c", &lcd_opts_nv3052c},
+  {"hx8282",  &lcd_opts_hx8282},
+  {"st7701s",  &lcd_opts_st7701s},
+  {"st7701sn",  &lcd_opts_st7701sn},
   {"", NULL} // 最后一个必须是空字符串
 };
 
@@ -1467,28 +1479,27 @@ static int l_lcd_showimage(lua_State *L){
 lcd.flush()
 */
 static int l_lcd_flush(lua_State* L) {
-  luat_lcd_conf_t * conf = NULL;
-  if (lua_gettop(L) == 1) {
-    conf = lua_touserdata(L, 1);
-  }
-  else {
-    conf = default_conf;
-  }
-  if (conf == NULL) {
-    //LLOGW("lcd not init");
-    return 0;
-  }
-  if (conf->buff == NULL) {
-    //LLOGW("lcd without buff, not support flush");
-    return 0;
-  }
-  if (conf->auto_flush) {
-    //LLOGI("lcd auto flush is enable, no need for flush");
+    luat_lcd_conf_t * conf = NULL;
+    if (lua_gettop(L) == 1) {
+        conf = lua_touserdata(L, 1);
+    }else {
+        conf = default_conf;
+    }
+    if (conf == NULL) {
+        //LLOGW("lcd not init");
+        return 0;
+    }
+    if (conf->buff == NULL) {
+        //LLOGW("lcd without buff, not support flush");
+        return 0;
+    }
+    if (conf->auto_flush) {
+        //LLOGI("lcd auto flush is enable, no need for flush");
+        return 0;
+    }
+    luat_lcd_flush(conf);
+    lua_pushboolean(L, 1);
     return 0;
-  }
-  luat_lcd_flush(conf);
-  lua_pushboolean(L, 1);
-  return 0;
 }
 
 /*