Browse Source

fix: 解决几个编译警告

Wendal Chen 4 years ago
parent
commit
64e5b1bf33

+ 3 - 0
luat/include/luat_zbuff.h

@@ -22,4 +22,7 @@ typedef struct luat_zbuff {
     uint8_t bit;    //色深度
 } luat_zbuff_t;
 
+
+int __zbuff_resize(luat_zbuff_t *buff, uint32_t new_size);
+
 #endif

+ 50 - 50
luat/modules/luat_lib_dac.c

@@ -79,56 +79,56 @@ static int l_dac_write(lua_State *L) {
     return 2;
 }
 
-/*
-从指定DAC通道输出一段波形,数据从文件读取
-@api dac.writeFile(ch, fd)
-@int 通道编号,例如0
-@string 文件路径
-@return true 成功返回true,否则返回false
-@return int 底层返回值,调试用
-
-if dac.open(0, 44000) then
-    log.info("dac", "dac ch0 is opened")
-    dac.writeFile(0, "/luadb/test.wav")
-end
-dac.close(0)
-*/
-static int l_dac_write_file(lua_State *L) {
-    uint16_t* buff;
-    int ch;
-    size_t buff_size = 4096;
-    size_t len;
-
-    ch = luaL_checkinteger(L, 1);
-    const char* path = luaL_checkstring(L, 2);
-    FILE* fd = luat_fs_fopen(path, "rb");
-    if (fd == NULL) {
-        LLOGD("file not exist %s", path);
-        lua_pushboolean(L, 0);
-        return 1;
-    }
-    if (lua_isinteger(L, 3)) {
-        buff_size = luaL_checkinteger(L, 3);
-    }
-    buff = luat_heap_malloc(buff_size);
-    if (buff == NULL) {
-        luat_fs_fclose(fd);
-        LLOGW("buff size too big? %d", buff_size);
-        lua_pushboolean(L, 0);
-        return 1;
-    }
-    while (1) {
-        len = luat_fs_fread(buff, buff_size, 1, fd);
-        if (len == 0) {
-            break;
-        }
-        luat_dac_write(ch, buff, len);
-    }
-    luat_heap_free(buff);
-    luat_fs_fclose(fd);
-    lua_pushboolean(L, 1);
-    return 1;
-}
+// /*
+// 从指定DAC通道输出一段波形,数据从文件读取
+// @api dac.writeFile(ch, fd)
+// @int 通道编号,例如0
+// @string 文件路径
+// @return true 成功返回true,否则返回false
+// @return int 底层返回值,调试用
+
+// if dac.open(0, 44000) then
+//     log.info("dac", "dac ch0 is opened")
+//     dac.writeFile(0, "/luadb/test.wav")
+// end
+// dac.close(0)
+// */
+// static int l_dac_write_file(lua_State *L) {
+//     uint16_t* buff;
+//     int ch;
+//     size_t buff_size = 4096;
+//     size_t len;
+
+//     ch = luaL_checkinteger(L, 1);
+//     const char* path = luaL_checkstring(L, 2);
+//     FILE* fd = luat_fs_fopen(path, "rb");
+//     if (fd == NULL) {
+//         LLOGD("file not exist %s", path);
+//         lua_pushboolean(L, 0);
+//         return 1;
+//     }
+//     if (lua_isinteger(L, 3)) {
+//         buff_size = luaL_checkinteger(L, 3);
+//     }
+//     buff = luat_heap_malloc(buff_size);
+//     if (buff == NULL) {
+//         luat_fs_fclose(fd);
+//         LLOGW("buff size too big? %d", buff_size);
+//         lua_pushboolean(L, 0);
+//         return 1;
+//     }
+//     while (1) {
+//         len = luat_fs_fread(buff, buff_size, 1, fd);
+//         if (len == 0) {
+//             break;
+//         }
+//         luat_dac_write(ch, buff, len);
+//     }
+//     luat_heap_free(buff);
+//     luat_fs_fclose(fd);
+//     lua_pushboolean(L, 1);
+//     return 1;
+// }
 
 /*
 关闭DAC通道

+ 1 - 0
luat/modules/luat_lib_pin.c

@@ -7,6 +7,7 @@
 
 #include "luat_base.h"
 #include "luat_pin.h"
+#include <stdlib.h>
 
 #define LUAT_LOG_TAG "pin"
 #include "luat_log.h"

+ 1 - 1
luat/modules/luat_lib_sensor.c

@@ -386,7 +386,7 @@ sys.taskInit(
 */
 static int l_sensor_hx711(lua_State *L)
 {
-  unsigned int j;
+  // unsigned int j;
   unsigned long hx711_dat;
   int date = luaL_checkinteger(L, 1);
   int clk = luaL_checkinteger(L, 2);

+ 1 - 1
luat/modules/luat_lib_uart.c

@@ -162,7 +162,7 @@ uart.tx(1, buf)
 static int l_uart_tx(lua_State *L)
 {
     size_t start, len;
-    const char *buf;
+    // const char *buf;
     luat_zbuff_t *buff;
     uint8_t id = luaL_checkinteger(L, 1);
     if(lua_isuserdata(L, 2))

+ 1 - 1
luat/modules/luat_lib_zbuff.c

@@ -1238,7 +1238,7 @@ static int l_zbuff_query(lua_State *L)
     	int16_t s;
     	uint16_t us;
     	int32_t i;
-    	uint32_t ui;
+    	// uint32_t ui;
     	int64_t l;
     	float f;
     	double d;

+ 1 - 1
luat/packages/lfs/lfs_sfd.c

@@ -42,7 +42,7 @@ int lfs_sfd_erase(const struct lfs_config *c, lfs_block_t block) {
     // Sync the state of the underlying block device. Negative error codes
     // are propogated to the user.
 int lfs_sfd_sync(const struct lfs_config *c) {
-    sfd_drv_t *drv = (sfd_drv_t *)c->context;
+    // sfd_drv_t *drv = (sfd_drv_t *)c->context;
     //drv->opts->ioctl(drv, ???);
     return 0;
 }

+ 1 - 1
luat/packages/u8g2/luat_lib_u8g2.c

@@ -950,7 +950,7 @@ LUAT_WEAK uint8_t u8x8_luat_byte_hw_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_i
       break;
     case U8X8_MSG_BYTE_INIT:
       //i2c_init(u8x8);			/* init i2c communication */
-      luat_i2c_setup(i2c_id,i2c_speed,NULL);
+      luat_i2c_setup(i2c_id,i2c_speed, 0);
       break;
     case U8X8_MSG_BYTE_SET_DC:
       /* ignored for i2c */