xavierlebel

touch

Mar 4th, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. --# load the Touchpoint API
  2. os.loadAPI("touchpoint")
  3. p = peripheral.wrap("back")
  4.  
  5. --# FUNCTIONS
  6.  
  7. function peat()
  8. p.setFreq(151)
  9. end
  10.  
  11. function peat2()
  12. p.setFreq(222)
  13. end
  14.  
  15. --# intialize a new button set on the top monitor
  16. local t = touchpoint.new("top")
  17.  
  18. --# add buttons
  19. t:add("label", nil, 2, 2, 14, 11, colors.red, colors.lime)
  20. t:add("Power", nil, 16, 2, 28, 11, colors.lime, colors.red)
  21.  
  22. --# draw the buttons
  23. t:draw()
  24.  
  25. while true do
  26. local event, p1 = t:handleEvents(os.pullEvent())
  27. if event == "button_click" then
  28. t:toggleButton(p1)
  29.  
  30. if p1 == "label" then
  31. peat()
  32. else
  33. peat2()
  34. end
  35. end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment