Manual iris control

This commit is contained in:
2026-01-01 23:47:11 -05:00
parent 0906603e58
commit 02faa9dc04
2 changed files with 46 additions and 2 deletions

View File

@ -54,12 +54,17 @@ function display.drawIrisStatus()
local irisState = utils.getIrisState() local irisState = utils.getIrisState()
if irisState == "OPEN" then if irisState == "OPEN" then
mon.setTextColor(colors.green) mon.setTextColor(colors.green)
mon.write("TOGGLE IRIS ")
elseif irisState == "CLOSED" then elseif irisState == "CLOSED" then
mon.setTextColor(colors.red) mon.setTextColor(colors.red)
mon.write("TOGGLE IRIS ")
elseif irisState == "MOVING" then
mon.setTextColor(colors.gray)
mon.write("IRIS MOVING ")
else else
mon.setTextColor(colors.gray) mon.setTextColor(colors.gray)
mon.write("IRIS: " .. irisState .. " ")
end end
mon.write("IRIS: " .. irisState .. " ")
mon.setTextColor(colors.white) mon.setTextColor(colors.white)
if irisState == "MOVING" then if irisState == "MOVING" then
sleep(0.1) sleep(0.1)
@ -194,6 +199,8 @@ function display.showIncoming(addressName, addressString, allowed, reason)
mon.setCursorPos(1, 7) mon.setCursorPos(1, 7)
mon.write(addressString) mon.write(addressString)
end end
display.drawIrisStatus()
end end
function display.showEntity(entityType, entityName, allowed) function display.showEntity(entityType, entityName, allowed)

View File

@ -98,6 +98,41 @@ function handlers.handlePasswordInput()
end end
--------------------------------------------- ---------------------------------------------
-- IRIS STATUS CLICK HANDLER (Toggle)
---------------------------------------------
function handlers.handleIrisToggle(eventType, side, x, y)
-- Only process if not entering password (password handler has higher priority)
if state.enteringPassword then
return nil
end
-- Only process if iris is enabled
if not config.irisEnabled then
return nil
end
-- Check if clicking on iris status area (bottom-left corner where "IRIS: STATUS" appears)
-- The iris status is at position (1, 19) and extends roughly 15-20 characters
if y == 19 and x >= 1 and x <= 20 then
local irisState = utils.getIrisState()
-- Toggle based on current state
if irisState == "OPEN" then
utils.closeIris()
display.drawIrisStatus()
return "iris_closed"
elseif irisState == "CLOSED" then
utils.openIris()
display.drawIrisStatus()
return "iris_opened"
end
-- If MOVING or NO IRIS, do nothing
end
return nil -- Not an iris status click
end ---------------------------------------------
-- DISCONNECT BUTTON HANDLER -- DISCONNECT BUTTON HANDLER
--------------------------------------------- ---------------------------------------------
@ -169,6 +204,7 @@ end
function handlers.handleMessage(eventType, side, message) function handlers.handleMessage(eventType, side, message)
state.lastReceivedMessage = message state.lastReceivedMessage = message
utils.debug("Message Received: " .. message)
return "message_received" return "message_received"
end end
@ -200,8 +236,9 @@ function handlers.setupConnectionHandlers()
-- Clear any existing handlers -- Clear any existing handlers
events.clearHandlers() events.clearHandlers()
-- Register all handlers with their priorities -- Register all handlers with their priorities
events.registerHandler("monitor_touch", handlers.handleIrisToggle, events.PRIORITY.DISCONNECT_BUTTON) -- Same priority as disconnect
events.registerHandler("monitor_touch", handlers.handleDisconnectButton, events.PRIORITY.DISCONNECT_BUTTON) events.registerHandler("monitor_touch", handlers.handleDisconnectButton, events.PRIORITY.DISCONNECT_BUTTON)
events.registerHandler("monitor_touch", handlers.handleDefaultClick, events.PRIORITY.DEFAULT) -- Lowest priority - returns coordinates events.registerHandler("monitor_touch", handlers.handleDefaultClick, events.PRIORITY.DEFAULT) -- Lowest priority - returns coordinates
events.registerHandler("stargate_incoming_wormhole", handlers.handleActivation, events.PRIORITY.ACTIVATION) events.registerHandler("stargate_incoming_wormhole", handlers.handleActivation, events.PRIORITY.ACTIVATION)
events.registerHandler("stargate_reconstructing_entity", handlers.handleEntityRead, events.PRIORITY.ENTITY_READ) events.registerHandler("stargate_reconstructing_entity", handlers.handleEntityRead, events.PRIORITY.ENTITY_READ)
events.registerHandler("stargate_disconnected", handlers.handleDisconnect, events.PRIORITY.DISCONNECT_CHECK) events.registerHandler("stargate_disconnected", handlers.handleDisconnect, events.PRIORITY.DISCONNECT_CHECK)