public bool Equals(DestinyHistoricalStatsValue input) { if (input == null) { return(false); } return (( StatId == input.StatId || (StatId != null && StatId.Equals(input.StatId)) ) && ( Basic == input.Basic || (Basic != null && Basic.Equals(input.Basic)) ) && ( Pga == input.Pga || (Pga != null && Pga.Equals(input.Pga)) ) && ( Weighted == input.Weighted || (Weighted != null && Weighted.Equals(input.Weighted)) ) && ( ActivityId == input.ActivityId || (ActivityId.Equals(input.ActivityId)) )); }
public void Update(DestinyHistoricalStatsValue?other) { if (other is null) { return; } if (StatId != other.StatId) { StatId = other.StatId; OnPropertyChanged(nameof(StatId)); } if (!Basic.DeepEquals(other.Basic)) { Basic.Update(other.Basic); OnPropertyChanged(nameof(Basic)); } if (!Pga.DeepEquals(other.Pga)) { Pga.Update(other.Pga); OnPropertyChanged(nameof(Pga)); } if (!Weighted.DeepEquals(other.Weighted)) { Weighted.Update(other.Weighted); OnPropertyChanged(nameof(Weighted)); } if (ActivityId != other.ActivityId) { ActivityId = other.ActivityId; OnPropertyChanged(nameof(ActivityId)); } }
/// <summary> /// アナログ値(バイナリ)を取得する。 /// </summary> /// <param name="mux">入力マルチプレクサ</param> /// <param name="dataRate">データーレート</param> /// <param name="pga">ゲイン</param> /// <returns>アナログ値(バイナリ)</returns> public int ReadRaw(Mux mux, DataRate dataRate = DataRate.Sps128, Pga pga = Pga.Fs2048mV) { ReadOnlySpan <byte> config = stackalloc byte[] { (byte)Register.Config, (byte)(((byte)SingleShotCoversion.Begin << 7) | ((byte)mux << 4) | ((byte)pga << 1) | (byte)Mode.PowerDownSingleShot), (byte)(((byte)dataRate << 5) | (byte)ComparatorQueue.Disable) }; Write(config); ReadOnlySpan <byte> conversion = stackalloc byte[] { (byte)Register.Conversion }; WriteEx(I2cMasterFlags.Start, conversion); switch (dataRate) { case DataRate.Sps8: Thread.Sleep(126); break; case DataRate.Sps16: Thread.Sleep(64); break; case DataRate.Sps32: Thread.Sleep(33); break; case DataRate.Sps64: Thread.Sleep(17); break; case DataRate.Sps128: Thread.Sleep(9); break; case DataRate.Sps250: Thread.Sleep(5); break; case DataRate.Sps475: Thread.Sleep(4); break; case DataRate.Sps860: Thread.Sleep(3); break; default: throw new ArgumentOutOfRangeException(nameof(dataRate)); } Span <byte> readBuffer = stackalloc byte[2]; ReadEx(I2cMasterFlags.RepeatedStart | I2cMasterFlags.Stop, readBuffer); return((short)((readBuffer[0] << 8) | readBuffer[1])); } } }
public bool DeepEquals(DestinyHistoricalStatsValue?other) { return(other is not null && StatId == other.StatId && (Basic is not null ? Basic.DeepEquals(other.Basic) : other.Basic is null) && (Pga is not null ? Pga.DeepEquals(other.Pga) : other.Pga is null) && (Weighted is not null ? Weighted.DeepEquals(other.Weighted) : other.Weighted is null) && ActivityId == other.ActivityId); }
/// <inheritdoc/> public int ReadRaw(int channel, DataRate dataRate = DataRate.Sps128, Pga pga = Pga.Fs10035mV) { if (!IsInitialized) { Initialize(); } byte extMux; Ads1115Slave.Mux adcMux; if (channel < 16) { extMux = (byte)((_mux & 0xf0) | channel); adcMux = Ads1115Slave.Mux.Ain0Gnd; } else if (channel < 32) { extMux = (byte)((_mux & 0x0f) | ((channel & 0x0f) << 4)); adcMux = Ads1115Slave.Mux.Ain1Gnd; } else if (channel < 48) { extMux = (byte)((_mux & 0xf0) | channel); adcMux = Ads1115Slave.Mux.Ain0Ain3; } else if (channel < 64) { extMux = (byte)((_mux & 0x0f) | ((channel & 0x0f) << 4)); adcMux = Ads1115Slave.Mux.Ain1Ain3; } else if (channel < 256) { throw new ArgumentOutOfRangeException(nameof(channel)); } else { extMux = (byte)(channel & 0xff); adcMux = Ads1115Slave.Mux.Ain0Ain1; } _pca9554.WritePort(extMux); _mux = extMux; Thread.Sleep(1); return(_ads1115.ReadRaw(adcMux, (Ads1115Slave.DataRate)dataRate, (Ads1115Slave.Pga)pga)); }
private static double ToVolt(int value, Pga pga) { switch (pga) { case Pga.Fs1254mV: return(1.2544F * value / 32767); case Pga.Fs2509mV: return(2.5088F * value / 32767); case Pga.Fs5018mV: return(5.0176F * value / 32767); case Pga.Fs10035mV: return(10.0352F * value / 32767); default: return(0); } }
/// <inheritdoc/> public List <double> ReadVoltage(int startChannel, int numOfChannels, DataRate dataRate = DataRate.Sps128, Pga pga = Pga.Fs10035mV) { return(ReadRaw(startChannel, numOfChannels, dataRate, pga).Select(x => ToVolt(x, pga)).ToList()); }
/// <inheritdoc/> public List <int> ReadRaw(int startChannel, int numOfChannels, DataRate dataRate = DataRate.Sps128, Pga pga = Pga.Fs10035mV) { var values = new List <int>(); for (var ch = startChannel; ch < startChannel + numOfChannels; ch++) { var tmp = ReadRaw(ch, dataRate, pga); values.Add(tmp); } return(values); }