Selaa lähdekoodia

add:draw函数提出

Dozingfiretruck 4 vuotta sitten
vanhempi
sitoutus
68cb123895

+ 9 - 1
components/lcd/luat_lcd.c

@@ -183,7 +183,15 @@ 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, luat_color_t* color) {
-    return conf->opts->draw(conf, x1, y1, x2, y2, color);
+    uint32_t size = (x2 - x1 + 1) * (y2 - y1 + 1) * 2;
+    luat_lcd_set_address(conf,x1, y1, x2, y2);
+    luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
+	if (conf->port == LUAT_LCD_SPI_DEVICE){
+		luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)color, size);
+	}else{
+		luat_spi_send(conf->port, (const char*)color, size);
+	}
+    return 0;
 }
 
 int luat_lcd_clear(luat_lcd_conf_t* conf,uint32_t color){

+ 0 - 1
components/lcd/luat_lcd.h

@@ -60,7 +60,6 @@ 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, luat_color_t* color);
     int (*sleep)(luat_lcd_conf_t* conf);
     int (*wakeup)(luat_lcd_conf_t* conf);
 } luat_lcd_opts_t;

+ 0 - 13
components/lcd/luat_lcd_custom.c

@@ -54,23 +54,10 @@ static int custom_init(luat_lcd_conf_t* conf) {
     return 0;
 };
 
-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) {
-    uint32_t size = size = (x_end - x_start+1) * (y_end - y_start+1) * 2;
-    luat_lcd_set_address(conf,x_start+conf->xoffset, y_start+conf->yoffset, x_end+conf->xoffset, y_end+conf->yoffset);
-    luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
-    if (conf->port == LUAT_LCD_SPI_DEVICE){
-		luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)color, size);
-	}else{
-		luat_spi_send(conf->port, (const char*)color, size);
-	}
-    return 0;
-}
-
 const luat_lcd_opts_t lcd_opts_custom = {
     .name = "custom",
     .init = custom_init,
     .close = custom_close,
-    .draw = custom_draw,
     .sleep = custom_sleep,
     .wakeup = custom_wakeup,
 };

+ 0 - 14
components/lcd/luat_lcd_gc9106l.c

@@ -116,24 +116,10 @@ static int gc9106l_init(luat_lcd_conf_t* conf) {
     return 0;
 };
 
-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) {
-    uint32_t size = size = (x_end - x_start+1) * (y_end - y_start+1) * 2;
-    luat_lcd_set_address(conf,x_start, y_start, x_end, y_end);
-    luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
-    if (conf->port == LUAT_LCD_SPI_DEVICE){
-		luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)color, size);
-	}else{
-		luat_spi_send(conf->port, (const char*)color, size);
-	}
-    return 0;
-}
-
-
 const luat_lcd_opts_t lcd_opts_gc9106l = {
     .name = "gc9106l",
     .init = gc9106l_init,
     .close = gc9106l_close,
-    .draw = gc9106l_draw,
     .sleep = gc9106l_sleep,
     .wakeup = gc9106l_wakeup,
 };

+ 0 - 13
components/lcd/luat_lcd_gc9306.c

@@ -184,23 +184,10 @@ static int gc9306_init(luat_lcd_conf_t* conf) {
     return 0;
 };
 
-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) {
-    uint32_t size = size = (x_end - x_start+1) * (y_end - y_start+1) * 2;
-    luat_lcd_set_address(conf,x_start, y_start, x_end, y_end);
-    luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
-	if (conf->port == LUAT_LCD_SPI_DEVICE){
-		luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)color, size);
-	}else{
-		luat_spi_send(conf->port, (const char*)color, size);
-	}
-    return 0;
-}
-
 const luat_lcd_opts_t lcd_opts_gc9306 = {
     .name = "gc9306",
     .init = gc9306_init,
     .close = gc9306_close,
-    .draw = gc9306_draw,
     .sleep = gc9306_sleep,
     .wakeup = gc9306_wakeup,
 };

+ 0 - 13
components/lcd/luat_lcd_gc9a01.c

@@ -283,23 +283,10 @@ static int gc9a01_init(luat_lcd_conf_t* conf) {
     return 0;
 };
 
-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) {
-    uint32_t size = size = (x_end - x_start+1) * (y_end - y_start+1) * 2;
-    luat_lcd_set_address(conf,x_start, y_start, x_end, y_end);
-    luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
-    if (conf->port == LUAT_LCD_SPI_DEVICE){
-		luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)color, size);
-	}else{
-		luat_spi_send(conf->port, (const char*)color, size);
-	}
-    return 0;
-}
-
 const luat_lcd_opts_t lcd_opts_gc9a01 = {
     .name = "gc9a01",
     .init = gc9a01_init,
     .close = gc9a01_close,
-    .draw = gc9a01_draw,
     .sleep = gc9a01_sleep,
     .wakeup = gc9a01_wakeup,
 };

+ 0 - 13
components/lcd/luat_lcd_ili9341.c

@@ -160,23 +160,10 @@ static int ili9341_init(luat_lcd_conf_t* conf) {
     return 0;
 };
 
-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) {
-    uint32_t size = size = (x_end - x_start+1) * (y_end - y_start+1) * 2;
-    luat_lcd_set_address(conf,x_start, y_start, x_end, y_end);
-    luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
-	if (conf->port == LUAT_LCD_SPI_DEVICE){
-		luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)color, size);
-	}else{
-		luat_spi_send(conf->port, (const char*)color, size);
-	}
-    return 0;
-}
-
 const luat_lcd_opts_t lcd_opts_ili9341 = {
     .name = "ili9341",
     .init = ili9341_init,
     .close = ili9341_close,
-    .draw = ili9341_draw,
     .sleep = ili9341_sleep,
     .wakeup = ili9341_wakeup,
 };

+ 0 - 13
components/lcd/luat_lcd_st7735.c

@@ -146,23 +146,10 @@ static int st7735_init(luat_lcd_conf_t* conf) {
     return 0;
 };
 
-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) {
-    uint32_t size = size = (x_end - x_start+1) * (y_end - y_start+1) * 2;
-    luat_lcd_set_address(conf,x_start, y_start, x_end, y_end);
-    luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
-    if (conf->port == LUAT_LCD_SPI_DEVICE){
-		luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)color, size);
-	}else{
-		luat_spi_send(conf->port, (const char*)color, size);
-	}
-    return 0;
-}
-
 const luat_lcd_opts_t lcd_opts_st7735 = {
     .name = "st7735",
     .init = st7735_init,
     .close = st7735_close,
-    .draw = st7735_draw,
     .sleep = st7735_sleep,
     .wakeup = st7735_wakeup,
 };

+ 0 - 13
components/lcd/luat_lcd_st7735s.c

@@ -152,23 +152,10 @@ static int st7735s_init(luat_lcd_conf_t* conf) {
     return 0;
 };
 
-static int st7735s_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) {
-    uint32_t size = (x_end - x_start+1) * (y_end - y_start+1) * 2;
-    luat_lcd_set_address(conf,x_start, y_start, x_end, y_end);
-    luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
-	if (conf->port == LUAT_LCD_SPI_DEVICE){
-		luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)color, size);
-	}else{
-		luat_spi_send(conf->port, (const char*)color, size);
-	}
-    return 0;
-}
-
 const luat_lcd_opts_t lcd_opts_st7735s = {
     .name = "st7735s",
     .init = st7735s_init,
     .close = st7735s_close,
-    .draw = st7735s_draw,
     .sleep = st7735s_sleep,
     .wakeup = st7735s_wakeup,
 };

+ 0 - 13
components/lcd/luat_lcd_st7789.c

@@ -137,23 +137,10 @@ static int st7789_init(luat_lcd_conf_t* conf) {
     return 0;
 };
 
-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) {
-    uint32_t size = size = (x_end - x_start+1) * (y_end - y_start+1) * 2;
-    luat_lcd_set_address(conf,x_start, y_start, x_end, y_end);
-    luat_gpio_set(conf->pin_dc, Luat_GPIO_HIGH);
-    if (conf->port == LUAT_LCD_SPI_DEVICE){
-		luat_spi_device_send((luat_spi_device_t*)(conf->userdata), (const char*)color, size);
-	}else{
-		luat_spi_send(conf->port, (const char*)color, size);
-	}
-    return 0;
-}
-
 const luat_lcd_opts_t lcd_opts_st7789 = {
     .name = "st7789",
     .init = st7789_init,
     .close = st7789_close,
-    .draw = st7789_draw,
     .sleep = st7789_sleep,
     .wakeup = st7789_wakeup,
 };

+ 1 - 1
components/lvgl/binding/luat_lib_lvgl7.c

@@ -14,7 +14,7 @@ static luat_lcd_conf_t* lcd_conf;
 static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) {
     //-----
     if (lcd_conf != NULL) {
-        lcd_conf->opts->draw(lcd_conf, area->x1, area->y1, area->x2, area->y2, color_p);
+        luat_lcd_draw(lcd_conf, area->x1, area->y1, area->x2, area->y2, color_p);
     }
     // LLOGD("CALL disp_flush (%d, %d, %d, %d)", area->x1, area->y1, area->x2, area->y2);
     lv_disp_flush_ready(disp_drv);