Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Lots of changes

  • Loading branch information...
commit a1eb61d57014ea44dc11eef29404a4252fa0d84e 1 parent 31009b1
Jonas Jongejan HalfdanJ authored
68 client/client.pde
View
@@ -1,35 +1,75 @@
String[] fontList;
PFont androidFont;
+float left=0;
+int right=0;
+boolean leftRev=false;
+boolean rightRev=false;
+
void setup() {
size(screenWidth, screenHeight);
background(0);
fontList = PFont.list();
androidFont = createFont(fontList[5], 35, true);
textFont(androidFont);
+
+ setupOsc();
+}
+
+boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (keyCode == 23) {//X
+ left = 255;
+ right = 255;
+ leftRev = false;
+ rightRev = false;
+ }
+ if (keyCode == 99) {//square
+ left = 255;
+ right = 255;
+ leftRev = true;
+ rightRev = true;
+ }
+ return true;
+}
+
+boolean onKeyUp(int keyCode, KeyEvent event) {
+ if (keyCode == 23) {//X
+ left = 0;
+ right = 0;
+ }
+ if (keyCode == 99) {//square
+ left = 0;
+ right = 0;
+ leftRev = false;
+ rightRev = false;
+ }
+ return true;
}
void draw() {
+
+ updateOsc();
+
background(0);
// Display current GPS data
text("Latitude: "+currentLatitude, 20, 40);
text("Longitude: "+currentLongitude, 20, 75);
text("Accuracy: "+currentAccuracy, 20, 110);
- text("Provider: "+currentProvider, 20, 145);
-}
+ text("Provider: "+currentProvider, 20, 145);
-//-----------------------------------------------------------------------------------------
+ fill(70, 100, 100);
+ stroke(255, 255, 255);
+ rect(screenWidth/2.0-100, screenHeight/2.0-100, 200, 200);
-void onResume() {
- super.onResume();
- // Build Listener
- locationListener = new MyLocationListener();
- // Acquire a reference to the system Location Manager
- locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
- // Register the listener with the Location Manager to receive location updates
- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
-}
+ fill(80, 255, 80);
+ if (leftRev)
+ fill(255, 0, 0);
+
+ arc(screenWidth/2.0-70, screenHeight/2.0+100, 50, 50, 0-HALF_PI, TWO_PI*left/255.0-HALF_PI);
-void onPause() {
- super.onPause();
+ fill(80, 255, 80);
+ if (rightRev)
+ fill(255, 0, 0);
+ arc(screenWidth/2.0+70, screenHeight/2.0+100, 50, 50, 0-HALF_PI, TWO_PI*right/255.0-HALF_PI);
}
+
14 client/gps.pde
View
@@ -21,7 +21,21 @@ String currentProvider = "";
//-----------------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------------
+
+void onResume() {
+ super.onResume();
+ // Build Listener
+ locationListener = new MyLocationListener();
+ // Acquire a reference to the system Location Manager
+ locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
+ // Register the listener with the Location Manager to receive location updates
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
+}
+void onPause() {
+ super.onPause();
+}
//-----------------------------------------------------------------------------------------
25 client/osc.pde
View
@@ -0,0 +1,25 @@
+import oscP5.*;
+//import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setupOsc() {
+ oscP5 = new OscP5(this, 12000);
+ //Connect server
+ myRemoteLocation = new NetAddress("172.20.10.4", 12000);
+}
+
+
+void updateOsc() {
+ OscMessage myMessage = new OscMessage("/ufo/motorSet");
+ myMessage.add(100);
+ myMessage.add(120);
+ myMessage.add(1);
+ myMessage.add(0);
+ oscP5.send(myMessage, myRemoteLocation);
+}
+
+void oscEvent(OscMessage theOscMessage) {
+}
+
2  server/arduino.pde
View
@@ -38,7 +38,7 @@ void updateArduino(){
(byte) left
,(byte) right
,(byte) (leftRev?100:0)
- ,(byte) (rightRev?100:0)
+ ,(byte) (rightRev?0:100)
}
);
}
BIN  server/code/oscP5.jar
View
Binary file not shown
25 server/osc.pde
View
@@ -0,0 +1,25 @@
+import oscP5.*;
+//import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setupOsc() {
+ oscP5 = new OscP5(this, 12000);
+ myRemoteLocation = new NetAddress("127.0.0.1", 12000);
+}
+
+void updateOsc() {
+
+}
+
+void oscEvent(OscMessage theOscMessage) {
+ left = 100;
+ if (theOscMessage.checkAddrPattern("/ufo/motorSet")) {
+ left = theOscMessage.get(0).intValue();
+ right = theOscMessage.get(1).intValue();
+ leftRev = (theOscMessage.get(2).intValue() > 0)?true:false;
+ rightRev = (theOscMessage.get(3).intValue() > 0)?true:false;
+ }
+}
+
4 server/server.pde
View
@@ -17,7 +17,8 @@ void setup()
frameRate(30);
setupArduino();
-
+ setupOsc();
+
fontList = PFont.list();
androidFont = createFont(fontList[5], 35, true);
textFont(androidFont);
@@ -27,6 +28,7 @@ void setup()
void draw()
{
+ updateOsc();
if (mousePressed) {
if (!mouseDown) {
mouseGuiElement = -1;
Please sign in to comment.
Something went wrong with that request. Please try again.