Sfoglia il codice sorgente

Merge branch 'master' of https://gitee.com/openLuat/LuatOS

# Conflicts:
#	components/u8g2/luat_lib_u8g2.c
#	demo/u8g2/main.lua
alienwalker 2 anni fa
parent
commit
d33b26e3e2

+ 2 - 2
components/u8g2/luat_lib_u8g2.c

@@ -357,7 +357,7 @@ static int l_u8g2_SendBuffer(lua_State *L) {
 }
 
 /*
-在显示屏上画一段文字,在显示屏上画一段文字,要调用u8g2.SendBuffer()才会更新到屏幕,坐标原点为左下角!!!,其他显示API均同
+在显示屏上画一段文字,在显示屏上画一段文字,要调用u8g2.SendBuffer()才会更新到屏 注意:设置坐标为显示字符串左下角坐标
 @api u8g2.DrawUTF8(str, x, y)
 @string 文件内容
 @int 横坐标
@@ -382,7 +382,7 @@ static int l_u8g2_DrawUTF8(lua_State *L) {
 }
 
 /*
-在提供的文本周围画一个框。这与 DrawUTF8 类似,但为文本添加了一些装饰。,要调用u8g2.SendBuffer()才会更新到屏幕
+在提供的文本周围画一个框。这与 DrawUTF8 类似,但为文本添加了一些装饰。要调用u8g2.SendBuffer()才会更新到屏幕 注意:设置坐标为显示字符串左下角坐标
 @api u8g2.DrawButtonUTF8(str, x, y, flags, w, h, v, str)
 @string 文件内容
 @int 横坐标

+ 1 - 1
demo/eink/main.lua

@@ -36,7 +36,7 @@ function eink_pin()
     elseif rtos_bsp == "EC618" then
         return 0,1,10,8,22
     elseif rtos_bsp == "EC718P" then
-        return 0,1,14,8,15
+        return 0,10,14,8,15
     else
         log.info("main", "bsp not support")
         return

+ 3 - 3
demo/u8g2/main.lua

@@ -35,11 +35,11 @@ function u8g2_pin()
     elseif rtos_bsp == "ESP32C3" then
         return 0,5,4,2,10,6,7
     elseif rtos_bsp == "ESP32S3" then
-        return 0,12,11,2,16,15,14,13
+        return 0,12,11,2,16,15,14
     elseif rtos_bsp == "EC618" then
-        return 0,10,11,0,1,10,8,18
+        return 0,10,11,0,1,10,8
     elseif rtos_bsp == "EC718P" then
-        return 0,14,15,0,1,10,8,18
+        return 0,14,15,0,14,10,8
     else
         log.info("main", "bsp not support")
         return

+ 3 - 1
lua/src/liolib.c

@@ -1185,11 +1185,13 @@ static int io_lsdir (lua_State *L) {
 
     for (size_t i = 0; i < ret; i++)
     {
-      lua_createtable(L, 0, 2);
+      lua_createtable(L, 0, 3);
       lua_pushinteger(L, ents[i].d_type);
       lua_setfield(L, -2, "type");
       lua_pushstring(L, ents[i].d_name);
       lua_setfield(L, -2, "name");
+      lua_pushinteger(L, ents[i].d_size);
+      lua_setfield(L, -2, "size");
       lua_seti(L, -2, i + 1);
     }
     luat_heap_free(ents);

+ 1 - 0
luat/include/luat_fs.h

@@ -159,6 +159,7 @@ typedef struct luat_fs_dirent
 {
     unsigned char d_type; //0:文件;1:文件夹
     char d_name[255];
+    size_t d_size;
 }luat_fs_dirent_t;
 
 

+ 9 - 1
luat/modules/luat_lib_i2c.c

@@ -185,11 +185,16 @@ static int l_i2c_exist(lua_State *L)
     return 1;
 }
 
+LUAT_WEAK int luat_i2c_set_polling_mode(int id, uint8_t on_off){
+    return -1;
+}
+
 /*
 i2c初始化
-@api i2c.setup(id, speed, slaveAddr)
+@api i2c.setup(id, speed, pullup)
 @int 设备id, 例如i2c1的id为1, i2c2的id为2
 @int I2C速度, 例如i2c.FAST
+@bool 是否软件上拉, 默认不开启,需要硬件支持
 @return int 成功就返回1,否则返回0
 @usage
 -- 初始化i2c1
@@ -204,6 +209,9 @@ static int l_i2c_setup(lua_State *L)
         return 1;
     }
     int re = luat_i2c_setup(luaL_checkinteger(L, 1), luaL_optinteger(L, 2, 0));
+    if (lua_isboolean(L, 3) && lua_toboolean(L, 3)) {
+        luat_i2c_set_polling_mode(luaL_checkinteger(L, 1), lua_toboolean(L, 3));
+    }
     lua_pushinteger(L, re == 0 ? 1 : 0);
     return 1;
 }

+ 0 - 4
luat/vfs/luat_fs_posix.c

@@ -296,16 +296,12 @@ int luat_vfs_posix_lsdir(void* fsdata, char const* _DirName, luat_fs_dirent_t* e
             }
             if (len > 0) {
                 memcpy(ents[index].d_name, ep->d_name, strlen(ep->d_name) + 1);
-                #ifdef LUA_USE_WINDOWS
-                ents[index].d_type = 0;
-                #else
                 if (ep->d_type == DT_REG) {
                     ents[index].d_type = 0;
                 }
                 else {
                     ents[index].d_type = 1;
                 }
-                #endif
                 index++;
                 len --;
             }

+ 13 - 1
luat/vfs/luat_vfs.c

@@ -339,7 +339,19 @@ int luat_fs_lsdir(char const* _DirName, luat_fs_dirent_t* ents, size_t offset, s
         LLOGD("such mount not support lsdir");
         return 0;
     }
-    return mount->fs->opts.lsdir(mount->userdata,  _DirName + strlen(mount->prefix), ents, offset, len);
+    LLOGD("luat_fs_lsdir _DirName:%s mount->prefix:%s dir:%s", _DirName,mount->prefix,_DirName + strlen(mount->prefix));
+    int ret = mount->fs->opts.lsdir(mount->userdata,  _DirName + strlen(mount->prefix), ents, offset, len);
+
+    char file_path[256] = {0};
+    memcpy(file_path, _DirName, strlen(_DirName) + 1);
+    for (size_t i = 0; i < ret; i++){
+        if (ents[i].d_type==0){
+            memcpy(file_path+strlen(_DirName), ents[i].d_name, strlen(ents[i].d_name) + 1);
+            file_path[strlen(_DirName) + strlen(ents[i].d_name)] = 0;
+            ents[i].d_size = luat_fs_fsize(file_path);
+        }
+    }
+    return ret;
 }
 
 void* luat_fs_mmap(FILE* stream) {