- -- sys库是标配
- _G.sys = require("sys")
- sys.taskInit(function()
- local cnt=0
- lvgl.init(480,320)--lvgl初始化
- local cont = lvgl.cont_create(nil, nil);
- -- lvgl.cont_set_fit(cont, lvgl.FIT_NONE )
- local label = lvgl.label_create(cont, nil)--创建标签label
- local label1 = lvgl.label_create(cont, nil)--创建标签label
- while 1 do
- local str=tostring(cnt)
- local dispStr ="Latitude11:"..string.format("%3.2f",cnt)
- local dispStr1="Longitude:" ..string.format("%3.2f",cnt)
- lvgl.obj_set_pos(label1, 0, 15);
- lvgl.label_set_text(label, dispStr)--设置标签内容
- lvgl.label_set_text(label1, dispStr1)--设置标签内容
- lvgl.scr_load(cont)--加载标签
- -- lvgl.scr_load(label)
- -- lvgl.scr_load(label1)
- sys.wait(100)
- cnt=cnt+0.01
- end
- end)
- sys.run()
- --- 模块功能:lvgldemo
- -- @module lvgl
- -- @author armxu
- -- @release 2023.10.24
-
- -- LuaTools需要PROJECT和VERSION这两个信息
- PROJECT = "lvgl_multi_Label_demo"
- VERSION = "1.0.0"
-
- log.info("main", PROJECT, VERSION)
-
- -- sys库是标配
- _G.sys = require("sys")
-
- --[[
- SPI0
- SPI0_SCK (PB2)
- SPI0_MISO (PB3)
- SPI0_MOSI (PB5)
- ]]
-
-
- --添加硬狗防止程序卡死
- wdt.init(15000)--初始化watchdog设置为15s
- sys.timerLoopStart(wdt.feed, 10000)--10s喂一次狗
-
- log.info("hello luatos")
-
- spi_lcd = spi.deviceSetup(0,20,0,0,8,20*1000*1000,spi.MSB,1,1)
- -- log.info("lcd.init",
- -- lcd.init("st7735s",{port = "device",pin_dc = 17, pin_pwr = 7,pin_rst = 19,direction = 2,w = 160,h = 80,xoffset = 1,yoffset = 26},spi_lcd))
-
- log.info("lcd.init",
- lcd.init("st7735",{port = "device",pin_dc = 17, pin_pwr = 7,pin_rst = 19,direction = 0,w = 128,h = 160,xoffset = 2,yoffset = 1},spi_lcd))
-
- --[[-- v0006及以后版本可用pin方式
- spi_lcd = spi.deviceSetup(0,pin.PB04,0,0,8,20*1000*1000,spi.MSB,1,1)
- log.info("lcd.init",
- lcd.init("st7735s",{port = "device",pin_dc = pin.PB01, pin_pwr = pin.PB00,pin_rst = pin.PB03,direction = 2,w = 160,h = 80,xoffset = 1,yoffset = 26},spi_lcd))
- ]]
- log.info("lvgl", lvgl.init())
-
- sys.taskInit(function()
- local cnt=0
- --创建容器
- local cont = lvgl.cont_create(nil, nil);
-
- --创建2个标签
- local label = lvgl.label_create(cont, nil)
- local label1 = lvgl.label_create(cont, nil)
-
- while 1 do
- local dispStr ="Latitude:"..string.format("%3.2f",cnt)--浮点数转换成字符串
- local dispStr1="Longitude:" ..string.format("%3.2f",cnt)--浮点数转换成字符串
- lvgl.obj_set_pos(label1, 0, 15);
- lvgl.label_set_text(label, dispStr) --设置标签内容
- lvgl.label_set_text(label1, dispStr1)--设置标签内容
- lvgl.scr_load(cont)--加载容器 显示标签
-
- sys.wait(200)
- cnt=cnt+0.01--浮点数累加
- end
- end)
-
-
- -- 用户代码已结束---------------------------------------------
- -- 结尾总是这一句
- sys.run()
- -- sys.run()之后后面不要加任何语句!!!!!
-
-
- lvgl.label_set_recolor(label, true)
- local dispStr ="#FF0000 Latitude11:"..string.format("%3.2f",cnt).."#"
- -- sys库是标配
- _G.sys = require("sys")
- sys.taskInit(function()
- local cnt=0
- lvgl.init(480,320)--lvgl初始化
- local cont = lvgl.cont_create(nil, nil);
- -- lvgl.cont_set_fit(cont, lvgl.FIT_NONE )
- local label = lvgl.label_create(cont, nil)--创建标签label
- local label1 = lvgl.label_create(cont, nil)--创建标签label
- lvgl.label_set_recolor(label, true)
-
- while 1 do
- local str=tostring(cnt)
- local dispStr ="#FF0000 Latitude11:"..string.format("%3.2f",cnt).."#"
- local dispStr1="Longitude:" ..string.format("%3.2f",cnt)
-
- lvgl.obj_set_pos(label1, 0, 15);
- lvgl.label_set_text(label, dispStr)--设置标签内容
- lvgl.label_set_text(label1, dispStr1)--设置标签内容
- lvgl.scr_load(cont)--加载标签
- -- lvgl.scr_load(label)
- -- lvgl.scr_load(label1)
- sys.wait(100)
- cnt=cnt+0.01
- end
- end)
- sys.run()