#200 RPS view on pocket

This commit is contained in:
Mikayla Fischler
2024-05-12 13:28:34 -04:00
parent 6a8ed311f3
commit 7f009f9c86
4 changed files with 98 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
-- Icon Indicator Graphics Element
local element = require("graphics.element")
local util = require("scada-common.util")
---@class icon_sym_color
---@field color cpair
@@ -9,7 +10,7 @@ local element = require("graphics.element")
---@class icon_indicator_args
---@field label string indicator label
---@field states table state color and symbol table
---@field value? integer default state, defaults to 1
---@field value? integer|boolean default state, defaults to 1 (true = 2, false = 1)
---@field min_label_width? integer label length if omitted
---@field parent graphics_element
---@field id? string element id
@@ -33,6 +34,7 @@ local function icon(args)
local e = element.new(args)
e.value = args.value or 1
if e.value == true then e.value = 2 end
-- state blit strings
local state_blit_cmds = {}
@@ -47,8 +49,11 @@ local function icon(args)
end
-- on state change
---@param new_state integer indicator state
---@param new_state integer|boolean indicator state
function e.on_update(new_state)
new_state = new_state or 1
if new_state == true then new_state = 2 end
local blit_cmd = state_blit_cmds[new_state]
e.value = new_state
e.w_set_cur(1, 1)
@@ -56,7 +61,7 @@ local function icon(args)
end
-- set indicator state
---@param val integer indicator state
---@param val integer|boolean indicator state
function e.set_value(val) e.on_update(val) end
-- element redraw