/// <summary> /// Requests a reading from the sensor and updates its data properties with the gathered values. /// </summary> /// <returns>An awaitable Task</returns> /// <remarks> /// Note that when #AutoUpdateWhenPropertyRead is `true` (which it is, by default), this method is implicitly /// called when any sensor data property is read from --- there's no need to call this method unless you set /// AutoUpdateWhenPropertyRead to `false`. /// /// Unless otherwise noted, this method updates all sensor data simultaneously, which can often lead to more efficient /// bus usage (as well as reducing USB chattiness). /// </remarks> public override async Task UpdateAsync() { var data = await dev.ReadWordDataAsync(register).ConfigureAwait(false); data &= 0x7FFF; // chop off the error bit of the high byte celsius = data * 0.02 - 273.15; RaisePropertyChanged(this); }
/// <summary> /// Read the specified channel from this ADC /// </summary> /// <param name="channel">The channel to read</param> /// <returns>An awaitable double value representing the voltage of the ADC</returns> public async Task <double> ReadAsync(Channel channel = Channel.Channel0) { // SendReceive(byte address, byte[] dataToWrite, byte numBytesToRead) int data = await dev.ReadWordDataAsync((byte)((byte)channel | (byte)Ltc2305ConfigBits.UnipolarMode)).ConfigureAwait(false); var retVal = CodeToVoltage(data, 5.0, Ltc2305ConfigBits.UnipolarMode); return(retVal); }