Guest User

Untitled

a guest
Nov 14th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. -- grid and arc test
  2. -- for arc-dev branch
  3.  
  4. engine.name = 'PolyPerc'
  5.  
  6. steps = {}
  7. aleds = {}
  8. position = 1
  9. intensity = 1
  10.  
  11. local g = grid.connect()
  12. local ar = arc.connect()
  13.  
  14. function allLeds(z)
  15. for i=1,4 do
  16. ar.all(i, z)
  17. end
  18. end
  19.  
  20. function allRefresh()
  21. for i=1,4 do
  22. ar.refresh(i)
  23. end
  24. end
  25.  
  26. function init()
  27. for i=1,16 do
  28. table.insert(steps,math.random(8))
  29. end
  30. for i=1,4 do
  31. table.insert(aleds,math.random(64))
  32. end
  33. grid_redraw()
  34. allLeds(1)
  35.  
  36. for i=1,4 do
  37. for j=1,64 do
  38. -- ar.led(i, j, 5)
  39. end
  40. end
  41.  
  42. --ar.refresh(1)
  43. --ar.refresh(2)
  44. --ar.refresh(3)
  45. --ar.refresh(4)
  46.  
  47. allRefresh()
  48.  
  49. end
  50.  
  51. function ar.event(n, z, typ)
  52. --aleds[n] = math.random(64)
  53. --print (n)
  54. --print (z)
  55. --print (typ)
  56. ar.all(n, 1)
  57. for i=2,64 do
  58. ar.led(n, i, math.floor(i/4))
  59. end
  60.  
  61. arc_redraw(n)
  62. end
  63.  
  64. function arc_redraw(n)
  65. ar.refresh(n)
  66. end
  67.  
  68. function g.event(x, y, z)
  69. if z == 1 then
  70. steps[x] = y
  71. grid_redraw()
  72. end
  73. end
  74.  
  75. function grid_redraw()
  76. g.all(0)
  77. for i=1,16 do
  78. if i==position then intensity = 15 else intensity = 4 end
  79. --print (intensity)
  80. g.led(i,steps[i],intensity)
  81. end
  82. g.refresh()
  83. end
Add Comment
Please, Sign In to add comment