public static void Run() { var scope = new DebugScope(); //scope.UpdatePeriod.Value = 1; var accel = new Memsic2125(); accel.XPwmInput.ConnectTo(new DigitalInputPin(Pins.GPIO_PIN_D6).Output); accel.YPwmInput.ConnectTo(new DigitalInputPin(Pins.GPIO_PIN_D7).Output); scope.ConnectTo(accel.XAccelerationOutput); scope.ConnectTo(accel.YAccelerationOutput); var compass = new Grove3AxisDigitalCompass(); scope.ConnectTo(compass.XGaussOutput); scope.ConnectTo(compass.YGaussOutput); scope.ConnectTo(compass.ZGaussOutput); var a0 = new AnalogInputPin(AnalogChannels.ANALOG_PIN_A0); scope.ConnectTo(a0.Analog); var sharp = new SharpGP2D12(); a0.Analog.ConnectTo(sharp.AnalogInput); scope.ConnectTo(sharp.DistanceOutput); var therm = new Thermistor(); therm.AnalogInput.ConnectTo(a0.Analog); scope.ConnectTo(therm.Temperature); var b = new CelsiusToFahrenheit(); therm.Temperature.ConnectTo(b.Celsius); scope.ConnectTo(b.Fahrenheit); var bmp = new Bmp085(); scope.ConnectTo(bmp.Temperature); var b2 = new CelsiusToFahrenheit(); bmp.Temperature.ConnectTo(b2.Celsius); scope.ConnectTo(b2.Fahrenheit); for (; ;) { Debug.Print("Tick"); Thread.Sleep(1000); } }
public MeadowApp() { Console.WriteLine("Initializing..."); // configure our BME280 on the I2C Bus var i2c = Device.CreateI2cBus(); bmp085 = new Bmp085(i2c); // Example that uses an IObersvable subscription to only be notified // when the temperature changes by at least a degree, and humidty by 5%. // (blowing hot breath on the sensor should trigger) bmp085.Subscribe(new FilterableObserver <AtmosphericConditionChangeResult, AtmosphericConditions>( h => { Console.WriteLine($"Temp and pressure changed by threshold; new temp: {h.New.Temperature}, old: {h.Old.Temperature}"); }, e => { return( (Math.Abs(e.Delta.Temperature) > 1) && (Math.Abs(e.Delta.Pressure) > 5) ); } )); // classical .NET events can also be used: bmp085.Updated += (object sender, AtmosphericConditionChangeResult e) => { Console.WriteLine($" Temperature: {e.New.Temperature}°C, Pressure: {e.New.Pressure}hPa"); }; // get an initial reading ReadConditions().Wait(); // start updating continuously bmp085.StartUpdating(); }