| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- --[[
- @module tsb_232log_page
- @summary 232日志页面
- @version 1.0
- @date 2026.03.17
- @author 李一玮
- @usage
- 本文件是232日志页面,展示232日志的各种用法。
- ]]
- local tsb_232log_page = {}
- -- 页面UI元素
- local main_container = nil
- local common_ui = require("tsb_common_page")
- -- 创建UI
- function tsb_232log_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 = 0xFFCCBC,
- })
- airui.label({
- parent = title_bar,
- text = "232监测界面",
- x = 190,
- y = 8,
- w = 200,
- h = 20,
- font_size = 16,
- color = 0xFFFFFF,
- })
- -- 标题栏公共信息展示
- common_ui.add_battery_display(title_bar)
- common_ui.create_back_button(title_bar, tsb_232log_page.cleanup)
- -- 滚动容器
- local scroll_container = airui.container({
- parent = main_container,
- x = 0,
- y = 30,
- w = 480,
- h = 270,
- color = 0xFFFFFF,
- })
- --------------------- 控制区 ------------------------
- -- 波特率标签
- airui.label({
- parent = scroll_container,
- text = "波特率:",
- x = 5,
- y = 16,
- w = 60,
- h = 30,
- font_size = 15,
- })
- -- 波特率下拉框
- local baudrate_dropdown = airui.dropdown({
- parent = scroll_container,
- x = 65,
- y = 7,
- w = 100,
- h = 35,
- options = {"2400", "4800", "9600", "19200", "38400", "57600", "115200"},
- default_index = 2, -- 默认选择9600
- on_change = function(self,idx)
- log.info("485_baudrate", "选择了波特率:" .. self.options[idx + 1])
- end
- })
- airui.label({
- parent = scroll_container,
- text = "推测:",
- x = 180,
- y = 16,
- w = 40,
- h = 30,
- font_size = 15,
- })
- local baud_predict = airui.label({
- parent = scroll_container,
- text = "2400",
- x = 220,
- y = 15,
- w = 50,
- h = 20,
- font_size = 15,
- })
- --------------------- 485日志显示 ------------------------
- local log_container = airui.container({
- parent = scroll_container,
- x = 0,
- y = 45,
- w = 480,
- h = 222,
- color = 0xFFFFFF,
- })
- -- 日志内容显示
- local log_content = airui.textarea({
- parent = log_container,
- x = 5,
- y = 5,
- w = 470,
- h = 212,
- text = "00 01 02 03 04 05 06 07\n" ..
- "08 09 0A 0B 0C 0D 0E 0F\n"
- })
- -- 开始监测按钮
- local start_btn = airui.button({
- parent = scroll_container,
- x = 285,
- y = 5,
- w = 100,
- h = 35,
- text = "开始监测",
- stype = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 },
- on_click = function(self)
- log.info("485_log", "开始监测按钮被点击")
- end
- })
- -- 清空按钮
- local clear_btn = airui.button({
- parent = scroll_container,
- x = 395,
- y = 5,
- w = 80,
- h = 35,
- text = "清空",
- on_click = function(self)
- log.info("485_log", "清空按钮被点击")
- -- 清空日志内容
- log_content:set_text("")
- end
- })
- ---------------------------------------------------
- -- 底部信息
- common_ui.create_status_bar(main_container)
- end
- -- 初始化页面
- function tsb_232log_page.init(params)
- tsb_232log_page.create_ui()
- end
- -- 清理页面
- function tsb_232log_page.cleanup()
- if main_container then
- main_container:destroy()
- main_container = nil
- end
- end
- return tsb_232log_page
|