--[[ @module tsb_ywy_page @summary 液位仪演示页面 @version 1.0 @date 2026.02.05 @author 江访 @usage 本文件是液位仪演示页面,展示液位仪的各种用法。 ]] local tsb_ywy_page = {} local common_ui = require("tsb_common_page") -- 页面UI元素 local main_container = nil -- 创建UI function tsb_ywy_page.create_ui() main_container = airui.container({ x = 0, y = 0, w = 480, h = 320, color = 0xF5F5F5, }) --------------------- 标题栏 ------------------------ local title_bar = airui.container({ parent = main_container, x = 0, y = 0, w = 480, h = 30, color = 0x4CAF50, }) airui.label({ parent = title_bar, text = "液位仪", x = 210, y = 8, w = 80, h = 20, font_size = 16, color = 0xFFFFFF, }) -- 标题栏公共信息展示 common_ui.add_battery_display(title_bar) common_ui.create_back_button(title_bar, tsb_ywy_page.cleanup) --------------------------------------------------- -- 滚动容器 local scroll_container = airui.container({ parent = main_container, x = 0, y = 30, w = 480, h = 270, color = 0xFFFFFF, }) --------------------- 第一排控制区 ------------------------ local control_container = airui.container({ parent = scroll_container, x = 0, y = 0, w = 480, h = 80, color = 0xFFFFFF, }) -- 波特率标签 airui.label({ parent = control_container, text = "波特率:", x = 10, y = 28, w = 60, h = 30, font_size = 15, }) -- 波特率下拉框 local baudrate_dropdown = airui.dropdown({ parent = control_container, x = 70, y = 20, w = 120, h = 35, options = {"2400", "4800", "9600", "19200", "38400", "57600", "115200"}, default_index = 2, -- 默认选择9600 on_change = function(self,idx) log.info("baudrate", "选择了波特率:" .. self.options[idx + 1]) end }) -- 液位仪查询按钮 local query_btn = airui.button({ parent = control_container, x = 220, y = 20, w = 100, h = 35, text = "液位仪查询", on_click = function(self) log.info("ywy_page", "点击液位仪查询按钮") _G.show_page("tsb_ywy_1_page") end }) -- 液位仪透传按钮 local passthrough_btn = airui.button({ parent = control_container, x = 340, y = 20, w = 100, h = 35, text = "液位仪透传", on_click = function(self) log.info("ywy_page", "点击液位仪透传按钮") _G.show_page("tsb_ywy_2_page") end }) --------------------------------------------------- -- 底部信息 common_ui.create_status_bar(main_container) end -- 初始化页面 function tsb_ywy_page.init(params) tsb_ywy_page.create_ui() end -- 清理页面 function tsb_ywy_page.cleanup() -- 停止定时器 common_ui.cleanup() if main_container then main_container:destroy() main_container = nil end end return tsb_ywy_page