Created
December 21, 2016 17:43
-
-
Save hpsaturn/18ccf29f4de1ab3e3771324620395133 to your computer and use it in GitHub Desktop.
Google Things parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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