public void setPower(boolean on) { device.writeBit(CONFIG_REG, POWER_DOWN_BIT, !on); // TODO Wait for the specified maximum conversion time }
/** * write a single bit in an 8-bit device register * * @param regAddr * Register regAddr to write to * @param bitNum * Bit position to write (0-7) * @param value * New bit value to write * @throws RuntimeIOException * if an I/O error occurs */ public void writeBit(int regAddr, int bitNum, int value) throws RuntimeIOException { // bool I2Cdev::writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t // bitNum, uint8_t data) writeBit(regAddr, bitNum, value != 0); }
public float oneShotRead() { // Assumes the device is powered down device.writeBit(CONFIG_REG, ONE_SHOT_BIT, true); while (! isDataAvailable()) { // TODO Wait the required number of ms with a timeout } return getTemperature(); }