Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. package com.thelastdaytosurvive.game;
  2. import org.usb4java.Device;
  3. import com.badlogic.gdx.utils.TimeUtils;
  4. import com.thelastdaytosurvive.game.McuWithPeriBoard;
  5.  
  6. public class PracticumController
  7. {
  8. int count = 0;
  9. long lastLEDTime = TimeUtils.millis();
  10. long refreshRate = 500;
  11. McuWithPeriBoard peri;
  12.  
  13. public PracticumController(){
  14. System.out.println("Test");
  15. McuBoard.initUsb();
  16. try
  17. {
  18. Device[] devices = McuBoard.findBoards();
  19.  
  20. if (devices.length == 0) {
  21. System.out.format("** Practicum board not found **\n");
  22. return;
  23. }
  24. else {
  25. System.out.format("** Found %d practicum board(s) **\n", devices.length);
  26. }
  27. peri = new McuWithPeriBoard(devices[0]);
  28.  
  29. System.out.format("** Practicum board found **\n");
  30. System.out.format("** Manufacturer: %s\n", peri.getManufacturer());
  31. System.out.format("** Product: %s\n", peri.getProduct());
  32. }
  33. catch (Exception e)
  34. {
  35. System.out.println(e);
  36. }
  37. }
  38.  
  39. public void update(){
  40. if(TimeUtils.millis() - lastLEDTime > refreshRate)
  41. {
  42. lastLEDTime = TimeUtils.millis();
  43. peri.setLedValue(count);
  44. boolean sw = peri.getSwitch();
  45. int light = peri.getLight();
  46. System.out.format("LED set to %d | Switch state: %s | Light: %d\n",
  47. count, sw, light);
  48. count++;
  49. if (count > 7) count = 0;
  50. }
  51.  
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement