webcam works
This commit is contained in:
parent
5f0a62d9bf
commit
8edc1224bb
4 changed files with 147 additions and 67 deletions
|
|
@ -25,6 +25,20 @@ class Camera {
|
|||
}
|
||||
}
|
||||
|
||||
boolean updateImage() {
|
||||
boolean newImageAvailable = cam.available();
|
||||
|
||||
if (newImageAvailable) {
|
||||
cam.read();
|
||||
}
|
||||
|
||||
return newImageAvailable;
|
||||
}
|
||||
|
||||
Capture getCam() {
|
||||
return cam;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class EuglenaApplet extends PApplet {
|
|||
|
||||
@Override
|
||||
public void settings() {
|
||||
size(1000, 1000, P2D);
|
||||
size(1920, 1200, P2D);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -26,22 +26,23 @@ public class EuglenaApplet extends PApplet {
|
|||
clear();
|
||||
smooth();
|
||||
|
||||
// Start up projectorApplet window
|
||||
projectorApplet = new ProjectorApplet();
|
||||
String[] args = {"Euglena projector"};
|
||||
PApplet.runSketch(args, projectorApplet);
|
||||
|
||||
camera = new Camera(this, cameraMode);
|
||||
ledControl = new LEDControl(this, whichArduino);
|
||||
|
||||
menu = new Menu(this);
|
||||
|
||||
// Start up projectorApplet window
|
||||
// Do this last, in case ProjectorApplet wants to use the camera, arduino, etc.
|
||||
projectorApplet = new ProjectorApplet();
|
||||
String[] args = {"Euglena projector"};
|
||||
PApplet.runSketch(args, projectorApplet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
clear();
|
||||
fill(255);
|
||||
rect(50, 50, 100, 100);
|
||||
camera.updateImage();
|
||||
imageMode(PApplet.CORNER);
|
||||
image(camera.getCam(), 0, 0, width - menu.width, height);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ class LEDControl {
|
|||
}
|
||||
PApplet.print("Using arduino ");
|
||||
PApplet.println(arduinos[whichArduino]);
|
||||
|
||||
this.arduino = new Arduino(applet, arduinos[whichArduino], comRate);
|
||||
|
||||
this.arduino.pinMode(Direction.LEFT.pin, Arduino.OUTPUT);
|
||||
this.arduino.pinMode(Direction.RIGHT.pin, Arduino.OUTPUT);
|
||||
this.arduino.pinMode(Direction.UP.pin, Arduino.OUTPUT);
|
||||
this.arduino.pinMode(Direction.DOWN.pin, Arduino.OUTPUT);
|
||||
for (Direction dir : Direction.values()) {
|
||||
this.arduino.pinMode(dir.pin, Arduino.OUTPUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +51,19 @@ class LEDControl {
|
|||
}
|
||||
}
|
||||
|
||||
public void allOn() {
|
||||
for (Direction dir : Direction.values()) {
|
||||
turnOn(dir);
|
||||
}
|
||||
}
|
||||
|
||||
public void allOff() {
|
||||
for (Direction dir : Direction.values()) {
|
||||
turnOff(dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum Direction {
|
||||
LEFT (0, 10),
|
||||
RIGHT (1, 5),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue