--[[ @module tsb_tq_page @summary 提枪信号演示页面 @version 1.0 @date 2026.03.04 @author 李一玮 @usage 本文件是提枪信号演示页面,展示提枪信号的各种用法。 ]] local tsb_tq_page = {} -- 页面UI元素 local main_container = nil local common_ui = require("tsb_common_page") -- 创建UI function tsb_tq_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 = 0xF44336, }) airui.label({ parent = title_bar, text = "提枪信号", x = 200, 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_tq_page.cleanup) --------------------------------------------------- -- 滚动容器 local scroll_container = airui.container({ parent = main_container, x = 0, y = 30, w = 480, h = 270, color = 0xF5F5F5, }) local keyboard1 = airui.keyboard({ x = 0, y = 0, w = 480, h = 160, -- x, y, 键盘默认打开ALIGN_BOTTOM_MID,位置从中下方开始计算 mode = "numeric", -- 键盘模式,可选 "text"/"upper"/"lower"/"numeric" auto_hide = true, -- 自动隐藏键盘 bg_color = 0xf1f1f1, -- 键盘背景颜色为灰色,可选,不设置则透明 on_commit = function() -- 确认事件回调,只有在按下确认键时才会触发 log.info("keyboard", "commit") end }) ------------------- 提枪信号输入 ------------------ local tq_input_container = airui.container({ parent = scroll_container, x = 10, y = 5, w = 200, h = 260, color = 0xFFFFFF, radius = 5, }) airui.label({ parent = tq_input_container, text = "提枪信号输入", x = 35, y = 10, w = 140, h = 30, font_size = 18, }) airui.label({ parent = tq_input_container, text = "油枪状态:", x = 20, y = 80, w = 80, h = 30, font_size = 16, }) local label_cur_vol = airui.label({ parent = tq_input_container, text = "抬枪", x = 100, y = 80, w = 60, h = 30, font_size = 16, }) airui.label({ parent = tq_input_container, text = "实时电压:", x = 20, y = 140, w = 100, h = 30, font_size = 16, }) local label_pulse_count = airui.label({ parent = tq_input_container, text = "5.0V", x = 100, y = 140, w = 70, h = 30, font_size = 16, }) ---------------------------------------------------- ------------------- 提枪信号输出 ------------------ local tq_output_container = airui.container({ parent = scroll_container, x = 220, y = 5, w = 250, h = 260, color = 0xFFFFFF, radius = 5, }) airui.label({ parent = tq_output_container, text = "提枪信号输出", x = 60, y = 10, w = 140, h = 30, font_size = 18, }) -- 输出电压 airui.label({ parent = tq_output_container, text = "输出电压:", x = 20, y = 80, w = 80, h = 30, font_size = 16, }) local voltage_output = airui.textarea({ parent = tq_output_container, x = 100, y = 72, w = 60, h = 35, text = "5", max_len = 2, keyboard = keyboard1 }) airui.label({ parent = tq_output_container, text = "V", x = 165, y = 80, w = 30, h = 30, font_size = 16, }) --------------------- 新国标开关 ------------------- airui.label({ parent = tq_output_container, text = "周期输出:", x = 20, y = 140, w = 80, h = 20, font_size = 16, }) local switch_tq = airui.switch({ parent = tq_output_container, x = 100, y = 133, w = 55, h = 25, checked = false, on_change = function(self) log.info("NEW_TAX", self:get_state() and "开启" or "关闭") end }) airui.label({ parent = tq_output_container, text = "开启后,提枪信号将按照3s的周期切换输出上面设置的电压和0V。", x = 20, y = 170, w = 200, h = 40, font_size = 12, color = 0x757575, }) -- 按钮 local start_btn = airui.button({ parent = tq_output_container, x = 40, y = 215, w = 80, h = 35, text = "开始", stype = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 }, on_click = function(self) log.info("button", "开始按钮被点击") end }) local stop_btn = airui.button({ parent = tq_output_container, x = 130, y = 215, w = 80, h = 35, text = "停止", on_click = function(self) log.info("button", "停止按钮被点击") end }) ---------------------------------------------------- -- 底部信息 common_ui.create_status_bar(main_container) end -- 初始化页面 function tsb_tq_page.init(params) tsb_tq_page.create_ui() end -- 清理页面 function tsb_tq_page.cleanup() if main_container then main_container:destroy() main_container = nil end end return tsb_tq_page