Advertisement
cyber_Ahn

7 Segemet Clock

Jan 30th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. local seg1 = "left"
  2. local seg2 = "bottom"
  3. local seg3 = "back"
  4. local seg4 = "right"
  5. local time_is = ""
  6. local at
  7. local bt
  8. local ct
  9. local dt
  10. print("loading API")
  11. shell.run("delete caAPI")
  12. shell.run("pastebin get EDLdR1nF caAPI")
  13. os.loadAPI("caAPI")
  14. local ix = true
  15. while ix == true do
  16. print("loading time")
  17. time_is = caAPI.getTime()
  18. print(time_is)
  19. print("split time")
  20. length = #time_is
  21. if length == 4 then
  22. at = "0"
  23. bt = string.sub(time_is,1,1)
  24. ct = string.sub(time_is,3,3)
  25. dt = string.sub(time_is,4,4)
  26. else
  27. at = string.sub(time_is,1,1)
  28. bt = string.sub(time_is,2,2)
  29. ct = string.sub(time_is,4,4)
  30. dt = string.sub(time_is,5,5)
  31. end
  32. print(at)
  33. print(bt)
  34. print(ct)
  35. print(dt)
  36. print("decode to 7 seg bundledCable")
  37. color_at = caAPI.numToSegCol(at)
  38. color_bt = caAPI.numToSegCol(bt)
  39. color_ct = caAPI.numToSegCol(ct)
  40. color_dt = caAPI.numToSegCol(dt)
  41. print("set Time on Display")
  42. if at == "0" then
  43. rs.setBundledOutput(seg4,colors.black)
  44. else
  45. rs.setBundledOutput(seg4,color_at)
  46. end
  47. rs.setBundledOutput(seg3,color_bt)
  48. rs.setBundledOutput(seg2,color_ct)
  49. rs.setBundledOutput(seg1,color_dt)
  50. sleep(2)
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement