Advertisement
lego11

Untitled

Jul 5th, 2020
1,229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- GRAFICO ERGB
  2.  
  3. mon = peripheral.wrap("back")
  4.  
  5. shuntA = peripheral.wrap("top")
  6. shuntB = peripheral.wrap("bottom")
  7. url = "http://rest.rgbcraft.com/corrente/dati.php?nome1="
  8. suffisso = ""
  9. --for i=1,9 do
  10. for i=1,7 do
  11. sleep(0.5)
  12. uuid, st, nome, tabella = shuntA.get(i)
  13. h = i+1
  14. suffisso = suffisso..nome.."&potenza"..i.."="..tabella.average.."&nome"..h.."="
  15. print("Shunt A"..i)
  16. end
  17. --[[
  18. --for i=10,14 do
  19. --sleep(0.5)
  20. --uuid, st, nome, tabella = shuntB.get(i-9)
  21. --h = i+1
  22. --suffisso = suffisso..nome.."&potenza"..i.."="..tabella.average.."&nome"..h.."="
  23. --print("Shunt B"..i)
  24. --end
  25. --]]
  26.  
  27. rest = http.get(url..suffisso)
  28. rest_repl = textutils.unserialize(rest.readAll())
  29. print(rest.readAll())
  30. rest.close()
  31.  
  32. mon.setTextScale(0.5)
  33. mon.clear()
  34. mon.setCursorPos(1,1)
  35. mon.write("Grafico consumo corrente")
  36.  
  37. rest_minmax = http.get("http://rest.rgbcraft.com/corrente/minmax.php")
  38. minmax = textutils.unserialize(rest_minmax.readAll())
  39. rest_minmax.close()
  40.  
  41. for k, v in ipairs(rest_repl) do
  42. y = (((v - minmax.min) * (3 - 17)) / (minmax.max - minmax.min)) + 17
  43. paintutils.drawPixel(k+7, y, colors.lime)
  44. sleep(0.1)
  45. end
  46. term.setBackgroundColor(colors.black)
  47. term.setTextColor(colors.white)
  48. term.setCursorPos(1,3)
  49. term.write(math.floor(tonumber(minmax.max)))
  50. term.setCursorPos(1,17)
  51. term.write(math.floor(tonumber(minmax.min)))
  52. term.setCursorPos(8,18)
  53. term.write(minmax.start)
  54. term.setCursorPos(46,18)
  55. term.write(minmax.finish)
  56. term.restore()
  57. term.clear()
  58. term.setCursorPos(1,1)
  59.  
  60. for j=5,1,-1 do
  61. term.setCursorPos(1, 15)
  62. print("CD: "..j.."   ")
  63. sleep(1)
  64. end
  65. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement