Posted 25 October 2017 - 02:23 PM
Hello every one, very long time i dont sing in, first its first, thanks for the answers in my R.I.P "Launchpad Controller", when i post that, afther 2 weeks whit no response i didont get in more, but today , i was having problems and when i sing in, i saw my forgoten post, and the answers, maybe later I correct that code for a new launchpad when i go again to the moon or mars ect…
I "recycle" that code to make a brand new Pneumaticraft Air Compressor controller, and i finish it and works, but i like to ask how i can make the program's menu to refres pressure, here is the code:
As you all can see, my code is very complex, i could make it more easy and simply, but this way i think is better for learning.
these last 2 lines dont work for refresing, i thing i need a "if bucle" or a "while bucle" for the refresing but didont know where i have to put then and how. Thanks a lot.
I "recycle" that code to make a brand new Pneumaticraft Air Compressor controller, and i finish it and works, but i like to ask how i can make the program's menu to refres pressure, here is the code:
Spoiler
Aire = peripheral.wrap("back")
presion = Aire.getPressure()
RUN = true
opcion = ""
determinada = ""
function close()
sleep(3)
RUN = false
end
function MENU ()
term.clear()
term.setCursorPos(1,1)
print(" ----- Air Compressor Controler -----")
print("WARNING por precaucion este compresor no llegara a 5 bares de presion nunca")
term.setCursorPos(1,4)
print("presion maxima : " ..Aire.getDangerPressure())
term.setCursorPos(1,5)
print("Presion actual : " ..presion) --<This one i want to refres to show in the menu the current pressiure at all times
term.setCursorPos(1,7)
print("Encender compresor 01")
print("Apagar compresor 02")
print("Compresor Automatico 03")
print("Encender hasta presion determinada 04")
print("Salir del programa 05")
term.setCursorPos(1,13)
print("Seleccion? : ") --posicion 14,13
term.setCursorPos(14,13)
opcion = read()
if opcion == "01" then
ON()
elseif opcion == "02" then
OFF()
elseif opcion == "03" then
AUTO()
elseif opcion == "04" then
HASTA()
elseif opcion == "05" then
Exit()
end
end
function ON()
rs.setOutput("back",true)
term.setCursorPos(1,16)
print("Compresor encendido")
sleep(0.5)
MENU()
end
function OFF()
rs.setOutput("back",false)
term.setCursorPos(1,16)
print("Compresor apagado")
sleep(0.5)
MENU()
end
function AUTO()
if presion < 4.5 then
rs.setOutput("back", true)
sleep(0.1)
else
rs.setOutput("back", false)
sleep(0.1)
MENU()
end
end
function HASTA()
term.setCursorPos(1,15)
print("hasta que presion? (si el compresor es de 5 bares y la tuberias de 5 bares no se recomienda)")
term.setCursorPos(1,16)
determinada = read()
if presion < determinada then
rs.setOutput("back",true)
presion = Aire.getPressure()
term.setCursorPos(1,17)
print("comprimiendo.. : " .. presion)
sleep(0.1)
elseif presion >= determinada then
rs.setOutput("back",false)
sleep(0.1)
MENU()
end
end
function Exit ()
term.clear()
print("hasta la proxima!!!")
close()
end
while RUN do
MENU()
term.setCursorPos(1,5) ---fail to do refres
print("Presion actual : " ..presion) --same here this one and the other i going to delete, works on menu but no working for refresing.
end
As you all can see, my code is very complex, i could make it more easy and simply, but this way i think is better for learning.
these last 2 lines dont work for refresing, i thing i need a "if bucle" or a "while bucle" for the refresing but didont know where i have to put then and how. Thanks a lot.
Edited on 26 October 2017 - 08:37 AM