async void Measure()
        {
            try {
                matrix.DrawSymbol(Glovebox.Graphics.Grid.Grid8x8.Symbols.HourGlass);
                matrix.FrameDraw();

                var content = new Message(telemetry.ToJson(bme280.Temperature.DegreesCelsius, hat.AnalogRead(ExplorerHatPro.AnalogPin.Ain2).ReadRatio(), bme280.Pressure.Hectopascals, bme280.Humidity));
                await deviceClient.SendEventAsync(content);

                matrix.FrameClear();
                matrix.FrameDraw();
            }
            catch {
                telemetry.Exceptions++;
                hat.Light(Colour.Red).On();
            }
        }
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            using (ExplorerHatPro hat = new ExplorerHatPro(ADS1015.Gain.Volt5))
                using (BMP280 bmp280 = new BMP280(0x76)) {
                    while (true)
                    {
                        Debug.WriteLine($"Temperature {bmp280.Temperature.DegreesCelsius}C, Pressure {bmp280.Pressure.Hectopascals}, Light ratio {hat.AnalogRead(AnalogPin.Ain2).ReadRatio()} ");

                        for (int l = 0; l < hat.ColourCount; l++)
                        {
                            hat.Light((Colour)l).On();
                            Task.Delay(20).Wait();
                        }

                        for (int l = 0; l < hat.ColourCount; l++)
                        {
                            hat.Light((Colour)l).Off();
                            Task.Delay(20).Wait();
                        }
                    }
                }
        }
Ejemplo n.º 3
0
 async void Measure()
 {
     try {
         var content = new Message(telemetry.ToJson(bme280.Temperature.DegreesCelsius, hat.AnalogRead(AnalogPin.Ain2).ReadRatio(), bme280.Pressure.Hectopascals, bme280.Humidity));
         await deviceClient.SendEventAsync(content);
     }
     catch {
         telemetry.Exceptions++;
         hat.Light(ExplorerHatPro.Colour.Red).On();
     }
 }