| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- --[[
- @module tsb_channel_page
- @summary 信道切换页面
- @version 1.0
- @date 2026.03.05
- @author 李一玮
- @usage
- 本文件是信道切换页面,展示信道切换的各种用法。
- ]]
- local tsb_channel_page = {}
- -- 页面UI元素
- local main_container = nil
- local common_ui = require("tsb_common_page")
- -- 创建UI
- function tsb_channel_page.create_ui()
- main_container = airui.container({
- x = 0,
- y = 0,
- w = 480,
- h = 320,
- color = 0xF5F5F5,
- color_opacity = 0
- })
- --------------------- 标题栏 ------------------------
- local title_bar = airui.container({
- parent = main_container,
- x = 0,
- y = 0,
- w = 480,
- h = 30,
- color = 0x7E57C2,
- })
- airui.label({
- parent = title_bar,
- text = "信道切换",
- x = 190,
- y = 8,
- w = 100,
- h = 20,
- font_size = 16,
- color = 0xFFFFFF,
- })
-
- -- 标题栏公共信息展示
- common_ui.add_battery_display(title_bar)
- common_ui.create_back_button(title_bar, tsb_channel_page.cleanup)
- ---------------------------------------------------
- -- 滚动容器
- local scroll_container = airui.container({
- parent = main_container,
- x = 0,
- y = 30,
- w = 480,
- h = 270,
- color = 0xFFFFFF,
-
- })
- 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 keyboard2 = airui.keyboard({
- x = 0,
- y = 0,
- w = 480,
- h = 160, -- x, y, 键盘默认打开ALIGN_BOTTOM_MID,位置从中下方开始计算
- mode = "lower", -- 键盘模式,可选 "text"/"upper"/"lower"/"numeric"
- auto_hide = true, -- 自动隐藏键盘
- bg_color = 0xf1f1f1, -- 键盘背景颜色为灰色,可选,不设置则透明
- on_commit = function() -- 确认事件回调,只有在按下确认键时才会触发
- log.info("keyboard", "commit")
- end
- })
- --------------------- 第一行控制区 ------------------------
- -- 当前lora信道标签
- airui.label({
- parent = scroll_container,
- text = "当前调试宝信道:",
- x = 10,
- y = 15,
- w = 120,
- h = 30,
- font_size = 15,
- })
- -- 当前lora信道值
- local current_channel_label = airui.label({
- parent = scroll_container,
- text = "1",
- x = 135,
- y = 15,
- w = 30,
- h = 30,
- font_size = 15,
- })
- -- 设置lora信道标签
- airui.label({
- parent = scroll_container,
- text = "设置调试宝信道:",
- x = 180,
- y = 15,
- w = 130,
- h = 30,
- font_size = 15,
- })
- -- 设置lora信道下拉框
- local channel_dropdown = airui.dropdown({
- parent = scroll_container,
- x = 310,
- y = 8,
- w = 70,
- h = 30,
- options = {"1", "2", "3", "4", "5", "6"},
- default_index = 0, -- 默认选择1
- on_change = function(self,idx)
- log.info("mqtt_channel", "选择了信道:" .. self.options[idx + 1])
- end
- })
- -- 目标设备类型标签
- airui.label({
- parent = scroll_container,
- text = "目标设备类型:",
- x = 10,
- y = 60,
- w = 100,
- h = 30,
- font_size = 15,
- })
- -- 目标设备类型下拉框
- local device_type_dropdown = airui.dropdown({
- parent = scroll_container,
- x = 120,
- y = 50,
- w = 100,
- h = 35,
- options = {"路由器", "连接器"},
- default_index = 0, -- 默认选择路由器
- on_change = function(self,idx)
- log.info("device_type", "选择了设备类型:" .. self.options[idx + 1])
- end
- })
- airui.label({
- parent = scroll_container,
- text = "目标设备SN:",
- x = 10,
- y = 110,
- w = 100,
- h = 30,
- font_size = 15,
- })
- -- 连接器SN输入框
- local sn_input = airui.textarea({
- parent = scroll_container,
- x = 120,
- y = 100,
- w = 100,
- h = 35,
- text = "",
- max_length = 5,
- keyboard = keyboard1
- })
- airui.label({
- parent = scroll_container,
- text = "切换到信道:",
- x = 10,
- y = 160,
- w = 100,
- h = 20,
- font_size = 15,
- })
- local channel1_dropdown = airui.dropdown({
- parent = scroll_container,
- x = 120,
- y = 150,
- w = 70,
- h = 35,
- options = {"1", "2", "3", "4", "5", "6"},
- default_index = 0, -- 默认选择1
- on_change = function(self,idx)
- log.info("mqtt_channel", "选择了信道:" .. self.options[idx + 1])
- end
- })
- ---------------------------------------------------
- -- 新配置下发按钮
- local new_config_btn = airui.button({
- parent = scroll_container,
- x = 30,
- y = 200,
- w = 100,
- h = 35,
- text = "指令下发",
- --stype = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 },
- on_click = function(self)
- log.info("mqtt_config", "新配置下发按钮被点击")
- end
- })
- -- 恢复默认配置按钮
- -- local default_config_btn = airui.button({
- -- parent = scroll_container,
- -- x = 120,
- -- y = 230,
- -- w = 120,
- -- h = 35,
- -- text = "恢复默认配置",
- -- on_click = function(self)
- -- log.info("mqtt_config", "恢复默认配置按钮被点击")
- -- end
- -- })
- -- 执行结果
- airui.label({
- parent = scroll_container,
- text = "执行结果:",
- x = 270,
- y = 210,
- w = 80,
- h = 30,
- font_size = 16,
- })
- -- 执行结果值
- local result_label = airui.label({
- parent = scroll_container,
- text = "成功",
- x = 350,
- y = 210,
- w = 100,
- h = 30,
- font_size = 16,
- })
- ---------------------------------------------------
- -- 底部信息
- common_ui.create_status_bar(main_container)
- end
- -- 初始化页面
- function tsb_channel_page.init(params)
- tsb_channel_page.create_ui()
- end
- -- 清理页面
- function tsb_channel_page.cleanup()
- if main_container then
- main_container:destroy()
- main_container = nil
- end
- end
- return tsb_channel_page
|