Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.thelastdaytosurvive.game;
- import org.usb4java.Device;
- import com.badlogic.gdx.utils.TimeUtils;
- import com.thelastdaytosurvive.game.McuWithPeriBoard;
- public class PracticumController
- {
- int count = 0;
- long lastLEDTime = TimeUtils.millis();
- long refreshRate = 500;
- McuWithPeriBoard peri;
- public PracticumController(){
- System.out.println("Test");
- McuBoard.initUsb();
- try
- {
- Device[] devices = McuBoard.findBoards();
- if (devices.length == 0) {
- System.out.format("** Practicum board not found **\n");
- return;
- }
- else {
- System.out.format("** Found %d practicum board(s) **\n", devices.length);
- }
- peri = new McuWithPeriBoard(devices[0]);
- System.out.format("** Practicum board found **\n");
- System.out.format("** Manufacturer: %s\n", peri.getManufacturer());
- System.out.format("** Product: %s\n", peri.getProduct());
- }
- catch (Exception e)
- {
- System.out.println(e);
- }
- }
- public void update(){
- if(TimeUtils.millis() - lastLEDTime > refreshRate)
- {
- lastLEDTime = TimeUtils.millis();
- peri.setLedValue(count);
- boolean sw = peri.getSwitch();
- int light = peri.getLight();
- System.out.format("LED set to %d | Switch state: %s | Light: %d\n",
- count, sw, light);
- count++;
- if (count > 7) count = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement