Skip to content

Instantly share code, notes, and snippets.

@hpsaturn
Created December 21, 2016 17:43
Show Gist options
  • Save hpsaturn/18ccf29f4de1ab3e3771324620395133 to your computer and use it in GitHub Desktop.
Save hpsaturn/18ccf29f4de1ab3e3771324620395133 to your computer and use it in GitHub Desktop.
Google Things parser
public class Pressure extends SensorBase {
private static final String TAG = Pressure.class.getSimpleName();
private static final boolean DEBUG = Config.DEBUG;
private float altitude;
private float pressure;
private float temperature;
public Pressure(Wishbone wb) {
super(wb);
}
public void read (){
byte[] data = new byte[12];
wb.SpiRead((short) (kMCUBaseAddress+(kMemoryOffsetPressure >> 1)),data,12);
this.altitude=ByteBuffer.wrap(data,0,4).order(ByteOrder.LITTLE_ENDIAN).getFloat();
this.pressure=ByteBuffer.wrap(data,4,4).order(ByteOrder.LITTLE_ENDIAN).getFloat();
this.temperature=ByteBuffer.wrap(data,8,4).order(ByteOrder.LITTLE_ENDIAN).getFloat();
}
public float getAltitude() {
return altitude;
}
public float getPressure() {
return pressure;
}
public float getTemperature() {
return temperature;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment