| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- --[[
- @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
|