/// <summary> /// Force the sensor to make a reading and update the relevant properties. /// </summary> public void Update() { _hih6130.WriteByte(0); // // Sensor takes 35ms to make a valid reading. // Thread.Sleep(40); var data = _hih6130.ReadBytes(4); // // Data format: // // Byte 0: S1 S0 H13 H12 H11 H10 H9 H8 // Byte 1: H7 H6 H5 H4 H3 H2 H1 H0 // Byte 2: T13 T12 T11 T10 T9 T8 T7 T6 // Byte 4: T5 T4 T3 T2 T1 T0 XX XX // if ((data[0] & 0xc0) != 0) { throw new Exception("Status indicates readings are invalid."); } var reading = ((data[0] << 8) | data[1]) & 0x3fff; Humidity = ((float)reading / 16383) * 100; reading = ((data[2] << 8) | data[3]) >> 2; Temperature = (((float)reading / 16383) * 165) - 40; }
/// <summary> /// Clear the interrupt flag. /// Se Command Register on page 13 of the datasheet. /// </summary> /// <remarks> /// According to the datasheet, writing a 1 into bit 6 of the command /// register will clear any pending interrupts. /// </remarks> public void ClearInterrupt() { _tsl2561.WriteByte(ClearInterruptBit); if (_interruptPin != null) { _interruptPin.ClearInterrupt(); } }
/// <summary> /// Clear the interrupt flag. /// Se Command Register on page 13 of the datasheet. /// </summary> /// <remarks> /// According to the datasheet, writing a 1 into bit 6 of the command /// register will clear any pending interrupts. /// </remarks> public void ClearInterrupt() { _tsl2561.WriteByte(ClearInterruptBit); if (_interruptPin != null) { //Port: TODO - check if needed _interruptPin.ClearInterrupt(); } }
void InitHT16K33() { // SetIsAwake(true); // SetDisplayOn(true); // SetBlinkRate(BlinkRate.Off); _I2CBus.WriteByte(0x21); _I2CBus.WriteByte(0x81); SetBrightness(Brightness.Maximum); ClearDisplay(); }