コード例 #1
0
 private async void HandleTemperatureMeasured(object sender, TemperatureData e)
 {
   if (e.IsValid)
   {
     await _dataPinLed.Flash(_longFlashTime);
     OnTemperatureMeasured?.Invoke(this, e);
   }
   else
   {
     await _errorLed.Flash(_longFlashTime);
   }
 }
コード例 #2
0
 private async void OnTemperatureMeasured(object sender, TemperatureData e)
 {
   Debug.WriteLine($"MainPage.OnTemperatureMeasured {e.Temperature}: {e.IsValid} at {DateTime.Now}");
   if (e.IsValid)
   {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
     {
       var brush = TemperatureText.Foreground;
       TemperatureText.Text = $"{e.Temperature}°C";
       TemperatureText.Foreground = new SolidColorBrush(Colors.Red);
       await Task.Delay(250);
       TemperatureText.Foreground = brush;
     });
   }
 }
コード例 #3
0
 private void ProcessTemperatureData(object sender, 
   TemperatureData temperatureData)
 {
   OnTemperatureDataReceived?.Invoke(this, temperatureData);
 }
コード例 #4
0
 public async void HandleNewTemperature(object sender, TemperatureData data)
 {
   Debug.WriteLine($"New temperature data received {data.Temperature} fanstatus = {data.FanStatus}");
   _lastTemperatureData = data;
   _lastTemperatureData.Timestamp = DateTimeOffset.UtcNow;
   if (_lastFanStatus != _lastTemperatureData.FanStatus && _isProcessing)
   {
     _isProcessing = false;
     _lastFanStatus = _lastTemperatureData.FanStatus;
     await UpdateFirstPageStatus();
   }
   else if (_lastToggleUse.IsSecondsAgo(Settings.FanSwitchQueueTtl) && _isProcessing)
   {
     _isProcessing = false;
     _lastFanStatus = _lastTemperatureData.FanStatus;
     await UpdateFirstPageStatus();
   }
   else if (!_isProcessing)
   {
     _lastFanStatus = _lastTemperatureData.FanStatus;
   }
 }