diff --git a/pocket/ui/pages/facility_matrix.lua b/pocket/ui/pages/facility_matrix.lua index 7287457..1a1f42c 100644 --- a/pocket/ui/pages/facility_matrix.lua +++ b/pocket/ui/pages/facility_matrix.lua @@ -10,12 +10,15 @@ local core = require("graphics.core") local Div = require("graphics.elements.Div") local TextBox = require("graphics.elements.TextBox") +local PushButton = require("graphics.elements.controls.PushButton") + local DataIndicator = require("graphics.elements.indicators.DataIndicator") local HorizontalBar = require("graphics.elements.indicators.HorizontalBar") local IconIndicator = require("graphics.elements.indicators.IconIndicator") local PowerIndicator = require("graphics.elements.indicators.PowerIndicator") local StateIndicator = require("graphics.elements.indicators.StateIndicator") +local ALIGN = core.ALIGN local cpair = core.cpair local label = style.label @@ -30,29 +33,29 @@ local mode_ind_s = { -- create an induction matrix view for the facility app ---@param app pocket_app ---@param panes Div[] ----@param tank_pane Div +---@param matrix_pane Div ---@param ps psil ---@param update function -return function (app, panes, tank_pane, ps, update) +return function (app, panes, matrix_pane, ps, update) local db = iocontrol.get_db() local fac = db.facility - local mtx_div = Div{parent=tank_pane,x=2,width=tank_pane.get_width()-2} + local mtx_div = Div{parent=matrix_pane,x=2,width=matrix_pane.get_width()-2} table.insert(panes, mtx_div) local matrix_page = app.new_page(nil, #panes) matrix_page.tasks = { update } - TextBox{parent=mtx_div,y=1,text="I Matrix",width=9} - local status = StateIndicator{parent=mtx_div,x=10,y=1,states=style.imatrix.states,value=1,min_width=12} + TextBox{parent=mtx_div,y=1,text="Induction Matrix",alignment=ALIGN.CENTER} + local status = StateIndicator{parent=mtx_div,x=5,y=3,states=style.imatrix.states,value=1,min_width=12} status.register(ps, "InductionMatrixStateStatus", status.update) - TextBox{parent=mtx_div,text="Charge",x=1,y=5,fg_bg=label} - local chg_bar = HorizontalBar{parent=mtx_div,x=1,y=6,fg_bg=cpair(colors.green,colors.gray)} - TextBox{parent=mtx_div,text="Input",x=1,y=7,fg_bg=label} - local in_bar = HorizontalBar{parent=mtx_div,x=1,y=8,fg_bg=cpair(colors.blue,colors.gray)} - TextBox{parent=mtx_div,text="Output",x=21,y=9,fg_bg=label} - local out_bar = HorizontalBar{parent=mtx_div,x=1,y=10,fg_bg=cpair(colors.red,colors.gray)} + TextBox{parent=mtx_div,text="Chg",y=5,fg_bg=label} + local chg_bar = HorizontalBar{parent=mtx_div,x=5,y=5,height=1,fg_bg=cpair(colors.green,colors.gray)} + TextBox{parent=mtx_div,text="In",y=7,fg_bg=label} + local in_bar = HorizontalBar{parent=mtx_div,x=5,y=7,height=1,fg_bg=cpair(colors.blue,colors.gray)} + TextBox{parent=mtx_div,text="Out",y=9,fg_bg=label} + local out_bar = HorizontalBar{parent=mtx_div,x=5,y=9,height=1,fg_bg=cpair(colors.red,colors.gray)} local function calc_saturation(val) local data = fac.induction_data_tbl[1] @@ -65,12 +68,12 @@ return function (app, panes, tank_pane, ps, update) in_bar.register(ps, "last_input", function (val) in_bar.update(calc_saturation(val)) end) out_bar.register(ps, "last_output", function (val) out_bar.update(calc_saturation(val)) end) - local energy = PowerIndicator{parent=mtx_div,x=1,y=12,lu_colors=lu_col,label="Chg: ",unit=db.energy_label,format="%8.2f",value=0,width=22,fg_bg=text_fg} - local avg_chg = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="\xb7Avg:",unit=db.energy_label,format="%8.2f",value=0,width=22,fg_bg=text_fg} - local input = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="In: ",unit=db.energy_label,format="%8.2f",rate=true,value=0,width=22,fg_bg=text_fg} - local avg_in = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="\xb7Avg:",unit=db.energy_label,format="%8.2f",rate=true,value=0,width=22,fg_bg=text_fg} - local output = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="Out: ",unit=db.energy_label,format="%8.2f",rate=true,value=0,width=22,fg_bg=text_fg} - local avg_out = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="\xb7Avg:",unit=db.energy_label,format="%8.2f",rate=true,value=0,width=22,fg_bg=text_fg} + local energy = PowerIndicator{parent=mtx_div,x=1,y=11,lu_colors=lu_col,label="Chg: ",unit=db.energy_label,format="%8.2f",value=0,width=22,fg_bg=text_fg} + local avg_chg = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="\xb7Avg: ",unit=db.energy_label,format="%8.2f",value=0,width=22,fg_bg=text_fg} + local input = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="In: ",unit=db.energy_label,format="%8.2f",rate=true,value=0,width=22,fg_bg=text_fg} + local avg_in = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="\xb7Avg: ",unit=db.energy_label,format="%8.2f",rate=true,value=0,width=22,fg_bg=text_fg} + local output = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="Out: ",unit=db.energy_label,format="%8.2f",rate=true,value=0,width=22,fg_bg=text_fg} + local avg_out = PowerIndicator{parent=mtx_div,x=1,lu_colors=lu_col,label="\xb7Avg: ",unit=db.energy_label,format="%8.2f",rate=true,value=0,width=22,fg_bg=text_fg} energy.register(ps, "energy", function (val) energy.update(db.energy_convert(val)) end) avg_chg.register(fac.ps, "avg_charge", avg_chg.update) @@ -79,5 +82,16 @@ return function (app, panes, tank_pane, ps, update) output.register(ps, "last_output", function (val) output.update(db.energy_convert(val)) end) avg_out.register(fac.ps, "avg_outflow", avg_out.update) + local mtx_ext_div = Div{parent=matrix_pane,x=2,width=matrix_pane.get_width()-2} + table.insert(panes, mtx_ext_div) + + local mtx_ext_page = app.new_page(matrix_page, #panes) + mtx_ext_page.tasks = { update } + + PushButton{parent=mtx_div,x=9,y=18,text="MORE",min_width=6,fg_bg=cpair(colors.lightGray,colors.gray),active_fg_bg=cpair(colors.gray,colors.lightGray),callback=mtx_ext_page.nav_to} + PushButton{parent=mtx_ext_div,x=9,y=18,text="BACK",min_width=6,fg_bg=cpair(colors.lightGray,colors.gray),active_fg_bg=cpair(colors.gray,colors.lightGray),callback=matrix_page.nav_to} + + TextBox{parent=mtx_ext_div,y=1,text="More Matrix Info",alignment=ALIGN.CENTER} + return matrix_page.nav_to end