-- -- montest.lua -- -- Minimal isolation test for monitor buttons. Puts ONE button on a monitor and -- counts presses on that same monitor. If touching it bumps the counter, monitor -- buttons work in mimic; if not, the problem is mimic's touch handling itself. -- -- montest -- uses monitor "right" -- montest monitor_1 -- uses a named monitor -- -- Ctrl+T to stop. -- require("/initenv").init_env() local mimic = require("mimic") local m = require("mimic.elements") local psil = require("scada-common.psil") local style = mimic.style local MON = ... or "right" local ps = psil.create() local root = mimic.init{ps=ps} -- terminal m.TextBox{parent=root, x=1, y=1, width=40, text="montest - touch the monitor button"} m.TextBox{parent=root, x=1, y=2, width=40, text="monitor: " .. MON} if not (peripheral.isPresent(MON) and peripheral.getType(MON) == "monitor") then m.TextBox{parent=root, x=1, y=4, width=45, text="NO MONITOR named '" .. MON .. "' - pass the right name", fg_bg=mimic.cpair(colors.red, style.theme.bg)} mimic.run() return end local board = mimic.add_display{monitor=MON, ps=ps} local count = 0 m.TextBox{parent=board, x=2, y=2, width=28, text="Touch PRESS ME below:"} local counter = m.TextBox{parent=board, x=2, y=8, width=28, text="presses: 0"} m.PushButton{parent=board, x=2, y=5, text="PRESS ME", min_width=14, fg_bg=style.wh_gray, active_fg_bg=style.ind_grn, callback=function () count = count + 1 counter.set_value("presses: " .. count) end} mimic.run()