Bläddra i källkod

change: 继续改lcd的buff模式

Wendal Chen 4 år sedan
förälder
incheckning
86d716f29e
3 ändrade filer med 14 tillägg och 3 borttagningar
  1. 5 0
      bsp/sysp/CMakeLists.txt
  2. 2 2
      components/lcd/luat_lib_lcd.c
  3. 7 1
      components/lvgl/binding/luat_lib_lvgl7.c

+ 5 - 0
bsp/sysp/CMakeLists.txt

@@ -21,6 +21,7 @@ include_directories(${TOPROOT}/lua/include
                     ${TOPROOT}/components/lcd
                     ${TOPROOT}/luat/packages/u8g2
                     ${TOPROOT}/luat/packages/qrcode
+                    ${TOPROOT}/components/ui/sdl2
                     )
 
 aux_source_directory(./port PORT_SRCS)
@@ -31,6 +32,8 @@ aux_source_directory(${TOPROOT}/components/lcd LCD_SRCS)
 aux_source_directory(${TOPROOT}/luat/packages/u8g2 U8G2_SRCS)
 aux_source_directory(${TOPROOT}/luat/packages/qrcode QRCODE_SRCS)
 
+aux_source_directory(${TOPROOT}/components/ui/sdl2 UI_SDL2_SRCS)
+
 add_library(lua ${LUA_SRCS})
 add_library(luatos_port ${PORT_SRCS})
 add_library(cjson ${CJSON_SRCS})
@@ -51,6 +54,7 @@ add_library(luat ${TOPROOT}/luat/modules/luat_main.c
                  ${TOPROOT}/luat/modules/luat_lib_i2c.c
                  ${TOPROOT}/luat/modules/luat_lib_spi.c
                  ${TOPROOT}/luat/modules/luat_lib_adc.c
+                 ${TOPROOT}/luat/modules/luat_lib_pin.c
                  ${TOPROOT}/luat/modules/crc.c
                  ${TOPROOT}/luat/vfs/luat_vfs.c
                  ${TOPROOT}/luat/vfs/luat_fs_luadb.c
@@ -61,6 +65,7 @@ add_library(luat ${TOPROOT}/luat/modules/luat_main.c
                  ${LCD_SRCS}
                  ${U8G2_SRCS}
                  ${QRCODE_SRCS}
+                 ${UI_SDL2_SRCS}
             )
 
 #-----------------------

+ 2 - 2
components/lcd/luat_lib_lcd.c

@@ -61,8 +61,10 @@ static int dft_conf_lua_ref = 0;
 
 // 所有绘图相关的函数都应该调用本函数
 static void lcd_auto_flush(luat_lcd_conf_t *conf) {
+#ifndef LUAT_USE_LCD_SDL2
   if (conf == NULL || conf->buff == NULL || conf->auto_flush == 0)
     return;
+#endif
   luat_lcd_flush(conf);
 }
 
@@ -232,8 +234,6 @@ static int l_lcd_init(lua_State* L) {
 #ifdef LUAT_USE_LCD_SDL2
         extern const luat_lcd_opts_t lcd_opts_sdl2;
         conf->opts = &lcd_opts_sdl2;
-        // 假装支持flush
-        conf->buff = (char*)&lcd_opts_sdl2;
 #endif
         int ret = luat_lcd_init(conf);
         if (ret == 0) {

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

@@ -107,6 +107,8 @@ LUAT_WEAK void luat_lv_disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * ar
         luat_lcd_draw_no_block(lcd_conf, area->x1, area->y1, area->x2, area->y2, color_p, disp_drv->buffer->flushing_last);
 #else
         luat_lcd_draw(lcd_conf, area->x1, area->y1, area->x2, area->y2, color_p);
+        if (disp_drv->buffer->flushing_last)
+            luat_lcd_flush(lcd_conf);
 #endif
     }
     // LLOGD("CALL disp_flush (%d, %d, %d, %d)", area->x1, area->y1, area->x2, area->y2);
@@ -163,7 +165,11 @@ int luat_lv_init(lua_State *L) {
 
     LLOGD("w %d h %d buff %d mode %d", w, h, fbuff_size, buffmode);
 
-    if (buffmode & 0x02) {
+    if (lcd_conf != NULL && lcd_conf->buff != NULL) {
+        fbuffer = lcd_conf->buff;
+        fbuff_size = w * h;
+    }
+    else if (buffmode & 0x02) {
         fbuffer = luat_heap_malloc(fbuff_size * sizeof(lv_color_t));
         if (fbuffer == NULL) {
             LLOGD("not enough memory");