/// <summary> /// Initializes the hardware. /// </summary> void Initialize() { var rgbLed = new RgbLed( Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue ); rgbLed.SetColor(RgbLed.Colors.Red); Console.WriteLine("Initialize hardware..."); // Analog Temp Sensor Console.WriteLine("Initializing analog temp sensor"); analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); // display this.displayController = new DisplayController(); // WiFi adapter Console.WriteLine("Initializaing wifi adapter."); Device.InitWiFiAdapter().Wait(); rgbLed.SetColor(RgbLed.Colors.Green); }
void Initialize() { onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); onboardLed.StartPulse(Color.Red); analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); displayController = new WeatherView(); Device.InitWiFiAdapter().Wait(); onboardLed.StartPulse(Color.Blue); var result = Device.WiFiAdapter.Connect(Secrets.WIFI_NAME, Secrets.WIFI_PASSWORD); if (result.ConnectionStatus != ConnectionStatus.Success) { throw new Exception($"Cannot connect to network: {result.ConnectionStatus}"); } onboardLed.StartPulse(Color.Green); }
public MeadowApp() { Console.WriteLine("Initializing..."); this.analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); this.analogTemperature.Updated += AnalogTemperatureUpdated; var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3); this.st7789 = new St7789( device: Device, spiBus: Device.CreateSpiBus( Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config), chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); this.displayWidth = Convert.ToInt32(this.st7789.Width); this.displayHeight = Convert.ToInt32(this.st7789.Height); this.graphics = new GraphicsLibrary(this.st7789); this.graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; this.LoadScreen(); this.analogTemperature.StartUpdating(); this.unitsTimer.AutoReset = true; this.unitsTimer.Elapsed += UnitsTimer_Elapsed; this.unitsTimer.Start(); }
public MeadowApp() { Console.WriteLine("Initializing..."); // configure our AnalogTemperature sensor analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); // Example that uses an IObersvable subscription to only be notified // when the temperature changes by at least a degree. analogTemperature.Subscribe(new FilterableObserver <AtmosphericConditionChangeResult, AtmosphericConditions>( h => { Console.WriteLine($"Temp changed by a degree; new: {h.New.Temperature}, old: {h.Old.Temperature}"); }, e => { return(Math.Abs(e.Delta.Temperature) > 1); } )); // classical .NET events can also be used: analogTemperature.Updated += (object sender, AtmosphericConditionChangeResult e) => { Console.WriteLine($"Temp Changed, temp: {e.New.Temperature}°C"); }; // Get an initial reading. ReadTemp().Wait(); // Spin up the sampling thread so that events are raised and // IObservable notifications are sent. analogTemperature.StartUpdating(); }
public void Initialize() { analogTemperature = new AnalogTemperature(MeadowApp.Device, MeadowApp.Device.Pins.A01, AnalogTemperature.KnownSensorType.LM35); analogTemperature.StartUpdating(TimeSpan.FromSeconds(30)); analogTemperature.TemperatureUpdated += AnalogTemperatureUpdated; }
protected void InitializeTempReader() { Temperature = new AnalogTemperature( device: MeadowApp.Device, analogPin: MeadowApp.Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35); }
async Task Initialize() { RgbPwmLed onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); onboardLed.StartPulse(Color.Red); display = new Max7219( device: Device, spiBus: Device.CreateSpiBus(), csPin: Device.Pins.D01, deviceCount: 4, maxMode: Max7219.Max7219Type.Display); graphics = new GraphicsLibrary(display); graphics.CurrentFont = new Font4x8(); graphics.Rotation = GraphicsLibrary.RotationType._180Degrees; graphics.Clear(); graphics.DrawText(0, 1, "WI"); graphics.DrawText(0, 9, "FI"); graphics.DrawText(0, 17, "TI"); graphics.DrawText(0, 25, "ME"); graphics.Show(); pushButton = new PushButton(Device, Device.Pins.D04, ResistorMode.InternalPullUp); pushButton.Clicked += PushButtonClicked; analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); Device.InitWiFiAdapter().Wait(); onboardLed.StartPulse(Color.Blue); var result = await Device.WiFiAdapter.Connect(Secrets.WIFI_NAME, Secrets.WIFI_PASSWORD); if (result.ConnectionStatus != ConnectionStatus.Success) { onboardLed.StartPulse(Color.Magenta); throw new Exception($"Cannot connect to network: {result.ConnectionStatus}"); } onboardLed.StartPulse(Color.Green); }
public void ConfigurePorts() { temperatureSensor = new AnalogTemperature( Device, Device.Pins.A00, AnalogTemperature.KnownSensorType.LM35 ); // subscribe to 1/4º C changes in temp temperatureSensor.Subscribe(new FilterableChangeObserver <AtmosphericConditionChangeResult, AtmosphericConditions>( h => { // probably update screen or something Console.WriteLine($"Current Temp: {h.New.Temperature}ºC"); } /*, * e => { return (Math.Abs(e.Delta.Temperature) > 0.25f); }*/)); }
void Initialize() { Console.WriteLine("Initialize hardware..."); Console.WriteLine("Onboard LED"); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); // configure our BME280 on the I2C Bus Console.WriteLine("BME280"); var i2c = Device.CreateI2cBus(); bme280 = new Bme280( i2c, Bme280.I2cAddress.Adddress0x76 ); // configure our AnalogTemperature sensor Console.WriteLine("Analog Temp"); anlgTemp = new AnalogTemperature( device: Device, analogPin: Device.Pins.A02, sensorType: AnalogTemperature.KnownSensorType.TMP35 ); //a02 = Device.CreateAnalogInputPort(Device.Pins.A02); Console.WriteLine("Relays"); relays[0] = new Relay(Device, Device.Pins.D04); // Fan relays[1] = new Relay(Device, Device.Pins.D09); // Heat 1 relays[2] = new Relay(Device, Device.Pins.D10); // Heat 2 relays[3] = new Relay(Device, Device.Pins.D06); // Cool 1 relays[4] = new Relay(Device, Device.Pins.D05); // Cool 2 Console.WriteLine("Display"); var config = new SpiClockConfiguration(48000, SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); display = new St7789( device: Device, spiBus: spiBus, chipSelectPin: null, dcPin: Device.Pins.D00, resetPin: Device.Pins.D02, width: 240, height: 240); canvas = new GraphicsLibrary(display); }
public TemperatureController(SoftPwm heatLampRelay, AnalogTemperature tempSensor) { // store references to the peripherals _heatLampRelay = heatLampRelay; _tempSensor = tempSensor; // configure our PID controller _pidController = new StandardPidController(); _pidController.ProportionalComponent = .5f; // proportional _pidController.IntegralComponent = .55f; // integral time minutes _pidController.DerivativeComponent = 0f; // derivative time in minutes _pidController.OutputMin = 0.0f; // 0% power minimum _pidController.OutputMax = 1.0f; // 100% power max _pidController.OutputTuningInformation = true; }
public DehydratorController(AnalogTemperature tempSensor, SoftPwm heater, Relay fan, ITextDisplay display) { _tempSensor = tempSensor; _heaterRelayPwm = heater; _fanRelay = fan; _display = display; _pidController = new StandardPidController(); _pidController.ProportionalComponent = .5f; // proportional _pidController.IntegralComponent = .55f; // integral time minutes _pidController.DerivativeComponent = 0f; // derivative time in minutes _pidController.OutputMin = 0.0f; // 0% power minimum _pidController.OutputMax = 1.0f; // 100% power max _pidController.OutputTuningInformation = false; }
private static AnalogTemperature InitializeAnalogTemperatureSensor(EventHandler <AtmosphericConditionChangeResult> updatedHandler) { Console.WriteLine("Initializing analog temperature sensor..."); AnalogTemperature analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); analogTemperature.Updated += updatedHandler; analogTemperature.StartUpdating(); return(analogTemperature); }
public static void Main() { Debug.Print("Read TMP35"); var tmp35 = new AnalogTemperature(AnalogChannels.ANALOG_PIN_A0, AnalogTemperature.KnownSensorType.TMP35, updateInterval: 0); // // Now read the sensor every 5 seconds. // while (true) { tmp35.Update(); Debug.Print("Reading: " + tmp35.Temperature.ToString("f2")); Thread.Sleep(5000); } }
void Initialize() { onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); onboardLed.SetColor(Color.Blue); analogTemperature = new AnalogTemperature(Device, Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35); analogTemperature.StartUpdating(TimeSpan.FromMinutes(5)); displayView = new DisplayView(); onboardLed.SetColor(Color.Green); }
void Initialize() { onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); displayController = new WeatherView(); onboardLed.StartPulse(Color.Green); }
protected void InitializePeripherals() { // display //_display = new Lcd2004(new MCP23008()); _display = new Lcd2004(N.Pins.GPIO_PIN_D8, N.Pins.GPIO_PIN_D9, N.Pins.GPIO_PIN_D10, N.Pins.GPIO_PIN_D11, N.Pins.GPIO_PIN_D12, N.Pins.GPIO_PIN_D13); _display.Clear(); _display.WriteLine("Display up!", 0); // rotary encoder _encoder = new RotaryEncoderWithButton(N.Pins.GPIO_PIN_D4, N.Pins.GPIO_PIN_D5, N.Pins.GPIO_PIN_D7, CircuitTerminationType.CommonGround); // door stuff _doorServo = new ContinuousRotationServo(N.PWMChannels.PWM_PIN_D6, NamedServoConfigs.IdealContinuousRotationServo); _openEndStopSwitch = new PushButton(N.Pins.GPIO_PIN_D2, CircuitTerminationType.CommonGround); _closeEndStopSwitch = new PushButton(N.Pins.GPIO_PIN_D3, CircuitTerminationType.CommonGround); _display.WriteLine("Door stuff up!", 1); // temp stuff _heatLampRelay = new SoftPwm(N.Pins.GPIO_PIN_D0, 0, 1f / 60f); _tempSensor = new AnalogTemperature(N.AnalogChannels.ANALOG_PIN_A0, AnalogTemperature.KnownSensorType.LM35, updateInterval: 5000, temperatureChangeNotificationThreshold: 1.0f); _display.WriteLine("Temp stuff up!", 2); //==== now wire up all the peripheral events // Analog Temp Sensor. Setup to notify at half a degree changes _tempSensor.TemperatureChanged += (object sender, SensorFloatEventArgs e) => { _currentTemp = e.CurrentValue; Debug.Print("Current Temp: " + _currentTemp.ToString("N1")); UpdateInfoScreen(); }; _encoder.Clicked += (s, e) => { // if the menu isn't displayed, display it. otherwise // encoder click events are handled by menu if (!_inMenu) { this.DisplayMenu(); } }; Debug.Print("Peripherals initialized."); }
public MeadowApp() { Console.WriteLine("Initializing..."); this.analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); this.analogTemperature.Updated += this.AnalogTemperatureUpdated; SpiClockConfiguration config = new SpiClockConfiguration( speedKHz: 6000, SpiClockConfiguration.Mode.Mode3); ISpiBus spiBus = Device.CreateSpiBus( Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config); this.st7789 = new St7789( device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); this.displayWidth = Convert.ToInt32(this.st7789.Width); this.displayHeight = Convert.ToInt32(this.st7789.Height); this.graphics = new GraphicsLibrary(this.st7789) { Rotation = GraphicsLibrary.RotationType._270Degrees }; this.LoadScreen(); this.analogTemperature.StartUpdating(); OnboardLed led = new OnboardLed(Device); led.SetColor(RgbColor.Green); }
public MeadowApp() { this.spdtSwitch = new SpdtSwitch(Device.CreateDigitalInputPort(Device.Pins.D04, InterruptMode.EdgeBoth)); this.displayInCelcius = this.spdtSwitch.IsOn; this.spdtSwitch.Changed += this.SpdtSwitch_Changed; this.st7789 = InitializeLcdScreen(out this.displayWidth, out this.displayHeight, out this.graphics); this.analogTemperature = InitializeAnalogTemperatureSensor(this.AnalogTemperatureUpdated); this.mcp9808 = InitializeMcp9808TemperatureSensor(); this.Display9808Temperature(this.mcp9808.GetTemperature()); this.mcp9808.Subscribe(new FilterableChangeObserver <AtmosphericConditionChangeResult, AtmosphericConditions>( this.Mcp9808TemperatureUpdated, e => Math.Abs(e.Delta.Temperature.Value) > 0.1 )); this.mcp9808.StartUpdating(); OnboardLed led = new OnboardLed(Device); led.SetColor(RgbColor.Green); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); analogTemperature.TemperatureUpdated += AnalogTemperatureTemperatureUpdated; //+= AnalogTemperatureUpdated; var config = new SpiClockConfiguration( speed: new Frequency(48000, Frequency.UnitType.Kilohertz), mode: SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus( clock: Device.Pins.SCK, copi: Device.Pins.MOSI, cipo: Device.Pins.MISO, config: config); var st7789 = new St7789( device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240); graphics = new MicroGraphics(st7789); graphics.Rotation = RotationType._270Degrees; onboardLed.SetColor(Color.Green); }
/// <summary> /// Configures the hardware perihperals (LCD, temp sensor, relays, etc.) /// so they can be used by the application. /// </summary> protected void InitializePeripherals() { // pushbutton (for testing) _pushButton = new PushButton( (H.Cpu.Pin) 0x15, CircuitTerminationType.Floating); // Rotary Encoder _encoder = new RotaryEncoderWithButton( N.Pins.GPIO_PIN_D7, N.Pins.GPIO_PIN_D6, N.Pins.GPIO_PIN_D5, CircuitTerminationType.CommonGround); // LCD //_display = new Lcd2004(new MCP23008()); _display = new Lcd2004(N.Pins.GPIO_PIN_D8, N.Pins.GPIO_PIN_D9, N.Pins.GPIO_PIN_D10, N.Pins.GPIO_PIN_D11, N.Pins.GPIO_PIN_D12, N.Pins.GPIO_PIN_D13); _display.Clear(); Debug.Print("Display up."); _display.WriteLine("Display up!", 0); // Analog Temp Sensor. Setup to notify at half a degree changes _tempSensor = new AnalogTemperature(N.AnalogChannels.ANALOG_PIN_A0, AnalogTemperature.KnownSensorType.LM35, temperatureChangeNotificationThreshold: 0.5F); Debug.Print("TempSensor up."); _display.WriteLine("Temp Sensor up!", 1); // Heater driven by Software PWM _heaterRelayPwm = new SoftPwm(N.Pins.GPIO_PIN_D2, 0.5f, 1.0f / 30.0f); Debug.Print("Heater PWM up."); _display.WriteLine("Heater PWM up!", 2); // Fan Relay _fanRelay = new Relay(N.Pins.GPIO_PIN_D3); Debug.Print("Fan up."); _display.WriteLine("Fan up!", 3); // output status Debug.Print("Peripherals up"); _display.WriteLine("Peripherals online!", 0); }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); analogTemperature = new AnalogTemperature( device: Device, analogPin: Device.Pins.A00, sensorType: AnalogTemperature.KnownSensorType.LM35 ); analogTemperature.Updated += AnalogTemperatureUpdated; var config = new SpiClockConfiguration( speedKHz: 6000, mode: SpiClockConfiguration.Mode.Mode3); st7789 = new St7789 ( device: Device, spiBus: Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config), chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); displayWidth = Convert.ToInt32(st7789.Width); displayHeight = Convert.ToInt32(st7789.Height); graphics = new GraphicsLibrary(st7789); graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; led.SetColor(RgbLed.Colors.Green); LoadScreen(); analogTemperature.StartUpdating(); }
public static void Main() { Debug.Print("Read TMP35"); // // Create a new TMP35 object to check the temperature every 1s and // to report any changes over 0.1C. // var tmp35 = new AnalogTemperature(AnalogChannels.ANALOG_PIN_A0, AnalogTemperature.KnownSensorType.TMP35, updateInterval: 1000, temperatureChangeNotificationThreshold: 0.1F); // // Connect an interrupt handler. // tmp35.TemperatureChanged += (s, e) => { Debug.Print("Temperature: " + e.CurrentValue.ToString("f2")); }; // // Now put the application to sleep as the data is processed // by the interrupt handler above. // Thread.Sleep(Timeout.Infinite); }
void Initialize() { onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); button = new PushButton(Device, Device.Pins.D04, ResistorMode.InternalPullUp); button.Clicked += ButtonClicked; var config = new SpiClockConfiguration( speed: new Frequency(48000, Frequency.UnitType.Kilohertz), mode: SpiClockConfiguration.Mode.Mode3); var spiBus = Device.CreateSpiBus( clock: Device.Pins.SCK, copi: Device.Pins.MOSI, cipo: Device.Pins.MISO, config: config); var display = new St7789 ( device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); displayController = new DisplayController(display); capacitive = new Capacitive( device: Device, analogPin: Device.Pins.A01, minimumVoltageCalibration: MINIMUM_VOLTAGE_CALIBRATION, maximumVoltageCalibration: MAXIMUM_VOLTAGE_CALIBRATION); var capacitiveObserver = Capacitive.CreateObserver( handler: result => { onboardLed.SetColor(Color.Purple); displayController.UpdateMoistureImage(result.New); displayController.UpdateMoisturePercentage(result.New, result.Old.Value); onboardLed.SetColor(Color.Green); }, filter: null ); capacitive.Subscribe(capacitiveObserver); capacitive.StartUpdating(TimeSpan.FromHours(1)); analogTemperature = new AnalogTemperature(Device, Device.Pins.A00, AnalogTemperature.KnownSensorType.LM35); var analogTemperatureObserver = AnalogTemperature.CreateObserver( handler => { onboardLed.SetColor(Color.Purple); displayController.UpdateTemperatureValue(handler.New, handler.Old.Value); onboardLed.SetColor(Color.Green); }, filter: null ); analogTemperature.Subscribe(analogTemperatureObserver); analogTemperature.StartUpdating(TimeSpan.FromHours(1)); onboardLed.SetColor(Color.Green); }
void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); onboardLed.SetColor(Color.Red); button = new PushButton(Device, Device.Pins.D04, ResistorMode.InternalPullUp); button.Clicked += ButtonClicked; var config = new SpiClockConfiguration ( speedKHz: 6000, mode: SpiClockConfiguration.Mode.Mode3 ); var display = new St7789 ( device: Device, spiBus: Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config), chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 240, height: 240 ); displayController = new DisplayController(display); capacitive = new Capacitive( device: Device, analogPin: Device.Pins.A01, minimumVoltageCalibration: MINIMUM_VOLTAGE_CALIBRATION, maximumVoltageCalibration: MAXIMUM_VOLTAGE_CALIBRATION); capacitive.Subscribe(new FilterableChangeObserver <FloatChangeResult, float>( handler => { onboardLed.SetColor(Color.Purple); displayController.UpdateMoistureImage(handler); displayController.UpdateMoisturePercentage(handler.New, handler.Old); onboardLed.SetColor(Color.Green); }, filter => { return(Math.Abs(filter.Delta) > 0.05); } )); capacitive.StartUpdating( sampleCount: 10, sampleIntervalDuration: 40, standbyDuration: (int)TimeSpan.FromHours(1).TotalMilliseconds); analogTemperature = new AnalogTemperature(Device, Device.Pins.A00, AnalogTemperature.KnownSensorType.LM35); analogTemperature.Subscribe(new FilterableChangeObserver <AtmosphericConditionChangeResult, AtmosphericConditions>( handler => { onboardLed.SetColor(Color.Purple); displayController.UpdateTemperatureValue(handler.New.Temperature.Value, handler.Old.Temperature.Value); onboardLed.SetColor(Color.Green); }, filter => { return(Math.Abs(filter.Delta.Temperature.Value) > 1f); } )); analogTemperature.StartUpdating( sampleCount: 10, sampleIntervalDuration: 40, standbyDuration: (int)TimeSpan.FromHours(1).TotalMilliseconds); onboardLed.SetColor(Color.Green); }
public SensorReader(F7Micro device, Layout layout) { _temperature = new AnalogTemperature(device, device.Pins.A00, AnalogTemperature.KnownSensorType.LM35); layout.Bind("sensors", this); }