--- 模块功能:LCD适配 require "ILI9341" module(..., package.seeall) -- 设置字体大小 disp.setfontheight(32) -- LCD分辨率的宽度和高度(单位是像素) WIDTH, HEIGHT, BPP = disp.getlcdinfo() -- 1个ASCII字符宽度为8像素,高度为16像素;汉字宽度和高度都为16像素 CHAR_WIDTH = 16 --[[ 函数名:getxpos 功能 :计算字符串居中显示的X坐标 参数 : str:string类型,要显示的字符串 返回值:X坐标 ]] function getxpos(str) return (WIDTH - string.len(str) * CHAR_WIDTH) / 2 end function setcolor(color) if BPP ~= 1 then return disp.setcolor(color) end end function SetBackPin() pmd.ldoset(15, pmd.LDO_VLCD) setOutputFnc = pins.setup(pio.P0_19, 0) setOutputFnc(1) end SetBackPin() sys.timerStart(SetBackPin, 100) -- 开机启动背光 -- SetLedPin() -- sys.timerStart(SetLedPin, 100) -- 开机启动背光 sys.taskInit(function() -- 定义照片文件路径列表 local photo_list = { "/lua/Calling.jpg", "/lua/PowerOn.jpg", "/lua/PutInSerNum.jpg", -- 你可以根据需要添加更多照片路径 } local photo_index = 1 while true do disp.clear() print("显示照片") -- 获取当前要显示的照片路径 local photo_path = photo_list[photo_index] if photo_path then disp.putimage(photo_path, 0, 0) else print("未找到对应的照片路径") end -- 更新显示窗口 getxpos("Hello World ----------------------------") disp.update() print("照片显示完成") -- 切换到下一张照片 photo_index = photo_index + 1 if photo_index > #photo_list then photo_index = 1 end -- 等待 10 秒 sys.wait(10000) end end)