Xenao

Affichage Matrice Induction

Oct 14th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.83 KB | None | 0 0
  1. --Declaration des peripheriques
  2. matrice = peripheral.wrap("bottom")
  3. screen = peripheral.wrap("back")
  4.  
  5. --Debut du programme (boucle infinie)
  6. while true do
  7. --Recuperation des quantites d'energie stockes
  8. stock = matrice.getEnergyStored()
  9. os.sleep(0.2)
  10. stock2 = matrice.getEnergyStored()
  11.  
  12. --Clear de l'ecran
  13. screen.clear()
  14.  
  15. --Titre
  16. screen.setTextScale(2)
  17. screen.setTextColor(colors.blue)
  18. screen.setCursorPos(9,1)
  19. screen.write("Rendement energetique")
  20.  
  21.  
  22. --Affichage de la quantite d'enerie stocke
  23. screen.setCursorPos(3,3)
  24. screen.setTextColor(colors.black)
  25. screen.write("Stock actuel :")
  26. screen.setCursorPos(18,3)
  27. screen.setTextColor(colors.white)
  28. screen.write(stock/2500000000)
  29. screen.setCursorPos(24,3)
  30. screen.write(" ")
  31. screen.setCursorPos(25,3)
  32. screen.setTextColor(colors.black)
  33. screen.write("GRF")
  34. --Bug de la quantite trop longue a l'affichage
  35. screen.setCursorPos(28,3)
  36. screen.write("  ")
  37. --Recuperation de la capacite de stockage
  38. max = matrice.getMaxEnergyStored()
  39.  
  40. --Calcul du pourcentage de stockage utilise
  41. pourcent = (stock/max)*100
  42. --Affichage du pourcentage de stockage utilise
  43. screen.setCursorPos(30,3)
  44. screen.setTextColor(colors.white)
  45. screen.write(pourcent)
  46. screen.setCursorPos(34,3)
  47. screen.setTextColor(colors.black)
  48. screen.write("%")
  49. --Bug de la quantite trop longue a l'affichage
  50. screen.setCursorPos(35,3)
  51. screen.write("  ")
  52.  
  53.  
  54. consommation = stock - stock2
  55. screen.setCursorPos(3,4)
  56. screen.setTextColor(colors.black)
  57. screen.write("Consommation :")
  58. screen.setCursorPos(18,4)
  59. screen.setTextColor(colors.white)
  60. screen.write(math.ceil(consommation/10))
  61. screen.setCursorPos(23,4)
  62. screen.write("  ")
  63. screen.setCursorPos(25,4)
  64. screen.setTextColor(colors.black)
  65. screen.write("RF/T")
  66.  
  67. if consommation => 0
  68. then screen.setBackgroundColor(colors.red)
  69. elseif screen.setBackgroundColor(colors.green)
  70.  
  71. end
Advertisement
Add Comment
Please, Sign In to add comment