From 84b6a7926e5cb4a17c5e8e69bc7444c423f1b6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=89=9B?= <3338533102@qq.com> Date: Fri, 19 Jan 2024 00:08:07 +0800 Subject: [PATCH 1/7] =?UTF-8?q?pca9555IO=E6=89=A9=E5=B1=95=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 推挽输出 --- script/libs/pca9555.lua | 123 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 script/libs/pca9555.lua diff --git a/script/libs/pca9555.lua b/script/libs/pca9555.lua new file mode 100644 index 00000000..628e7a41 --- /dev/null +++ b/script/libs/pca9555.lua @@ -0,0 +1,123 @@ +--[[ + +@module pca9555 +@summary pca9555 IO扩展 +@version 1.0 +@date 2024/1/15 +@author 小牛 +@usage + i2c.setup(0, i2c.FAST) + pca9555.setup(0, 0x20, 0x0000) + for i=0,7 do + pca9555.pin(i,0) + end +]] + +local pca9555 = {} + +local PCA9555_i2cid=0 +local PCA9555_addr=0x20 +local PCA9555_mode=0x0000 --IO全为输出 +local PCA9555_IOstart=0xffff + +-- pca9555 registers define +local PCA9555_REG_IN0 = 0x00 --输入端口寄存器0 默认值由外部逻辑决定 只可读不可写 +local PCA9555_REG_IN1 = 0x01 --输入端口寄存器1 默认值由外部逻辑决定 只可读不可写 +local PCA9555_REG_OUT0 = 0x02 --输出端口寄存器0 默认值为1 可读可写 +local PCA9555_REG_OUT1 = 0x03 --输入端口寄存器1 默认值为1 可读可写 +local PCA9555_REG_POL0 = 0x04 --极性反转寄存器0 默认值为0 可读可写 +local PCA9555_REG_POL1 = 0x05 --极性反转寄存器1 默认值为0 可读可写 +local PCA9555_REG0_CFG0 = 0x06 --配置端口寄存器0 默认为1 可读可写 +local PCA9555_REG1_CFG1 = 0x07 --配置端口寄存器1 默认为1 可读可写 + +--[[ +配置寄存器说明 1为输入模式 0为输出模式 +Config registers +--------------------------------------------------------------------------------------- +Config prot 0 register +Bit 7 6 5 4 3 2 1 +Symbol C0.7 C0.6 C0.5 C0.4 C0.3 C0.2 C0.0 +Default 1 1 1 1 1 1 1 +--------------------------------------------------------------------------------------- +Config prot 1 register +Bit 7 6 5 4 3 2 1 +Symbol C1.7 C1.6 C1.5 C1.4 C1.3 C1.2 C1.0 +Default 1 1 1 1 1 1 1 +--------------------------------------------------------------------------------------- +]] + +--[[ +pca9555初始化 +pca955.setup(i2cid, addr,mode) +@number i2cid 所在的i2c总线 +@number addr pca9555设备的i2c地址 +@number mode 配置输入输出模式 --0xffff 高八位配置IO 17-10 低八位配置IO 0-7 +@return 初始化失败,返回nil +@usage + i2c.setup(0, i2c.FAST) + pca9555.setup(0,0x20,0xffff) +]] +function pca9555.setup(i2cid,addr,mode) + PCA9555_i2cid=i2cid + PCA9555_addr=addr + PCA9555_mode=mode + readEncoder() + local tmp=i2c.readReg(PCA9555_i2cid, PCA9555_addr, 0x02, 2) + if tmp==nil then + log.info("PCA9555初始化失败") + return nil + end + if PCA9555_mode~=nil then + i2c.writeReg(PCA9555_i2cid,PCA9555_addr,0x06,pack.pack(">pin + else + pin=pin-2 + val=(PCA9555_IOstart&(1<>pin + end + return val + elseif val==0 then + if pin<8 then + PCA9555_IOstart=PCA9555_IOstart&(~(1< Date: Fri, 19 Jan 2024 15:27:12 +0800 Subject: [PATCH 2/7] pca9555.lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化和修改了部分代码 --- script/libs/pca9555.lua | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/script/libs/pca9555.lua b/script/libs/pca9555.lua index 628e7a41..0a1f052c 100644 --- a/script/libs/pca9555.lua +++ b/script/libs/pca9555.lua @@ -51,7 +51,7 @@ pca9555初始化 pca955.setup(i2cid, addr,mode) @number i2cid 所在的i2c总线 @number addr pca9555设备的i2c地址 -@number mode 配置输入输出模式 --0xffff 高八位配置IO 17-10 低八位配置IO 0-7 +@number mode 配置输入输出模式 --0xffff 高八位配置IO 17-10 低八位配置IO 7-0 @return 初始化失败,返回nil @usage i2c.setup(0, i2c.FAST) @@ -93,28 +93,24 @@ function pca9555.pin(pin,val) log.info("请选择引脚") elseif pin then if val==nil then - if pin<8 then - val=(PCA9555_IOstart&(1<>pin - else + if pin>9 then pin=pin-2 - val=(PCA9555_IOstart&(1<>pin end + local tmp=i2c.readReg(PCA9555_i2cid, PCA9555_addr,0x00,2) + _,tmp=pack.unpack(tmp,">pin return val elseif val==0 then - if pin<8 then - PCA9555_IOstart=PCA9555_IOstart&(~(1<9 then pin=pin-2 - PCA9555_IOstart=PCA9555_IOstart&(~(1<9 then pin=pin-2 - PCA9555_IOstart=PCA9555_IOstart|(1< Date: Fri, 19 Jan 2024 16:36:47 +0800 Subject: [PATCH 3/7] pca9555.lua MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 规范了api --- script/libs/pca9555.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/libs/pca9555.lua b/script/libs/pca9555.lua index 0a1f052c..ad1a1372 100644 --- a/script/libs/pca9555.lua +++ b/script/libs/pca9555.lua @@ -48,7 +48,7 @@ Default 1 1 1 1 1 1 1 --[[ pca9555初始化 -pca955.setup(i2cid, addr,mode) +@api pca955.setup(i2cid, addr,mode) @number i2cid 所在的i2c总线 @number addr pca9555设备的i2c地址 @number mode 配置输入输出模式 --0xffff 高八位配置IO 17-10 低八位配置IO 7-0 @@ -78,8 +78,8 @@ function pca9555.setup(i2cid,addr,mode) end --[[ -pca9555引脚配置 -pca9555.pin(pin,val) +pca9555 pin控制 +@api pca9555.pin(pin,val) @number pin 引脚 0-7 10-17 @number val 高/低电平 1/0 @return number 如果val未填,则读取pin的输出电平 From 614c8a7f711a003158626ac6f8c03963a1346a8f Mon Sep 17 00:00:00 2001 From: Dozingfiretruck <1473454180@qq.com> Date: Fri, 19 Jan 2024 18:29:39 +0800 Subject: [PATCH 4/7] =?UTF-8?q?add:http=E6=94=AF=E6=8C=81zbuff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/network/libhttp/luat_http.h | 4 ++++ components/network/libhttp/luat_http_client.c | 9 +++++++++ components/network/libhttp/luat_lib_http.c | 17 ++++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/components/network/libhttp/luat_http.h b/components/network/libhttp/luat_http.h index e404aee1..e2dd28c3 100644 --- a/components/network/libhttp/luat_http.h +++ b/components/network/libhttp/luat_http.h @@ -2,6 +2,9 @@ #define LUAT_HTTP_H #ifdef __LUATOS__ +#include "luat_zbuff.h" + + #if defined(AIR101) || defined(AIR103) // #define HTTP_REQ_HEADER_MAX_SIZE (2048) #define HTTP_RESP_BUFF_SIZE (2048) @@ -86,6 +89,7 @@ typedef struct{ char *req_header; char *req_body; //发送body size_t req_body_len; //发送body长度 + luat_zbuff_t *zbuff_body; char *req_auth; #ifdef LUAT_USE_FOTA //OTA相关 diff --git a/components/network/libhttp/luat_http_client.c b/components/network/libhttp/luat_http_client.c index 310b484f..a91a4c1b 100644 --- a/components/network/libhttp/luat_http_client.c +++ b/components/network/libhttp/luat_http_client.c @@ -313,6 +313,13 @@ static int on_body(http_parser* parser, const char *at, size_t length){ } } #endif + else if(http_ctrl->is_post==0 && http_ctrl->zbuff_body!=NULL){ + if (http_ctrl->zbuff_body->len < http_ctrl->zbuff_body->used+length+1 ){ + http_ctrl->zbuff_body->addr = luat_heap_realloc(http_ctrl->zbuff_body->addr,http_ctrl->zbuff_body->used+length+1); + } + memcpy(http_ctrl->zbuff_body->addr + http_ctrl->zbuff_body->used ,at,length); + http_ctrl->zbuff_body->used += length; + } else{ if (!http_ctrl->body){ http_ctrl->body = luat_heap_malloc(length+1); @@ -475,6 +482,8 @@ static void http_send_message(luat_http_ctrl_t *http_ctrl){ // 发送body if (http_ctrl->req_body){ http_send(http_ctrl, (uint8_t*)http_ctrl->req_body, http_ctrl->req_body_len); + }else if(http_ctrl->is_post==1 && http_ctrl->zbuff_body!=NULL){ + http_send(http_ctrl, http_ctrl->zbuff_body->addr, http_ctrl->zbuff_body->used); } #else int result; diff --git a/components/network/libhttp/luat_lib_http.c b/components/network/libhttp/luat_lib_http.c index ca1d5ac7..c255f3ed 100644 --- a/components/network/libhttp/luat_lib_http.c +++ b/components/network/libhttp/luat_lib_http.c @@ -76,7 +76,7 @@ http客户端 @string 请求方法, 支持 GET/POST 等合法的HTTP方法 @string url地址, 支持 http和https, 支持域名, 支持自定义端口 @tabal 请求头 可选 例如 {["Content-Type"] = "application/x-www-form-urlencoded"} -@string body 可选, 对POST/PUT等请求方式有效 +@string/zbuff body 可选 @table 额外配置 可选 包含 timeout:超时时间单位ms 可选,默认10分钟,写0即永久等待 dst:下载路径,可选 adapter:选择使用网卡,可选 debug:是否打开debug信息,可选,ipv6:是否为ipv6 默认不是,可选 callback:下载回调函数,参数 content_len:总长度 body_len:以下载长度 userdata 用户传参,可选 userdata:回调自定义传参 @string 服务器ca证书数据, 可选, 一般不需要 @string 客户端ca证书数据, 可选, 一般不需要, 双向https认证才需要 @@ -242,6 +242,11 @@ static int l_http_request(lua_State *L) { // memcpy(http_ctrl->method, method, len + 1); // LLOGD("method:%s",http_ctrl->method); + if (strcmp("POST", method) == 0 || strcmp("PUT", method) == 0){ + http_ctrl->is_post = 1; + } + + const char *url = luaL_checklstring(L, 2, &len); // http_ctrl->url = luat_heap_malloc(len + 1); // memset(http_ctrl->url, 0, len + 1); @@ -278,11 +283,17 @@ static int l_http_request(lua_State *L) { if (lua_isstring(L, 4)) { const char *body = luaL_checklstring(L, 4, &(http_ctrl->req_body_len)); http_ctrl->req_body = luat_heap_malloc((http_ctrl->req_body_len) + 1); - // TODO 检测req_body是否为NULL + // TODO 检测req_body是否为NULL memset(http_ctrl->req_body, 0, (http_ctrl->req_body_len) + 1); memcpy(http_ctrl->req_body, body, (http_ctrl->req_body_len)); snprintf_(body_len, 6,"%d",(http_ctrl->req_body_len)); http_add_header(http_ctrl,"Content-Length",body_len); + }else if(lua_isuserdata(L, 4)){//zbuff + http_ctrl->zbuff_body = ((luat_zbuff_t *)luaL_checkudata(L, 4, LUAT_ZBUFF_TYPE)); + if (http_ctrl->is_post){ + snprintf_(body_len, 6,"%d",(http_ctrl->zbuff_body->used)); + http_add_header(http_ctrl,"Content-Length",body_len); + } } // TODO 对 req_header进行realloc @@ -413,7 +424,7 @@ int32_t l_http_callback(lua_State *L, void* ptr){ http_ctrl->headers_len -= temp-header; header = temp; } - LLOGD("http_ctrl->body:%.*s len:%d",http_ctrl->body_len,http_ctrl->body,http_ctrl->body_len); + // LLOGD("http_ctrl->body:%.*s len:%d",http_ctrl->body_len,http_ctrl->body,http_ctrl->body_len); // 处理body, 需要区分下载模式和非下载模式 if (http_ctrl->is_download) { // 下载模式 From d3cff45313dac279199e82b2034ae31103993b2f Mon Sep 17 00:00:00 2001 From: alienwalker Date: Fri, 19 Jan 2024 18:39:52 +0800 Subject: [PATCH 5/7] =?UTF-8?q?add:=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E9=80=9A=E8=AF=9D=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/cc/luat_lib_cc.c | 11 +++++++++++ luat/modules/luat_lib_i2s.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/components/cc/luat_lib_cc.c b/components/cc/luat_lib_cc.c index 82cbeba0..51ab295d 100644 --- a/components/cc/luat_lib_cc.c +++ b/components/cc/luat_lib_cc.c @@ -400,6 +400,16 @@ static int l_cc_record_call(lua_State* L) { return 1; } +/** +获取当前通话质量 +@api cc.quality() +@return int 1为低音质,2为高音质,0没有在通话 + */ +static int l_cc_get_quality(lua_State* L) { + lua_pushinteger(L, luat_cc.record_type); + return 1; +} + /** 注册通话回调 @api cc.on(event, func) @@ -435,6 +445,7 @@ static const rotable_Reg_t reg_cc[] = { "accept" , ROREG_FUNC(l_cc_answer_call)}, { "hangUp" , ROREG_FUNC(l_cc_hangup_call)}, { "lastNum" , ROREG_FUNC(l_cc_get_last_call_num)}, + { "quality" , ROREG_FUNC(l_cc_get_quality)}, { "on" , ROREG_FUNC(l_cc_on)}, { "record", ROREG_FUNC(l_cc_record_call)}, { NULL, {}} diff --git a/luat/modules/luat_lib_i2s.c b/luat/modules/luat_lib_i2s.c index 84856c20..c911d0aa 100644 --- a/luat/modules/luat_lib_i2s.c +++ b/luat/modules/luat_lib_i2s.c @@ -250,7 +250,32 @@ static int l_i2s_tx_stat(lua_State *L) { lua_pushinteger(L, remain); return 2; } - +#if 0 +/* +获取I2S参数,参数具体参考setup +@api i2s.getPara(id) +@int 通道id +@return boolean 是否在工作状态 true是 +@return int 模式, 0 主机 1 从机 +@return int 采样率 +@return int 数据位数 +@return int 声道 +@return int 格式 +@return int 1个声道的BCLK数量 +*/ +static int l_i2s_get_param(lua_State *L) { + int id = luaL_checkinteger(L, 1); + luat_i2s_conf_t *config = luat_i2s_get_config(id); + lua_pushboolean(L, config->state); + lua_pushinteger(L, config->mode); + lua_pushinteger(L, config->sample_rate); + lua_pushinteger(L, config->data_bits); + lua_pushinteger(L, config->channel_format); + lua_pushinteger(L, config->standard); + lua_pushinteger(L, config->channel_bits); + return 7; +} +#endif int l_i2s_play(lua_State *L); int l_i2s_pause(lua_State *L); int l_i2s_stop(lua_State *L); @@ -287,6 +312,9 @@ static const rotable_Reg_t reg_i2s[] = { "close", ROREG_FUNC(l_i2s_close)}, { "on", ROREG_FUNC(l_i2s_on)}, { "txStat", ROREG_FUNC(l_i2s_tx_stat)}, +#if 0 + { "getPara", ROREG_FUNC(l_i2s_get_param)}, +#endif // 以下为兼容扩展功能,待定 { "play", ROREG_FUNC(l_i2s_play)}, { "pause", ROREG_FUNC(l_i2s_pause)}, From 80437b27b1e16b790b45ec8f6f3676b69533a016 Mon Sep 17 00:00:00 2001 From: Dozingfiretruck <1473454180@qq.com> Date: Sat, 20 Jan 2024 11:24:56 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:lcd=E7=A1=AC=E4=BB=B6=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/lcd/luat_lib_lcd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/lcd/luat_lib_lcd.c b/components/lcd/luat_lib_lcd.c index 963a79a7..547db9ab 100644 --- a/components/lcd/luat_lib_lcd.c +++ b/components/lcd/luat_lib_lcd.c @@ -1316,11 +1316,13 @@ static int lcd_out_func (JDEC* jd, void* bitmap, JRECT* rect){ // rgb高低位swap uint16_t count = (rect->right - rect->left + 1) * (rect->bottom - rect->top + 1); - for (size_t i = 0; i < count; i++) - { - dev->buff[i] = ((tmp[i] >> 8) & 0xFF)+ ((tmp[i] << 8) & 0xFF00); + for (size_t i = 0; i < count; i++){ + if (default_conf->port == LUAT_LCD_HW_ID_0) + dev->buff[i] = tmp[i]; + else + dev->buff[i] = ((tmp[i] >> 8) & 0xFF)+ ((tmp[i] << 8) & 0xFF00); } - + // LLOGD("jpeg seg %dx%d %dx%d", rect->left, rect->top, rect->right, rect->bottom); // LLOGD("jpeg seg size %d %d %d", rect->right - rect->left + 1, rect->bottom - rect->top + 1, (rect->right - rect->left + 1) * (rect->bottom - rect->top + 1)); luat_lcd_draw(default_conf, dev->x + rect->left, dev->y + rect->top, From 9c9acca3d2b64f25686ce6a62d4d09a899772270 Mon Sep 17 00:00:00 2001 From: Dozingfiretruck <1473454180@qq.com> Date: Sat, 20 Jan 2024 11:25:40 +0800 Subject: [PATCH 7/7] =?UTF-8?q?add:lcd=20demo=E5=A2=9E=E5=8A=A0718P?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/lcd/main.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/demo/lcd/main.lua b/demo/lcd/main.lua index 7ac7ee75..c2bfe089 100644 --- a/demo/lcd/main.lua +++ b/demo/lcd/main.lua @@ -60,6 +60,8 @@ function lcd_pin() return 2,16,15,14,13 elseif rtos_bsp == "EC618" then return 0,1,10,8,22 + elseif rtos_bsp == "EC718P" then + return lcd.HWID_0,36,0xff,0xff,0xff -- 硬件lcd驱动 else log.info("main", "bsp not support") return @@ -69,28 +71,28 @@ end local spi_id,pin_reset,pin_dc,pin_cs,bl = lcd_pin() -- v0006及以后版本可用pin方式, 请升级到最新固件 https://gitee.com/openLuat/LuatOS/releases -spi_lcd = spi.deviceSetup(spi_id,pin_cs,0,0,8,20*1000*1000,spi.MSB,1,0) +if spi_id ~= lcd.HWID_0 then + spi_lcd = spi.deviceSetup(spi_id,pin_cs,0,0,8,20*1000*1000,spi.MSB,1,0) ---[[ 此为合宙售卖的2.4寸TFT LCD 分辨率:240X320 屏幕ic:GC9306 购买地址:https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-24045920841.39.6c2275a1Pa8F9o&id=655959696358]] --- lcd.init("gc9a01",{port = "device",pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 0,w = 240,h = 320,xoffset = 0,yoffset = 0},spi_lcd) + --[[ 此为合宙售卖的1.8寸TFT LCD LCD 分辨率:128X160 屏幕ic:st7735 购买地址:https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-24045920841.19.6c2275a1Pa8F9o&id=560176729178]] + -- lcd.init("st7735",{port = "device",pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 0,w = 128,h = 160,xoffset = 0,yoffset = 0},spi_lcd) ---[[ 此为合宙售卖的1.8寸TFT LCD LCD 分辨率:128X160 屏幕ic:st7735 购买地址:https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-24045920841.19.6c2275a1Pa8F9o&id=560176729178]] -lcd.init("st7735",{port = "device",pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 0,w = 128,h = 160,xoffset = 0,yoffset = 0},spi_lcd) + --[[ 此为合宙售卖的1.54寸TFT LCD LCD 分辨率:240X240 屏幕ic:st7789 购买地址:https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-24045920841.20.391445d5Ql4uJl&id=659456700222]] + lcd.init("st7789",{port = "device",pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 0,w = 240,h = 320,xoffset = 0,yoffset = 0},spi_lcd) ---[[ 此为合宙售卖的1.54寸TFT LCD LCD 分辨率:240X240 屏幕ic:st7789 购买地址:https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-24045920841.20.391445d5Ql4uJl&id=659456700222]] --- lcd.init("st7789",{port = "device",pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 0,w = 240,h = 240,xoffset = 0,yoffset = 0},spi_lcd) + --[[ 此为合宙售卖的0.96寸TFT LCD LCD 分辨率:160X80 屏幕ic:st7735s 购买地址:https://item.taobao.com/item.htm?id=661054472686]] + --lcd.init("st7735v",{port = "device",pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 1,w = 160,h = 80,xoffset = 0,yoffset = 24},spi_lcd) + --如果显示颜色相反,请解开下面一行的注释,关闭反色 + --lcd.invoff() + --如果显示依旧不正常,可以尝试老版本的板子的驱动 + -- lcd.init("st7735s",{port = "device",pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 2,w = 160,h = 80,xoffset = 0,yoffset = 0},spi_lcd) ---[[ 此为合宙售卖的0.96寸TFT LCD LCD 分辨率:160X80 屏幕ic:st7735s 购买地址:https://item.taobao.com/item.htm?id=661054472686]] ---lcd.init("st7735v",{port = "device",pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 1,w = 160,h = 80,xoffset = 0,yoffset = 24},spi_lcd) ---如果显示颜色相反,请解开下面一行的注释,关闭反色 ---lcd.invoff() ---如果显示依旧不正常,可以尝试老版本的板子的驱动 --- lcd.init("st7735s",{port = "device",pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 2,w = 160,h = 80,xoffset = 0,yoffset = 0},spi_lcd) +else + lcd.init("st7789",{port = spi_id, pin_dc = pin_dc, pin_pwr = bl, pin_rst = pin_reset,direction = 0,w = 240,h = 320}) +end ---[[ 此为合宙售卖的2.4寸TFT LCD 分辨率:240X320 屏幕ic:GC9306 购买地址:https://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-24045920841.39.6c2275a1Pa8F9o&id=655959696358]] --- lcd.init("gc9306",{port = "device",pin_dc = pin_dc , pin_pwr = bl,pin_rst = pin_reset,direction = 0,w = 240,h = 320,xoffset = 0,yoffset = 0},spi_lcd) --- 不在上述内置驱动的, 看demo/lcd_custom +-- 不在内置驱动的, 看demo/lcd_custom sys.taskInit(function() -- 开启缓冲区, 刷屏速度回加快, 但也消耗2倍屏幕分辨率的内存