#604 start of total rework of redstone RTUs for relay functionalitiy

This commit is contained in:
Mikayla Fischler
2025-04-21 22:18:09 -04:00
parent 48ec973695
commit 0d7302dc8e
6 changed files with 87 additions and 53 deletions

View File

@@ -11,10 +11,14 @@ local digital_write = rsio.digital_write
-- create new redstone device
---@nodiscard
---@param relay? table optional redstone relay to use instead of the computer's redstone interface
---@return rtu_rs_device interface, boolean faulted
function redstone_rtu.new()
function redstone_rtu.new(relay)
local unit = rtu.init_unit()
-- physical interface to use
local phy = relay or rs
-- get RTU interface
local interface = unit.interface()
@@ -30,6 +34,12 @@ function redstone_rtu.new()
write_holding_reg = interface.write_holding_reg
}
-- change the phy in use (a relay or rs)
---@param new_phy table
function public.change_phy(new_phy) phy = new_phy end
-- NOTE: for runtime speed, inversion logic results in extra code here but less code when functions are called
-- link digital input
---@param side string
---@param color integer