Peter Recktenwald: Hacks für die Digitale Fotografie — 2014/10/2 — page 355 — le-tex
public class RPiCameraTrap {
public static String GetActDate() {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
// Get the date today using Calendar object.
Date today = Calendar.getInstance().getTime();
// Using DateFormat format method we can create a string
// representation of a date with the dened format.
String reportDate = df.format(today);
return reportDate;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws InterruptedException {
// TODO code application logic here
Camera piCam = new Camera();
// create gpio controller
nal GpioController gpio = GpioFactory.getInstance();
// provision gpio pin #00 as an input pin with its internal pull
// up resistor enabled
nal GpioPinDigitalInput myButton
= gpio.provisionDigitalInputPin(RaspiPin.GPIO_00, PinPullResistance.PULL_UP);
// create and register gpio pin listener
myButton.addListener(new GpioPinListenerDigital() {
@Override
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalState
ChangeEvent event){
// display pin state on console
System.out.println(" --> GPIO PIN STATE CHANGE: "
+ event.getPin()
+ "="+ event.getState());
piCam.takePicture("pic" + GetActDate());
}
});
System.out.println(" ... complete the GPIO #00 circuit and see the
listener feedback here in the console.");
// keep program running until user aborts (CTRL-C)
for (;;) {
Thread.sleep(500);
}
}
}
KAPITEL 6: RASPBERRY PI-HACKS FÜR DIE DIGITA LE FOTOGRAFIE 355
Comentários a estes Manuais