first commit
This commit is contained in:
commit
a5a0434432
1126 changed files with 439481 additions and 0 deletions
9
Software/Java/test/Test.java
Normal file
9
Software/Java/test/Test.java
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/* Run: Java$ ./bin/compile.sh && ./bin/Test.sh */
|
||||
import java.io.IOException;
|
||||
import tests.*;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) throws IOException, InterruptedException, Exception {
|
||||
BaseTest grovepiTest = new BaseTest();
|
||||
}
|
||||
}
|
||||
60
Software/Java/test/tests/BaseTest.java
Normal file
60
Software/Java/test/tests/BaseTest.java
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
package tests;
|
||||
|
||||
import com.dexterind.grovepi.*;
|
||||
import com.dexterind.grovepi.sensors.base.*;
|
||||
import com.dexterind.grovepi.sensors.*;
|
||||
import com.dexterind.grovepi.events.*;
|
||||
import com.dexterind.grovepi.utils.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BaseTest implements GrovepiListener {
|
||||
private static Grovepi grovepi = null;
|
||||
|
||||
public BaseTest() throws IOException, InterruptedException, Exception {
|
||||
System.out.println("-----------------------------------------------------");
|
||||
System.out.println(" GrovePi test application");
|
||||
System.out.println("----------------------------------------------------");
|
||||
|
||||
grovepi = Grovepi.getInstance();
|
||||
grovepi.addListener(this);
|
||||
grovepi.init();
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent event) {
|
||||
if (event.status == 2) {
|
||||
|
||||
try {
|
||||
System.out.print( grovepi.board.version() );
|
||||
} catch( IOException e) {
|
||||
System.out.print( e.getMessage() );
|
||||
}
|
||||
|
||||
try {
|
||||
System.out.print( "\n" );
|
||||
this.getDHTValue();
|
||||
System.out.print( "\n" );
|
||||
} catch ( Exception e) {
|
||||
System.out.print( "Err:" + e.getMessage() );
|
||||
}
|
||||
}
|
||||
};
|
||||
public void onSensorEvent(SensorEvent event) {
|
||||
System.out.print(event.value);
|
||||
};
|
||||
|
||||
public void getDHTValue() throws IOException, InterruptedException, Exception {
|
||||
int pin = 2; // D2
|
||||
DHTDigitalSensor sensor = new DHTDigitalSensor(
|
||||
pin,
|
||||
DHTDigitalSensor.MODULE_DHT22,
|
||||
DHTDigitalSensor.SCALE_C
|
||||
);
|
||||
float[] output = sensor.read();
|
||||
System.out.print( Arrays.toString(output) );
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue