Compare commits

...

2 Commits

Author SHA1 Message Date
e1e996e50f Fix ThrottleInit (2) 2026-06-25 06:22:27 -05:00
1f487a98c4 fix ThrottleInit (1) 2026-06-25 06:20:15 -05:00

View File

@@ -117,7 +117,24 @@ Config.Autopilot = {
AutopilotDesiredHeading = nil AutopilotDesiredHeading = nil
} }
Throttles = {
ForeThrottle = {
name = nil,
side = nil
},
AftThrottle = {
name = nil,
side = nil
},
DownThrottle = {
name = nil,
side = nil
}
}
function ThrottleInit() function ThrottleInit()
Throttles = {}
local sides = { local sides = {
"top", "top",
"bottom", "bottom",
@@ -171,6 +188,46 @@ function ThrottleInit()
end end
end end
end end
print("\nIdentifying aft throttle")
print("\nPlease change the input signal for the throttle")
local initialStates = getRelayStates()
while true do
local currentStates = getRelayStates()
for pname, currentState in pairs(currentStates) do
local initialState = initialStates[pname]
for k, v in pairs(currentState) do
if initialState[k] ~= v then
Throttles.AftThrottleThrottle.name = pname
Throttles.AftThrottle.side = k
return
end
end
end
end
print("\nIdentifying down throttle")
print("\nPlease change the input signal for the throttle")
local initialStates = getRelayStates()
while true do
local currentStates = getRelayStates()
for pname, currentState in pairs(currentStates) do
local initialState = initialStates[pname]
for k, v in pairs(currentState) do
if initialState[k] ~= v then
Throttles.DownThrottle.name = pname
Throttles.DownThrottle.side = k
return
end
end
end
end
end end
function PropellerInit() function PropellerInit()
@@ -679,35 +736,6 @@ function collectSensorData()
return data return data
end end
function Main()
Init()
while true do
local sensorData = collectSensorData()
-- Update monitor displays
if Config.Monitors.InstrumentPanelMonitor then
displayInstrumentPanel(Config.Monitors.InstrumentPanelMonitor, sensorData)
end
if Config.Monitors.AutopilotControlMonitor then
displayAutopilotControls(Config.Monitors.AutopilotControlMonitor, sensorData)
end
local unindexedThrusters = checkIfThrusterIsIndexed()
if unindexedThrusters ~= nil then
partiallyUpdateThrusters(unindexedThrusters)
end
PollSensors()
UpdateGlobalThrust()
UpdateStabilization()
-- Add a small delay to avoid overloading the system
os.sleep(0.1)
end
end
function displayAutopilotControls(monitor) function displayAutopilotControls(monitor)
if not monitor or not monitor.peripheral then return end if not monitor or not monitor.peripheral then return end
@@ -759,4 +787,4 @@ function Main()
end end
-- Run the main function when the script starts -- Run the main function when the script starts
Main() Main()