Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- GRAFICO ERGB
- mon = peripheral.wrap("back")
- shuntA = peripheral.wrap("top")
- shuntB = peripheral.wrap("bottom")
- url = "http://rest.rgbcraft.com/corrente/dati.php?nome1="
- suffisso = ""
- --for i=1,9 do
- for i=1,7 do
- sleep(0.5)
- uuid, st, nome, tabella = shuntA.get(i)
- h = i+1
- suffisso = suffisso..nome.."&potenza"..i.."="..tabella.average.."&nome"..h.."="
- print("Shunt A"..i)
- end
- --[[
- --for i=10,14 do
- --sleep(0.5)
- --uuid, st, nome, tabella = shuntB.get(i-9)
- --h = i+1
- --suffisso = suffisso..nome.."&potenza"..i.."="..tabella.average.."&nome"..h.."="
- --print("Shunt B"..i)
- --end
- --]]
- rest = http.get(url..suffisso)
- rest_repl = textutils.unserialize(rest.readAll())
- print(rest.readAll())
- rest.close()
- mon.setTextScale(0.5)
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write("Grafico consumo corrente")
- rest_minmax = http.get("http://rest.rgbcraft.com/corrente/minmax.php")
- minmax = textutils.unserialize(rest_minmax.readAll())
- rest_minmax.close()
- for k, v in ipairs(rest_repl) do
- y = (((v - minmax.min) * (3 - 17)) / (minmax.max - minmax.min)) + 17
- paintutils.drawPixel(k+7, y, colors.lime)
- sleep(0.1)
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(1,3)
- term.write(math.floor(tonumber(minmax.max)))
- term.setCursorPos(1,17)
- term.write(math.floor(tonumber(minmax.min)))
- term.setCursorPos(8,18)
- term.write(minmax.start)
- term.setCursorPos(46,18)
- term.write(minmax.finish)
- term.restore()
- term.clear()
- term.setCursorPos(1,1)
- for j=5,1,-1 do
- term.setCursorPos(1, 15)
- print("CD: "..j.." ")
- sleep(1)
- end
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement