private void GetReading(bool flame, DateTime t) { DispatcherHelper.CheckBeginInvokeOnUI(async() => { ADS1115SensorData x = await _adc.readSingleShot(_settingFlameSensor); ReadingTime = t; FlameLevel = x.VoltageValue; //the higher the voltage returned the less flame is detected so we invert this to give it a more flame, higher reading like most people would expect. if (flame) { FlameStatus = "Flame On"; } else { FlameStatus = "Flame Off"; } Reading reading = new Reading { ReadingDateTime = t, FlameOn = (flame) ? 1 : 0, FlameLevel = FlameLevel }; while (ChartData.Count > 60) { ChartData.RemoveAt(0); } ChartData.Add(reading); }); }
private async void bt_convert_Click(object sender, RoutedEventArgs e) { if (Setting.Mode == AdcMode.CONTINOUS_CONVERSION) { if (adc != null && adc.IsInitialized) { try { await adc.readContinuousInit(Setting); } catch (Exception ex) { throw new Exception("Initialization of continuous read has failed" + ex); } timer.Start(); } } else { timer.Stop(); if (adc != null && adc.IsInitialized) { try { var temp = await adc.readSingleShot(Setting); ConvertedValue = temp.DecimalValue; ConvertedVoltage = temp.VoltageValue; } catch (Exception ex) { throw new Exception("Read from ADS1115 has failed: " + ex); } } } }