CyrusBuilt.MonoPi.Sensors.DS1620.GetTemperature C# (CSharp) Method

GetTemperature() public method

Sends the commands to get the temperature from the sensor.
/// This instance has been disposed and is no longer usable. ///
public GetTemperature ( ) : Double
return Double
		public Double GetTemperature() {
			if (this._isDisposed) {
				throw new ObjectDisposedException("CyrusBuilt.MonoPi.Sensors.DS1620");
			}

			this._reset.Write(PinState.Low);
			this._clock.Write(PinState.High);
			this._reset.Write(PinState.High);
			this.SendCommand(0x0c);    // write config command.
			this.SendCommand(0x02);    // cpu mode.
			this._reset.Write(PinState.Low);

			Thread.Sleep(200);         // wait until the configuration register is written.
			this._clock.Write(PinState.High);
			this._reset.Write(PinState.High);
			this.SendCommand(0xEE);    // start conversion.
			this._reset.Write(PinState.Low);

			Thread.Sleep(200);
			this._clock.Write(PinState.High);
			this._reset.Write(PinState.High);
			this.SendCommand(0xAA);
			Int32 raw = this.ReadData();
			this._reset.Write(PinState.Low);
			return ((Double)raw / 2.0);
		}