Last active
August 29, 2015 14:26
-
-
Save justinplatz/0b2aed28e08b033be9ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LeapToServo implements Runnable{ | |
| //Define Channel name | |
| public static final String CHANNEL = "my_channel"; | |
| //Create PubNub instance | |
| private Pubnub pubnub; | |
| //Create Leap Controller instance | |
| private Controller controller; | |
| //is Runnable running? | |
| private boolean running; | |
| //Last value of Left Yaw | |
| int oldLeftYaw = 0; | |
| //Last value of Left Pitch | |
| int oldLeftPitch = 0; | |
| //Last value of Right Yaw | |
| int oldRightYaw = 0; | |
| //Last value of Right Pitch | |
| int oldRightPitch = 0; | |
| //Takes in Pubkey and Subkey and sets up PubNub Configuration | |
| public LeapToServo(String pubKey, String subKey){ | |
| pubnub = new Pubnub(pubKey, subKey); | |
| pubnub.setUUID("LeapController"); | |
| } | |
| /** | |
| * Implementation of the Runnable interface. | |
| */ | |
| public void run(){ | |
| for(;;) { | |
| if (!running) break; | |
| captureFrame(this.controller); | |
| try { | |
| Thread.sleep(50); | |
| } catch (InterruptedException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } | |
| public static void main(String[] args) { | |
| String pubKey = "demo"; | |
| String subKey = "demo"; | |
| LeapToServo s = new LeapToServo(pubKey, subKey); | |
| s.startTracking(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment