From 78364ed09c03896d988c20745c756c58ae84f5d8 Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Tue, 28 Nov 2023 17:58:24 -0800 Subject: [PATCH] Release 1.5.0 --- .../Driver/3-AxisDigitalAccelerometer16g.cs | 2 +- .../3-AxisDigitalAccelerometer16g.csproj | 2 +- .../Driver/Readme.md | 4 +- ...-AxisDigitalAccelerometer16g_Sample.csproj | 2 +- .../MeadowApp.cs | 4 +- .../Driver/3-AxisDigitalAccelerometer1_5g.cs | 2 +- .../3-AxisDigitalAccelerometer1_5g.csproj | 2 +- .../Driver/Readme.md | 12 +- ...AxisDigitalAccelerometer1_5g_Sample.csproj | 2 +- .../MeadowApp.cs | 12 +- .../Driver/3-AxisDigitalCompass.cs | 14 +- .../Driver/3-AxisDigitalCompass.csproj | 2 +- Source/3-AxisDigitalCompass/Driver/Readme.md | 14 +- .../3-AxisDigitalCompass_Sample.csproj | 2 +- .../3-AxisDigitalCompass_Sample/MeadowApp.cs | 14 +- .../Driver/4-ChannelSpdtRelay.cs | 86 ++++++++++ .../Driver/4-ChannelSpdtRelay.csproj | 30 ++++ .../Driver/4-ChannelSpdtRelay.enums.cs | 28 ++++ Source/4-ChannelSpdtRelay/Driver/Readme.md | 69 ++++++++ .../Stm32Expander/Stm32Expander.Commands.cs | 10 ++ .../Stm32Expander.DigitalOutputPort.cs | 47 ++++++ .../Stm32Expander.PinDefinitions.cs | 98 ++++++++++++ .../Driver/Stm32Expander/Stm32Expander.cs | 151 ++++++++++++++++++ .../4-ChannelSpdtRelay_Sample.csproj | 12 ++ .../4-ChannelSpdtRelay_Sample/MeadowApp.cs | 60 +++++++ .../4-DigitDisplay/Driver/4-DigitDisplay.cs | 5 +- .../Driver/4-DigitDisplay.csproj | 2 +- Source/4-DigitDisplay/Driver/Readme.md | 7 +- .../4-DigitDisplay_Sample.csproj | 2 +- .../Sample/4-DigitDisplay_Sample/MeadowApp.cs | 8 +- Source/Button/Driver/Button.csproj | 2 +- Source/Button/Driver/Readme.md | 6 +- .../Sample/Button_Sample/Button_Sample.csproj | 2 +- .../Button/Sample/Button_Sample/MeadowApp.cs | 6 +- Source/Buzzer/Driver/Buzzer.csproj | 2 +- Source/Buzzer/Driver/Readme.md | 4 +- .../Sample/Buzzer_Sample/Buzzer_Sample.csproj | 2 +- .../Buzzer/Sample/Buzzer_Sample/MeadowApp.cs | 4 +- Source/FlameSensor/Driver/FlameSensor.csproj | 2 +- Source/FlameSensor/Driver/Readme.md | 4 +- .../FlameSensor_Sample.csproj | 2 +- .../Sample/FlameSensor_Sample/MeadowApp.cs | 4 +- Source/Grove.sln | 23 +++ Source/LCD/Driver/LCD.csproj | 2 +- Source/LCD/Driver/Readme.md | 2 +- .../LCD/Samples/LCD_Sample/LCD_Sample.csproj | 2 +- Source/LCD/Samples/LCD_Sample/MeadowApp.cs | 2 +- Source/LEDButton/Driver/LEDButton.csproj | 2 +- Source/LEDButton/Driver/Readme.md | 6 +- .../LEDButton_Sample/LEDButton_Sample.csproj | 2 +- .../Sample/LEDButton_Sample/MeadowApp.cs | 6 +- Source/LEDSocket/Driver/LEDSocket.csproj | 2 +- Source/LEDSocket/Driver/Readme.md | 2 +- .../LEDSocket_Sample/LEDSocket_Sample.csproj | 2 +- .../Sample/LEDSocket_Sample/MeadowApp.cs | 2 +- Source/LightSensor/Driver/LightSensor.cs | 12 +- Source/LightSensor/Driver/LightSensor.csproj | 2 +- Source/LightSensor/Driver/Readme.md | 10 +- .../LightSensor_Sample.csproj | 2 +- .../Sample/LightSensor_Sample/MeadowApp.cs | 10 +- Source/LineFinder/Driver/LineFinder.cs | 2 +- Source/LineFinder/Driver/LineFinder.csproj | 2 +- Source/LineFinder/Driver/Readme.md | 4 +- .../LineFinder_Sample.csproj | 2 +- .../Sample/LineFinder_Sample/MeadowApp.cs | 4 +- .../LoudnessSensor/Driver/LoudnessSensor.cs | 10 +- .../Driver/LoudnessSensor.csproj | 2 +- Source/LoudnessSensor/Driver/Readme.md | 8 +- .../LoudnessSensor_Sample.csproj | 2 +- .../Sample/LoudnessSensor_Sample/MeadowApp.cs | 8 +- .../MagneticSwitch/Driver/MagneticSwitch.cs | 2 +- .../Driver/MagneticSwitch.csproj | 2 +- Source/MagneticSwitch/Driver/Readme.md | 4 +- .../MagneticSwitch_Sample.csproj | 2 +- .../Sample/MagneticSwitch_Sample/MeadowApp.cs | 4 +- .../Driver/MiniPIRMotionSensor.csproj | 2 +- Source/MiniPIRMotionSensor/Driver/Readme.md | 4 +- .../MiniPIRMotionSensor_Sample/MeadowApp.cs | 4 +- .../MiniPIRMotionSensor_Sample.csproj | 2 +- .../MoistureSensor/Driver/MoistureSensor.cs | 10 +- .../Driver/MoistureSensor.csproj | 2 +- Source/MoistureSensor/Driver/Readme.md | 10 +- .../Sample/MoistureSensor_Sample/MeadowApp.cs | 10 +- .../MoistureSensor_Sample.csproj | 2 +- .../Driver/OLEDDisplay1_12inch.csproj | 4 +- Source/OLEDDisplay1_12inch/Driver/Readme.md | 2 +- .../OLEDDisplay1_12inch_Sample/MeadowApp.cs | 2 +- .../OLEDDisplay1_12inch_Sample.csproj | 2 +- .../Driver/PIRMotionSensor.csproj | 2 +- Source/PIRMotionSensor/Driver/Readme.md | 4 +- .../PIRMotionSensor_Sample/MeadowApp.cs | 4 +- .../PIRMotionSensor_Sample.csproj | 2 +- Source/RTC/Driver/RTC.csproj | 2 +- Source/RTC/Driver/Readme.md | 18 +-- Source/RTC/Sample/RTC_Sample/MeadowApp.cs | 18 +-- .../RTC/Sample/RTC_Sample/RTC_Sample.csproj | 2 +- Source/Relay/Driver/Readme.md | 4 +- Source/Relay/Driver/Relay.cs | 2 +- Source/Relay/Driver/Relay.csproj | 2 +- Source/Relay/Sample/Relay_Sample/MeadowApp.cs | 4 +- .../Sample/Relay_Sample/Relay_Sample.csproj | 2 +- Source/RotaryAngleSensor/Driver/Readme.md | 10 +- .../Driver/RotaryAngleSensor.csproj | 2 +- .../RotaryAngleSensor_Sample/MeadowApp.cs | 10 +- .../RotaryAngleSensor_Sample.csproj | 2 +- Source/Servo/Driver/Readme.md | 8 +- Source/Servo/Driver/Servo.csproj | 2 +- Source/Servo/Sample/Servo_Sample/MeadowApp.cs | 8 +- .../Sample/Servo_Sample/Servo_Sample.csproj | 2 +- Source/SoundSensor/Driver/Readme.md | 8 +- Source/SoundSensor/Driver/SoundSensor.csproj | 2 +- .../Sample/SoundSensor_Sample/MeadowApp.cs | 8 +- .../SoundSensor_Sample.csproj | 2 +- Source/Speaker/Driver/Readme.md | 4 +- Source/Speaker/Driver/Speaker.cs | 2 - Source/Speaker/Driver/Speaker.csproj | 2 +- .../Sample/Speaker_Sample/MeadowApp.cs | 4 +- .../Speaker_Sample/Speaker_Sample.csproj | 2 +- Source/SwitchP/Driver/Readme.md | 4 +- Source/SwitchP/Driver/SwitchP.cs | 6 +- Source/SwitchP/Driver/SwitchP.csproj | 2 +- .../Sample/SwitchP_Sample/MeadowApp.cs | 4 +- .../SwitchP_Sample/SwitchP_Sample.csproj | 2 +- .../Driver/Readme.md | 8 +- ...peratureHumiditySensor_HighAccuracyMini.cs | 2 +- ...tureHumiditySensor_HighAccuracyMini.csproj | 2 +- .../MeadowApp.cs | 8 +- ...iditySensor_HighAccuracyMini_Sample.csproj | 2 +- Source/TemperatureSensor/Driver/Readme.md | 14 +- .../Driver/TemperatureSensor.csproj | 2 +- .../TemperatureSensor_Sample/MeadowApp.cs | 14 +- .../TemperatureSensor_Sample.csproj | 2 +- Source/ThumbJoystick/Driver/Readme.md | 6 +- Source/ThumbJoystick/Driver/ThumbJoystick.cs | 10 +- .../ThumbJoystick/Driver/ThumbJoystick.csproj | 2 +- .../Sample/ThumbJoystick_Sample/MeadowApp.cs | 6 +- .../ThumbJoystick_Sample.csproj | 2 +- Source/Tilt/Driver/Readme.md | 4 +- Source/Tilt/Driver/Tilt.cs | 6 +- Source/Tilt/Driver/Tilt.csproj | 2 +- Source/Tilt/Sample/Tilt_Sample/MeadowApp.cs | 4 +- .../Sample/Tilt_Sample/Tilt_Sample.csproj | 2 +- Source/Touch/Driver/Readme.md | 6 +- Source/Touch/Driver/Touch.csproj | 2 +- Source/Touch/Sample/Touch_Sample/MeadowApp.cs | 6 +- .../Sample/Touch_Sample/Touch_Sample.csproj | 2 +- Source/VibrationMotor/Driver/Readme.md | 6 +- .../VibrationMotor/Driver/VibrationMotor.cs | 4 +- .../Driver/VibrationMotor.csproj | 2 +- .../Sample/VibrationMotor_Sample/MeadowApp.cs | 6 +- .../VibrationMotor_Sample.csproj | 2 +- Source/VibrationSensor/Driver/Readme.md | 4 +- .../Driver/VibrationSensor.csproj | 2 +- .../VibrationSensor_Sample/MeadowApp.cs | 4 +- .../VibrationSensor_Sample.csproj | 2 +- Source/WaterSensor/Driver/Readme.md | 10 +- Source/WaterSensor/Driver/WaterSensor.cs | 2 +- Source/WaterSensor/Driver/WaterSensor.csproj | 2 +- .../Sample/WaterSensor_Sample/MeadowApp.cs | 10 +- .../WaterSensor_Sample.csproj | 2 +- 160 files changed, 950 insertions(+), 334 deletions(-) create mode 100644 Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.cs create mode 100644 Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.csproj create mode 100644 Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.enums.cs create mode 100644 Source/4-ChannelSpdtRelay/Driver/Readme.md create mode 100644 Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.Commands.cs create mode 100644 Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.DigitalOutputPort.cs create mode 100644 Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.PinDefinitions.cs create mode 100644 Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.cs create mode 100644 Source/4-ChannelSpdtRelay/Sample/4-ChannelSpdtRelay_Sample/4-ChannelSpdtRelay_Sample.csproj create mode 100644 Source/4-ChannelSpdtRelay/Sample/4-ChannelSpdtRelay_Sample/MeadowApp.cs diff --git a/Source/3-AxisDigitalAccelerometer16g/Driver/3-AxisDigitalAccelerometer16g.cs b/Source/3-AxisDigitalAccelerometer16g/Driver/3-AxisDigitalAccelerometer16g.cs index 9a8770c7..c52aeba3 100644 --- a/Source/3-AxisDigitalAccelerometer16g/Driver/3-AxisDigitalAccelerometer16g.cs +++ b/Source/3-AxisDigitalAccelerometer16g/Driver/3-AxisDigitalAccelerometer16g.cs @@ -13,7 +13,7 @@ public class ThreeAxisDigitalAccelerometer16g : Adxl345 /// /// public ThreeAxisDigitalAccelerometer16g(II2cBus i2CBus) - : base (i2CBus) + : base(i2CBus) { } } } \ No newline at end of file diff --git a/Source/3-AxisDigitalAccelerometer16g/Driver/3-AxisDigitalAccelerometer16g.csproj b/Source/3-AxisDigitalAccelerometer16g/Driver/3-AxisDigitalAccelerometer16g.csproj index 8bc063db..ea9249ad 100644 --- a/Source/3-AxisDigitalAccelerometer16g/Driver/3-AxisDigitalAccelerometer16g.csproj +++ b/Source/3-AxisDigitalAccelerometer16g/Driver/3-AxisDigitalAccelerometer16g.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/3-AxisDigitalAccelerometer16g/Driver/Readme.md b/Source/3-AxisDigitalAccelerometer16g/Driver/Readme.md index 36e23ae1..24409986 100644 --- a/Source/3-AxisDigitalAccelerometer16g/Driver/Readme.md +++ b/Source/3-AxisDigitalAccelerometer16g/Driver/Readme.md @@ -17,14 +17,14 @@ ThreeAxisDigitalAccelerometer16g sensor; public override Task Initialize() { - Console.WriteLine("Initializing"); + Resolver.Log.Info("Initializing"); sensor = new ThreeAxisDigitalAccelerometer16g(Device.CreateI2cBus()); sensor.SetPowerState(false, false, true, false, ThreeAxisDigitalAccelerometer16g.Frequencies.TwoHz); sensor.Updated += (sender, result) => { - Console.WriteLine($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," + + Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," + $"Y:{result.New.Y.MetersPerSecondSquared:N2}," + $"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]"); }; diff --git a/Source/3-AxisDigitalAccelerometer16g/Sample/3-AxisDigitalAccelerometer16g_Sample/3-AxisDigitalAccelerometer16g_Sample.csproj b/Source/3-AxisDigitalAccelerometer16g/Sample/3-AxisDigitalAccelerometer16g_Sample/3-AxisDigitalAccelerometer16g_Sample.csproj index e6dd1bcc..f8304915 100644 --- a/Source/3-AxisDigitalAccelerometer16g/Sample/3-AxisDigitalAccelerometer16g_Sample/3-AxisDigitalAccelerometer16g_Sample.csproj +++ b/Source/3-AxisDigitalAccelerometer16g/Sample/3-AxisDigitalAccelerometer16g_Sample/3-AxisDigitalAccelerometer16g_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/3-AxisDigitalAccelerometer16g/Sample/3-AxisDigitalAccelerometer16g_Sample/MeadowApp.cs b/Source/3-AxisDigitalAccelerometer16g/Sample/3-AxisDigitalAccelerometer16g_Sample/MeadowApp.cs index b37153e4..54ca561c 100644 --- a/Source/3-AxisDigitalAccelerometer16g/Sample/3-AxisDigitalAccelerometer16g_Sample/MeadowApp.cs +++ b/Source/3-AxisDigitalAccelerometer16g/Sample/3-AxisDigitalAccelerometer16g_Sample/MeadowApp.cs @@ -15,14 +15,14 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initializing"); + Resolver.Log.Info("Initializing"); sensor = new ThreeAxisDigitalAccelerometer16g(Device.CreateI2cBus()); sensor.SetPowerState(false, false, true, false, ThreeAxisDigitalAccelerometer16g.Frequencies.TwoHz); sensor.Updated += (sender, result) => { - Console.WriteLine($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," + + Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," + $"Y:{result.New.Y.MetersPerSecondSquared:N2}," + $"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]"); }; diff --git a/Source/3-AxisDigitalAccelerometer1_5g/Driver/3-AxisDigitalAccelerometer1_5g.cs b/Source/3-AxisDigitalAccelerometer1_5g/Driver/3-AxisDigitalAccelerometer1_5g.cs index 4a070833..5e3b2f71 100644 --- a/Source/3-AxisDigitalAccelerometer1_5g/Driver/3-AxisDigitalAccelerometer1_5g.cs +++ b/Source/3-AxisDigitalAccelerometer1_5g/Driver/3-AxisDigitalAccelerometer1_5g.cs @@ -13,7 +13,7 @@ public class ThreeAxisDigitalAccelerometer1_5g : Mma7660fc /// /// public ThreeAxisDigitalAccelerometer1_5g(II2cBus i2cBus) - : base (i2cBus, Addresses.Address_0x4c) + : base(i2cBus, Addresses.Address_0x4c) { } } } \ No newline at end of file diff --git a/Source/3-AxisDigitalAccelerometer1_5g/Driver/3-AxisDigitalAccelerometer1_5g.csproj b/Source/3-AxisDigitalAccelerometer1_5g/Driver/3-AxisDigitalAccelerometer1_5g.csproj index 0a4ff3d1..a7cb00d0 100644 --- a/Source/3-AxisDigitalAccelerometer1_5g/Driver/3-AxisDigitalAccelerometer1_5g.csproj +++ b/Source/3-AxisDigitalAccelerometer1_5g/Driver/3-AxisDigitalAccelerometer1_5g.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/3-AxisDigitalAccelerometer1_5g/Driver/Readme.md b/Source/3-AxisDigitalAccelerometer1_5g/Driver/Readme.md index b62de589..1b6730d8 100644 --- a/Source/3-AxisDigitalAccelerometer1_5g/Driver/Readme.md +++ b/Source/3-AxisDigitalAccelerometer1_5g/Driver/Readme.md @@ -17,14 +17,15 @@ ThreeAxisDigitalAccelerometer1_5g sensor; public override Task Initialize() { - Console.WriteLine("Initializing"); + Resolver.Log.Info("Initializing"); // create the sensor driver sensor = new ThreeAxisDigitalAccelerometer1_5g(Device.CreateI2cBus()); // classical .NET events can also be used: - sensor.Updated += (sender, result) => { - Console.WriteLine($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," + + sensor.Updated += (sender, result) => + { + Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," + $"Y:{result.New.Y.MetersPerSecondSquared:N2}," + $"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]" + $" Direction: {sensor.Direction}" + @@ -33,9 +34,10 @@ public override Task Initialize() // Example that uses an IObersvable subscription to only be notified when the filter is satisfied var consumer = ThreeAxisDigitalAccelerometer1_5g.CreateObserver( - handler: result => Console.WriteLine($"Observer: [x] changed by threshold; new [x]: X:{result.New.X:N2}, old: X:{result.Old?.X:N2}"), + handler: result => Resolver.Log.Info($"Observer: [x] changed by threshold; new [x]: X:{result.New.X:N2}, old: X:{result.Old?.X:N2}"), // only notify if there's a greater than 0.5G change in the Z direction - filter: result => { + filter: result => + { if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var. return (result.New - old).Z > new Acceleration(0.5, AU.Gravity); diff --git a/Source/3-AxisDigitalAccelerometer1_5g/Sample/3-AxisDigitalAccelerometer1_5g_Sample/3-AxisDigitalAccelerometer1_5g_Sample.csproj b/Source/3-AxisDigitalAccelerometer1_5g/Sample/3-AxisDigitalAccelerometer1_5g_Sample/3-AxisDigitalAccelerometer1_5g_Sample.csproj index 4a75ded7..11a05fdd 100644 --- a/Source/3-AxisDigitalAccelerometer1_5g/Sample/3-AxisDigitalAccelerometer1_5g_Sample/3-AxisDigitalAccelerometer1_5g_Sample.csproj +++ b/Source/3-AxisDigitalAccelerometer1_5g/Sample/3-AxisDigitalAccelerometer1_5g_Sample/3-AxisDigitalAccelerometer1_5g_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/3-AxisDigitalAccelerometer1_5g/Sample/3-AxisDigitalAccelerometer1_5g_Sample/MeadowApp.cs b/Source/3-AxisDigitalAccelerometer1_5g/Sample/3-AxisDigitalAccelerometer1_5g_Sample/MeadowApp.cs index 997ea99d..05040393 100644 --- a/Source/3-AxisDigitalAccelerometer1_5g/Sample/3-AxisDigitalAccelerometer1_5g_Sample/MeadowApp.cs +++ b/Source/3-AxisDigitalAccelerometer1_5g/Sample/3-AxisDigitalAccelerometer1_5g_Sample/MeadowApp.cs @@ -17,14 +17,15 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initializing"); + Resolver.Log.Info("Initializing"); // create the sensor driver sensor = new ThreeAxisDigitalAccelerometer1_5g(Device.CreateI2cBus()); // classical .NET events can also be used: - sensor.Updated += (sender, result) => { - Console.WriteLine($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," + + sensor.Updated += (sender, result) => + { + Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," + $"Y:{result.New.Y.MetersPerSecondSquared:N2}," + $"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]" + $" Direction: {sensor.Direction}" + @@ -33,9 +34,10 @@ public override Task Initialize() // Example that uses an IObersvable subscription to only be notified when the filter is satisfied var consumer = ThreeAxisDigitalAccelerometer1_5g.CreateObserver( - handler: result => Console.WriteLine($"Observer: [x] changed by threshold; new [x]: X:{result.New.X:N2}, old: X:{result.Old?.X:N2}"), + handler: result => Resolver.Log.Info($"Observer: [x] changed by threshold; new [x]: X:{result.New.X:N2}, old: X:{result.Old?.X:N2}"), // only notify if there's a greater than 0.5G change in the Z direction - filter: result => { + filter: result => + { if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var. return (result.New - old).Z > new Acceleration(0.5, AU.Gravity); diff --git a/Source/3-AxisDigitalCompass/Driver/3-AxisDigitalCompass.cs b/Source/3-AxisDigitalCompass/Driver/3-AxisDigitalCompass.cs index 3c977e6c..22230e82 100644 --- a/Source/3-AxisDigitalCompass/Driver/3-AxisDigitalCompass.cs +++ b/Source/3-AxisDigitalCompass/Driver/3-AxisDigitalCompass.cs @@ -25,13 +25,13 @@ public ThreeAxisDigitalCompass( DataOutputRates outputRate = DataOutputRates.Rate15, SampleAmounts samplesAmount = SampleAmounts.One, MeasurementConfigurations measurementConfig = MeasurementConfigurations.Normal) - : base ( - i2cBus, - address, - gain, - measuringMode, - outputRate, - samplesAmount, + : base( + i2cBus, + address, + gain, + measuringMode, + outputRate, + samplesAmount, measurementConfig) { } } diff --git a/Source/3-AxisDigitalCompass/Driver/3-AxisDigitalCompass.csproj b/Source/3-AxisDigitalCompass/Driver/3-AxisDigitalCompass.csproj index b0adabf7..6a08ad22 100644 --- a/Source/3-AxisDigitalCompass/Driver/3-AxisDigitalCompass.csproj +++ b/Source/3-AxisDigitalCompass/Driver/3-AxisDigitalCompass.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/3-AxisDigitalCompass/Driver/Readme.md b/Source/3-AxisDigitalCompass/Driver/Readme.md index af188fff..5b892157 100644 --- a/Source/3-AxisDigitalCompass/Driver/Readme.md +++ b/Source/3-AxisDigitalCompass/Driver/Readme.md @@ -17,26 +17,28 @@ ThreeAxisDigitalCompass sensor; public override Task Initialize() { - Console.WriteLine("Initializing ..."); + Resolver.Log.Info("Initializing ..."); sensor = new ThreeAxisDigitalCompass(Device.CreateI2cBus()); - sensor.Updated += (sender, result) => { - Console.WriteLine($"Direction: [X:{result.New.X:N2}," + + sensor.Updated += (sender, result) => + { + Resolver.Log.Info($"Direction: [X:{result.New.X:N2}," + $"Y:{result.New.Y:N2}," + $"Z:{result.New.Z:N2}]"); - Console.WriteLine($"Heading: [{Hmc5883.DirectionToHeading(result.New).DecimalDegrees:N2}] degrees"); + Resolver.Log.Info($"Heading: [{Hmc5883.DirectionToHeading(result.New).DecimalDegrees:N2}] degrees"); }; var consumer = Hmc5883.CreateObserver( handler: result => { - Console.WriteLine($"Observer: [x] changed by threshold; " + + Resolver.Log.Info($"Observer: [x] changed by threshold; " + $"new [x]: X:{Hmc5883.DirectionToHeading(result.New):N2}, " + $"old: X:{((result.Old != null) ? Hmc5883.DirectionToHeading(result.Old.Value) : "n/a"):N2} degrees"); }, - filter: result => { + filter: result => + { if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var. return (Hmc5883.DirectionToHeading(result.New - old) > new Azimuth(5)); diff --git a/Source/3-AxisDigitalCompass/Sample/3-AxisDigitalCompass_Sample/3-AxisDigitalCompass_Sample.csproj b/Source/3-AxisDigitalCompass/Sample/3-AxisDigitalCompass_Sample/3-AxisDigitalCompass_Sample.csproj index c0ad6623..0f7d132d 100644 --- a/Source/3-AxisDigitalCompass/Sample/3-AxisDigitalCompass_Sample/3-AxisDigitalCompass_Sample.csproj +++ b/Source/3-AxisDigitalCompass/Sample/3-AxisDigitalCompass_Sample/3-AxisDigitalCompass_Sample.csproj @@ -12,7 +12,7 @@ latest - + diff --git a/Source/3-AxisDigitalCompass/Sample/3-AxisDigitalCompass_Sample/MeadowApp.cs b/Source/3-AxisDigitalCompass/Sample/3-AxisDigitalCompass_Sample/MeadowApp.cs index 68f65574..85f55e3b 100644 --- a/Source/3-AxisDigitalCompass/Sample/3-AxisDigitalCompass_Sample/MeadowApp.cs +++ b/Source/3-AxisDigitalCompass/Sample/3-AxisDigitalCompass_Sample/MeadowApp.cs @@ -17,26 +17,28 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initializing ..."); + Resolver.Log.Info("Initializing ..."); sensor = new ThreeAxisDigitalCompass(Device.CreateI2cBus()); - sensor.Updated += (sender, result) => { - Console.WriteLine($"Direction: [X:{result.New.X:N2}," + + sensor.Updated += (sender, result) => + { + Resolver.Log.Info($"Direction: [X:{result.New.X:N2}," + $"Y:{result.New.Y:N2}," + $"Z:{result.New.Z:N2}]"); - Console.WriteLine($"Heading: [{Hmc5883.DirectionToHeading(result.New).DecimalDegrees:N2}] degrees"); + Resolver.Log.Info($"Heading: [{Hmc5883.DirectionToHeading(result.New).DecimalDegrees:N2}] degrees"); }; var consumer = Hmc5883.CreateObserver( handler: result => { - Console.WriteLine($"Observer: [x] changed by threshold; " + + Resolver.Log.Info($"Observer: [x] changed by threshold; " + $"new [x]: X:{Hmc5883.DirectionToHeading(result.New):N2}, " + $"old: X:{((result.Old != null) ? Hmc5883.DirectionToHeading(result.Old.Value) : "n/a"):N2} degrees"); }, - filter: result => { + filter: result => + { if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var. return (Hmc5883.DirectionToHeading(result.New - old) > new Azimuth(5)); diff --git a/Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.cs b/Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.cs new file mode 100644 index 00000000..e311a72b --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.cs @@ -0,0 +1,86 @@ +using Meadow.Foundation.Relays; +using Meadow.Hardware; +using Meadow.Peripherals.Relays; + +namespace Meadow.Foundation.Grove.Relays +{ + /// + /// Represents a Grove Four Channel Spdt Relay + /// + public partial class FourChannelSpdtRelay : II2cPeripheral + { + /// + /// The relays + /// + public readonly Relay[] Relays = new Relay[4]; + + /// + public byte DefaultI2cAddress => 0x12; + + /// + /// The digital output ports for the relays + /// + protected readonly IDigitalOutputPort[] ports = new IDigitalOutputPort[4]; + + private readonly Stm32Expander ioExpander; + + /// + /// Creates a new FourChannelSpdtRelay driver + /// + /// The I2C bus the peripheral is connected to + /// The bus address of the peripheral + public FourChannelSpdtRelay(II2cBus i2cBus, byte address = 0x11) + { + ioExpander = new Stm32Expander(i2cBus, address); + + Initialize(); + } + + void Initialize() + { + ports[0] = ioExpander.Pins.SW1.CreateDigitalOutputPort(false); + ports[1] = ioExpander.Pins.SW2.CreateDigitalOutputPort(false); + ports[2] = ioExpander.Pins.SW3.CreateDigitalOutputPort(false); + ports[3] = ioExpander.Pins.SW4.CreateDigitalOutputPort(false); + + Relays[0] = new Relay(ports[0], RelayType.NormallyOpen); + Relays[1] = new Relay(ports[1], RelayType.NormallyOpen); + Relays[2] = new Relay(ports[2], RelayType.NormallyOpen); + Relays[3] = new Relay(ports[3], RelayType.NormallyOpen); + } + + /// + /// Get the firmware version + /// + /// The firmware version as a byte + public byte GetFirmwareVersion() + { + return ioExpander.GetFirmwareVersion(); + } + + /// + /// Set a new I2C address + /// + /// + public void SetI2cAddress(byte address) + { + ioExpander.SetI2cAddress(address); + } + + /// + /// Convenience method to turn all outputs off + /// + public void SetAllOff() + { + ioExpander.SetAllOff(); + } + + /// + /// Convenience method to turn all outputs on + /// + public void SetAllOn() + { + ioExpander.SetAllOn(); + } + } +} \ No newline at end of file diff --git a/Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.csproj b/Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.csproj new file mode 100644 index 00000000..fcee7e77 --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.csproj @@ -0,0 +1,30 @@ + + + Readme.md + enable + 10.0 + Apache-2.0 + Wilderness Labs, Inc + true + netstandard2.1 + true + Library + 4ChannelSpdtRelay + Wilderness Labs, Inc + http://developer.wildernesslabs.co/Meadow/Meadow.Foundation/ + Meadow.Foundation.Grove.Relays.4ChannelSpdtRelay + https://github.com/WildernessLabs/Meadow.Foundation.Grove + Meadow.Foundation,Grove,relay,relays,spdt + 0.1.0 + true + Grove I2C 4-Channel SPDT Relay + icon.png + + + + + + + + + diff --git a/Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.enums.cs b/Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.enums.cs new file mode 100644 index 00000000..c7cbc72b --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Driver/4-ChannelSpdtRelay.enums.cs @@ -0,0 +1,28 @@ +namespace Meadow.Foundation.Grove.Relays +{ + public partial class FourChannelSpdtRelay + { + /// + /// Represents the four relays on the Grove 4-Channel SPDT Relay + /// + public enum RelayIndex + { + /// + /// Switch 1 + /// + Switch1 = 0, + /// + /// Switch 2 + /// + Switch2 = 1, + /// + /// Switch 3 + /// + Switch3 = 2, + /// + /// Switch 4 + /// + Switch4 = 3, + } + } +} diff --git a/Source/4-ChannelSpdtRelay/Driver/Readme.md b/Source/4-ChannelSpdtRelay/Driver/Readme.md new file mode 100644 index 00000000..445bc9b6 --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Driver/Readme.md @@ -0,0 +1,69 @@ +# Meadow.Foundation.Grove.Relays.4ChannelSpdtRelay + +**Grove I2C 4-Channel SPDT Relay** + +The **4ChannelSpdtRelay** library is designed for the [Wilderness Labs](www.wildernesslabs.co) Meadow .NET IoT platform and is part of [Meadow.Foundation](https://developer.wildernesslabs.co/Meadow/Meadow.Foundation/). + +The **Meadow.Foundation** peripherals library is an open-source repository of drivers and libraries that streamline and simplify adding hardware to your C# .NET Meadow IoT application. + +For more information on developing for Meadow, visit [developer.wildernesslabs.co](http://developer.wildernesslabs.co/). + +To view all Wilderness Labs open-source projects, including samples, visit [github.com/wildernesslabs](https://github.com/wildernesslabs/). + +## Usage + +```csharp +FourChannelSpdtRelay module; + +public override Task Initialize() +{ + Resolver.Log.Info("Initializing ..."); + + module = new FourChannelSpdtRelay(Device.CreateI2cBus(), 0x11); + + return Task.CompletedTask; +} + +public override Task Run() +{ + for (int i = 0; i < 5; i++) + { + Resolver.Log.Info("All on"); + module.SetAllOn(); + + Thread.Sleep(1000); + + Resolver.Log.Info("All off"); + module.SetAllOff(); + + Thread.Sleep(1000); + + for (int j = 0; j < 4; j++) + { + Resolver.Log.Info($"{(RelayIndex)j} on"); + module.Relays[j].IsOn = true; + Thread.Sleep(1000); + } + + for (int j = 0; j < 4; j++) + { + Resolver.Log.Info($"{(RelayIndex)j} off"); + module.Relays[j].IsOn = false; + Thread.Sleep(1000); + } + } + + return Task.CompletedTask; +} + +``` +## How to Contribute + +- **Found a bug?** [Report an issue](https://github.com/WildernessLabs/Meadow_Issues/issues) +- Have a **feature idea or driver request?** [Open a new feature request](https://github.com/WildernessLabs/Meadow_Issues/issues) +- Want to **contribute code?** Fork the [Meadow.Foundation.Grove](https://github.com/WildernessLabs/Meadow.Foundation.Grove) repository and submit a pull request against the `develop` branch + + +## Need Help? + +If you have questions or need assistance, please join the Wilderness Labs [community on Slack](http://slackinvite.wildernesslabs.co/). diff --git a/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.Commands.cs b/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.Commands.cs new file mode 100644 index 00000000..97b63b4d --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.Commands.cs @@ -0,0 +1,10 @@ +namespace Meadow.Foundation.Grove.Relays +{ + internal partial class Stm32Expander + { + const byte CHANNEL_CONTROL = 0x10; + const byte SAVE_I2C_ADDRESS = 0x11; + const byte READ_I2C_ADDRESS = 0x12; + const byte READ_FIRMWARE_VERSION = 0x13; + } +} \ No newline at end of file diff --git a/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.DigitalOutputPort.cs b/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.DigitalOutputPort.cs new file mode 100644 index 00000000..ac2f5035 --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.DigitalOutputPort.cs @@ -0,0 +1,47 @@ +using Meadow.Hardware; +using System; + +namespace Meadow.Foundation.Grove.Relays +{ + internal partial class Stm32Expander + { + /// + /// A Stm32Expander FourChannelSptdRelay-specific implementation of the IDigitalOutputPort + /// + internal partial class DigitalOutputPort : DigitalOutputPortBase + { + internal event EventHandler Disposed = delegate { }; + + /// + /// The port's containing Stm32Expander + /// + public Stm32Expander Peripheral { get; } + + /// + /// Creates a DigitalOutputPort instance + /// + public DigitalOutputPort(Stm32Expander peripheral, IPin pin, bool initialState, OutputType initialOutputType = OutputType.PushPull) + : base(pin, (IDigitalChannelInfo)pin!.SupportedChannels![0], initialState, initialOutputType) + { + Peripheral = peripheral; + + State = initialState; + } + + /// + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + Disposed?.Invoke(this, EventArgs.Empty); + } + + /// + public override bool State + { + + get => Peripheral.GetPinState(Pin); + set => Peripheral.SetPinState(Pin, value); + } + } + } +} diff --git a/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.PinDefinitions.cs b/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.PinDefinitions.cs new file mode 100644 index 00000000..6dfeedda --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.PinDefinitions.cs @@ -0,0 +1,98 @@ +using Meadow.Hardware; +using System.Collections; +using System.Collections.Generic; + +namespace Meadow.Foundation.Grove.Relays +{ + internal partial class Stm32Expander + { + /// + /// Pin definitions for the Grove 4-ChannelSpdtRelay + /// + public class PinDefinitions : IPinDefinitions + { + /// + /// The controller for the pins + /// + public IPinController Controller { get; set; } + + /// + /// List of pins + /// + public IList AllPins { get; } = new List(); + + /// + /// Pin SW1 + /// + public IPin SW1 => new Pin( + Controller, + "SW1", (byte)0x01, + new List { + new DigitalChannelInfo("SW1"), + } + ); + + /// + /// Pin SW2 + /// + public IPin SW2 => new Pin( + Controller, + "SW2", (byte)0x02, + new List { + new DigitalChannelInfo("SW2"), + } + ); + + /// + /// Pin SW3 + /// + public IPin SW3 => new Pin( + Controller, + "SW3", (byte)0x04, + new List { + new DigitalChannelInfo("SW3"), + } + ); + + /// + /// Pin SW4 + /// + public IPin SW4 => new Pin( + Controller, + "SW4", (byte)0x08, + new List { + new DigitalChannelInfo("SW4"), + } + ); + + /// + /// Create a new PinDefinitions object + /// + public PinDefinitions(Stm32Expander controller) + { + Controller = controller; + InitAllPins(); + } + + /// + /// Initialize all pins + /// + protected void InitAllPins() + { + // add all our pins to the collection + AllPins.Add(SW1); + AllPins.Add(SW2); + AllPins.Add(SW3); + AllPins.Add(SW4); + } + + /// + /// Get Pins + /// + /// IEnumerator of IPin with all pins + public IEnumerator GetEnumerator() => AllPins.GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } + } +} \ No newline at end of file diff --git a/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.cs b/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.cs new file mode 100644 index 00000000..618f1433 --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Driver/Stm32Expander/Stm32Expander.cs @@ -0,0 +1,151 @@ +using Meadow.Hardware; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Meadow.Foundation.Grove.Relays +{ + internal partial class Stm32Expander : IDigitalOutputController, II2cPeripheral + { + /// + /// Four Channel Spdt Relay pin definitions + /// + public PinDefinitions Pins { get; } + + /// + /// The number of IO pins available on the device + /// + public int NumberOfPins { get; } = 4; + + /// + public byte DefaultI2cAddress => 0x12; + + /// + /// The I2C Communications object + /// + protected II2cCommunications i2CCommunications; + + private readonly List pinsInUse = new(); + + private byte relayStates = 0x00; + + /// + /// Creates a new FourChannelSpdtRelay Stm32Expander driver + /// + /// The I2C bus the peripheral is connected to + /// The bus address of the peripheral + public Stm32Expander(II2cBus i2cBus, byte address = 0x11) + { + i2CCommunications = new I2cCommunications(i2cBus, address); + + Pins = new PinDefinitions(this) + { + Controller = this + }; + } + + /// + /// Get the firmware version + /// + /// The firmware version as a byte + public byte GetFirmwareVersion() + { + return i2CCommunications.ReadRegister(READ_FIRMWARE_VERSION); + } + + /// + /// Set a new I2C address + /// + /// + public void SetI2cAddress(byte address) + { + i2CCommunications.WriteRegister(SAVE_I2C_ADDRESS, address); + i2CCommunications = new I2cCommunications(i2CCommunications.Bus, address); + } + + /// + public IDigitalOutputPort CreateDigitalOutputPort(IPin pin, bool initialState = false, OutputType initialOutputType = OutputType.PushPull) + { + if (IsValidPin(pin)) + { + lock (pinsInUse) + { + if (pinsInUse.Contains(pin)) + { + throw new PortInUseException($"{GetType().Name} pin {pin.Name} is already in use"); + } + var port = new DigitalOutputPort(this, pin, initialState); + + pinsInUse.Add(pin); + + port.Disposed += (s, e) => + { + lock (pinsInUse) + { + pinsInUse.Remove(pin); + } + }; + + return port; + } + } + + throw new Exception("Pin is out of range"); + } + + /// + protected IPin GetPin(string pinName) + { + return Pins.AllPins.FirstOrDefault(p => p.Name == pinName || p.Key.ToString() == p.Name); + } + + /// + /// Checks if a pin exists on the 4-Channel SPDT Relay + /// + protected bool IsValidPin(IPin pin) => Pins.AllPins.Contains(pin); + + /// + /// Convenience method to turn all outputs off + /// + public void SetAllOff() + { + i2CCommunications.WriteRegister(CHANNEL_CONTROL, relayStates = 0x00); + } + + /// + /// Convenience method to turn all outputs on + /// + public void SetAllOn() + { + i2CCommunications.WriteRegister(CHANNEL_CONTROL, relayStates = 0x0F); + } + + /// + /// Retrieves the state of a pin + /// + /// The pin to query + protected bool GetPinState(IPin pin) + { + return true; + } + + /// + /// Sets the state of a pin + /// + /// The pin to update + /// True to set the pin state high, False to set it low + protected void SetPinState(IPin pin, bool state) + { + if (state) + { + relayStates |= (byte)pin.Key; + } + else + { + relayStates &= (byte)~(byte)pin.Key; + } + + i2CCommunications.WriteRegister(CHANNEL_CONTROL, relayStates); + } + } +} \ No newline at end of file diff --git a/Source/4-ChannelSpdtRelay/Sample/4-ChannelSpdtRelay_Sample/4-ChannelSpdtRelay_Sample.csproj b/Source/4-ChannelSpdtRelay/Sample/4-ChannelSpdtRelay_Sample/4-ChannelSpdtRelay_Sample.csproj new file mode 100644 index 00000000..9723d21e --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Sample/4-ChannelSpdtRelay_Sample/4-ChannelSpdtRelay_Sample.csproj @@ -0,0 +1,12 @@ + + + netstandard2.1 + true + Library + App + + + + + + diff --git a/Source/4-ChannelSpdtRelay/Sample/4-ChannelSpdtRelay_Sample/MeadowApp.cs b/Source/4-ChannelSpdtRelay/Sample/4-ChannelSpdtRelay_Sample/MeadowApp.cs new file mode 100644 index 00000000..61f32089 --- /dev/null +++ b/Source/4-ChannelSpdtRelay/Sample/4-ChannelSpdtRelay_Sample/MeadowApp.cs @@ -0,0 +1,60 @@ +using Meadow; +using Meadow.Devices; +using Meadow.Foundation.Grove.Relays; +using System.Threading; +using System.Threading.Tasks; +using static Meadow.Foundation.Grove.Relays.FourChannelSpdtRelay; + +namespace Grove.FourChannelSpdtRelay_Sample +{ + // Change F7FeatherV2 to F7FeatherV1 for V1.x boards + public class MeadowApp : App + { + // + + FourChannelSpdtRelay module; + + public override Task Initialize() + { + Resolver.Log.Info("Initializing ..."); + + module = new FourChannelSpdtRelay(Device.CreateI2cBus(), 0x11); + + return Task.CompletedTask; + } + + public override Task Run() + { + for (int i = 0; i < 5; i++) + { + Resolver.Log.Info("All on"); + module.SetAllOn(); + + Thread.Sleep(1000); + + Resolver.Log.Info("All off"); + module.SetAllOff(); + + Thread.Sleep(1000); + + for (int j = 0; j < 4; j++) + { + Resolver.Log.Info($"{(RelayIndex)j} on"); + module.Relays[j].IsOn = true; + Thread.Sleep(1000); + } + + for (int j = 0; j < 4; j++) + { + Resolver.Log.Info($"{(RelayIndex)j} off"); + module.Relays[j].IsOn = false; + Thread.Sleep(1000); + } + } + + return Task.CompletedTask; + } + + // + } +} \ No newline at end of file diff --git a/Source/4-DigitDisplay/Driver/4-DigitDisplay.cs b/Source/4-DigitDisplay/Driver/4-DigitDisplay.cs index 06cc1260..a895bac4 100644 --- a/Source/4-DigitDisplay/Driver/4-DigitDisplay.cs +++ b/Source/4-DigitDisplay/Driver/4-DigitDisplay.cs @@ -11,11 +11,10 @@ public class FourDigitDisplay : Tm1637 /// /// Creates a new FourDigitDisplay driver /// - /// /// /// - public FourDigitDisplay(IMeadowDevice device, IPin pinClock, IPin pinData) - : base(device, pinClock, pinData) + public FourDigitDisplay(IPin pinClock, IPin pinData) + : base(pinClock, pinData) { } } } \ No newline at end of file diff --git a/Source/4-DigitDisplay/Driver/4-DigitDisplay.csproj b/Source/4-DigitDisplay/Driver/4-DigitDisplay.csproj index fcc5afb7..a20e62f5 100644 --- a/Source/4-DigitDisplay/Driver/4-DigitDisplay.csproj +++ b/Source/4-DigitDisplay/Driver/4-DigitDisplay.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/4-DigitDisplay/Driver/Readme.md b/Source/4-DigitDisplay/Driver/Readme.md index 80d2fbf1..d6c6b077 100644 --- a/Source/4-DigitDisplay/Driver/Readme.md +++ b/Source/4-DigitDisplay/Driver/Readme.md @@ -17,13 +17,12 @@ FourDigitDisplay display; public override Task Initialize() { - Console.WriteLine("Initializing ..."); + Resolver.Log.Info("Initializing ..."); display = new FourDigitDisplay( - device: Device, pinClock: Device.Pins.D02, - pinData: Device.Pins.D01) - { + pinData: Device.Pins.D01) + { Brightness = 7, ScreenOn = true }; diff --git a/Source/4-DigitDisplay/Sample/4-DigitDisplay_Sample/4-DigitDisplay_Sample.csproj b/Source/4-DigitDisplay/Sample/4-DigitDisplay_Sample/4-DigitDisplay_Sample.csproj index 81ac1455..77407514 100644 --- a/Source/4-DigitDisplay/Sample/4-DigitDisplay_Sample/4-DigitDisplay_Sample.csproj +++ b/Source/4-DigitDisplay/Sample/4-DigitDisplay_Sample/4-DigitDisplay_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/4-DigitDisplay/Sample/4-DigitDisplay_Sample/MeadowApp.cs b/Source/4-DigitDisplay/Sample/4-DigitDisplay_Sample/MeadowApp.cs index 6e50b559..0aea1829 100644 --- a/Source/4-DigitDisplay/Sample/4-DigitDisplay_Sample/MeadowApp.cs +++ b/Source/4-DigitDisplay/Sample/4-DigitDisplay_Sample/MeadowApp.cs @@ -2,7 +2,6 @@ using Meadow.Devices; using Meadow.Foundation.Displays; using Meadow.Foundation.Grove.Displays; -using System; using System.Threading.Tasks; namespace Grove.FourDigitDisplay_Sample @@ -16,13 +15,12 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initializing ..."); + Resolver.Log.Info("Initializing ..."); display = new FourDigitDisplay( - device: Device, pinClock: Device.Pins.D02, - pinData: Device.Pins.D01) - { + pinData: Device.Pins.D01) + { Brightness = 7, ScreenOn = true }; diff --git a/Source/Button/Driver/Button.csproj b/Source/Button/Driver/Button.csproj index 8e8cfe9a..a9dbfabd 100644 --- a/Source/Button/Driver/Button.csproj +++ b/Source/Button/Driver/Button.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/Button/Driver/Readme.md b/Source/Button/Driver/Readme.md index 0c56362b..ad541783 100644 --- a/Source/Button/Driver/Readme.md +++ b/Source/Button/Driver/Readme.md @@ -17,16 +17,16 @@ Button button; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); button = new Button(Device.Pins.D13) { LongClickedThreshold = TimeSpan.FromMilliseconds(1500) }; - button.Clicked += (s, e) => Console.WriteLine("Grove Button clicked"); + button.Clicked += (s, e) => Resolver.Log.Info("Grove Button clicked"); - button.LongClicked += (s, e) => Console.WriteLine("Grove Button long clicked"); + button.LongClicked += (s, e) => Resolver.Log.Info("Grove Button long clicked"); return Task.CompletedTask; } diff --git a/Source/Button/Sample/Button_Sample/Button_Sample.csproj b/Source/Button/Sample/Button_Sample/Button_Sample.csproj index 29349de8..b5a83958 100644 --- a/Source/Button/Sample/Button_Sample/Button_Sample.csproj +++ b/Source/Button/Sample/Button_Sample/Button_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/Button/Sample/Button_Sample/MeadowApp.cs b/Source/Button/Sample/Button_Sample/MeadowApp.cs index 4d5308bd..f8888920 100644 --- a/Source/Button/Sample/Button_Sample/MeadowApp.cs +++ b/Source/Button/Sample/Button_Sample/MeadowApp.cs @@ -15,16 +15,16 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); button = new Button(Device.Pins.D13) { LongClickedThreshold = TimeSpan.FromMilliseconds(1500) }; - button.Clicked += (s, e) => Console.WriteLine("Grove Button clicked"); + button.Clicked += (s, e) => Resolver.Log.Info("Grove Button clicked"); - button.LongClicked += (s, e) => Console.WriteLine("Grove Button long clicked"); + button.LongClicked += (s, e) => Resolver.Log.Info("Grove Button long clicked"); return Task.CompletedTask; } diff --git a/Source/Buzzer/Driver/Buzzer.csproj b/Source/Buzzer/Driver/Buzzer.csproj index 559886ef..70bcfc19 100644 --- a/Source/Buzzer/Driver/Buzzer.csproj +++ b/Source/Buzzer/Driver/Buzzer.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/Buzzer/Driver/Readme.md b/Source/Buzzer/Driver/Readme.md index 134ac8bc..038b76a8 100644 --- a/Source/Buzzer/Driver/Readme.md +++ b/Source/Buzzer/Driver/Readme.md @@ -17,7 +17,7 @@ Buzzer buzzer; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); buzzer = new Buzzer(Device.Pins.D13); @@ -28,7 +28,7 @@ public override async Task Run() { for (int i = 0; i < 5; i++) { - Console.WriteLine("Playing A major triad starting at A4"); + Resolver.Log.Info("Playing A major triad starting at A4"); await buzzer.PlayTone(new Frequency(440, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //A await buzzer.PlayTone(new Frequency(554.37f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //C# await buzzer.PlayTone(new Frequency(659.25f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //E diff --git a/Source/Buzzer/Sample/Buzzer_Sample/Buzzer_Sample.csproj b/Source/Buzzer/Sample/Buzzer_Sample/Buzzer_Sample.csproj index 8f372c93..210b5119 100644 --- a/Source/Buzzer/Sample/Buzzer_Sample/Buzzer_Sample.csproj +++ b/Source/Buzzer/Sample/Buzzer_Sample/Buzzer_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/Buzzer/Sample/Buzzer_Sample/MeadowApp.cs b/Source/Buzzer/Sample/Buzzer_Sample/MeadowApp.cs index 15dd3261..b076ef53 100644 --- a/Source/Buzzer/Sample/Buzzer_Sample/MeadowApp.cs +++ b/Source/Buzzer/Sample/Buzzer_Sample/MeadowApp.cs @@ -16,7 +16,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); buzzer = new Buzzer(Device.Pins.D13); @@ -27,7 +27,7 @@ public override async Task Run() { for (int i = 0; i < 5; i++) { - Console.WriteLine("Playing A major triad starting at A4"); + Resolver.Log.Info("Playing A major triad starting at A4"); await buzzer.PlayTone(new Frequency(440, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //A await buzzer.PlayTone(new Frequency(554.37f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //C# await buzzer.PlayTone(new Frequency(659.25f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //E diff --git a/Source/FlameSensor/Driver/FlameSensor.csproj b/Source/FlameSensor/Driver/FlameSensor.csproj index 4608eff9..9e2370fb 100644 --- a/Source/FlameSensor/Driver/FlameSensor.csproj +++ b/Source/FlameSensor/Driver/FlameSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/FlameSensor/Driver/Readme.md b/Source/FlameSensor/Driver/Readme.md index 3e87507f..fa308a69 100644 --- a/Source/FlameSensor/Driver/Readme.md +++ b/Source/FlameSensor/Driver/Readme.md @@ -17,13 +17,13 @@ FlameSensor flameSensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); flameSensor = new FlameSensor(Device.Pins.D13); flameSensor.FlameDetected += (s, e) => { - Console.WriteLine($"fire detected: {e}"); + Resolver.Log.Info($"fire detected: {e}"); }; return Task.CompletedTask; diff --git a/Source/FlameSensor/Sample/FlameSensor_Sample/FlameSensor_Sample.csproj b/Source/FlameSensor/Sample/FlameSensor_Sample/FlameSensor_Sample.csproj index ba682977..86e8586d 100644 --- a/Source/FlameSensor/Sample/FlameSensor_Sample/FlameSensor_Sample.csproj +++ b/Source/FlameSensor/Sample/FlameSensor_Sample/FlameSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/FlameSensor/Sample/FlameSensor_Sample/MeadowApp.cs b/Source/FlameSensor/Sample/FlameSensor_Sample/MeadowApp.cs index 66560722..8a63022b 100644 --- a/Source/FlameSensor/Sample/FlameSensor_Sample/MeadowApp.cs +++ b/Source/FlameSensor/Sample/FlameSensor_Sample/MeadowApp.cs @@ -15,13 +15,13 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); flameSensor = new FlameSensor(Device.Pins.D13); flameSensor.FlameDetected += (s, e) => { - Console.WriteLine($"fire detected: {e}"); + Resolver.Log.Info($"fire detected: {e}"); }; return Task.CompletedTask; diff --git a/Source/Grove.sln b/Source/Grove.sln index 6e10e365..412a930b 100644 --- a/Source/Grove.sln +++ b/Source/Grove.sln @@ -267,6 +267,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OLEDDisplay1_12inch", "OLED EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OLEDDisplay1_12inch_Sample", "OLEDDisplay1_12inch\Sample\OLEDDisplay1_12inch_Sample\OLEDDisplay1_12inch_Sample.csproj", "{6E5F9572-4A9E-434A-8FBA-F666A1BFD3FD}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4-ChannelSpdtRelay", "4-ChannelSpdtRelay", "{CFEB0449-4B3E-41C2-83A9-99D0FA5C22EC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{F2452A20-B901-499C-9B30-65BE39FCCF10}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "4-ChannelSpdtRelay", "4-ChannelSpdtRelay\Driver\4-ChannelSpdtRelay.csproj", "{BBBD136F-8AB1-475A-B5DC-3CDB3D7C0402}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "4-ChannelSpdtRelay_Sample", "4-ChannelSpdtRelay\Sample\4-ChannelSpdtRelay_Sample\4-ChannelSpdtRelay_Sample.csproj", "{3D954EBE-50AB-439C-90FE-3FEC0A5D6039}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -665,6 +673,18 @@ Global {6E5F9572-4A9E-434A-8FBA-F666A1BFD3FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {6E5F9572-4A9E-434A-8FBA-F666A1BFD3FD}.Release|Any CPU.Build.0 = Release|Any CPU {6E5F9572-4A9E-434A-8FBA-F666A1BFD3FD}.Release|Any CPU.Deploy.0 = Release|Any CPU + {BBBD136F-8AB1-475A-B5DC-3CDB3D7C0402}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BBBD136F-8AB1-475A-B5DC-3CDB3D7C0402}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BBBD136F-8AB1-475A-B5DC-3CDB3D7C0402}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {BBBD136F-8AB1-475A-B5DC-3CDB3D7C0402}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BBBD136F-8AB1-475A-B5DC-3CDB3D7C0402}.Release|Any CPU.Build.0 = Release|Any CPU + {BBBD136F-8AB1-475A-B5DC-3CDB3D7C0402}.Release|Any CPU.Deploy.0 = Release|Any CPU + {3D954EBE-50AB-439C-90FE-3FEC0A5D6039}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D954EBE-50AB-439C-90FE-3FEC0A5D6039}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3D954EBE-50AB-439C-90FE-3FEC0A5D6039}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {3D954EBE-50AB-439C-90FE-3FEC0A5D6039}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D954EBE-50AB-439C-90FE-3FEC0A5D6039}.Release|Any CPU.Build.0 = Release|Any CPU + {3D954EBE-50AB-439C-90FE-3FEC0A5D6039}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -769,6 +789,9 @@ Global {42494A24-65BE-4484-B7A2-B8C7065F8DB0} = {7826F802-2845-4B70-83F1-B9BC1E276CE1} {899477AF-5FD3-41DE-960A-DE0DD335A781} = {7826F802-2845-4B70-83F1-B9BC1E276CE1} {6E5F9572-4A9E-434A-8FBA-F666A1BFD3FD} = {42494A24-65BE-4484-B7A2-B8C7065F8DB0} + {F2452A20-B901-499C-9B30-65BE39FCCF10} = {CFEB0449-4B3E-41C2-83A9-99D0FA5C22EC} + {BBBD136F-8AB1-475A-B5DC-3CDB3D7C0402} = {CFEB0449-4B3E-41C2-83A9-99D0FA5C22EC} + {3D954EBE-50AB-439C-90FE-3FEC0A5D6039} = {F2452A20-B901-499C-9B30-65BE39FCCF10} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {803C75D4-CF94-4881-BC4C-7CBE9D272949} diff --git a/Source/LCD/Driver/LCD.csproj b/Source/LCD/Driver/LCD.csproj index e764871d..cb9521dc 100644 --- a/Source/LCD/Driver/LCD.csproj +++ b/Source/LCD/Driver/LCD.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/LCD/Driver/Readme.md b/Source/LCD/Driver/Readme.md index 78e1e986..2e359433 100644 --- a/Source/LCD/Driver/Readme.md +++ b/Source/LCD/Driver/Readme.md @@ -17,7 +17,7 @@ LCD display; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); display = new LCD(Device.CreateI2cBus()); diff --git a/Source/LCD/Samples/LCD_Sample/LCD_Sample.csproj b/Source/LCD/Samples/LCD_Sample/LCD_Sample.csproj index 74c00dfb..2acc9645 100644 --- a/Source/LCD/Samples/LCD_Sample/LCD_Sample.csproj +++ b/Source/LCD/Samples/LCD_Sample/LCD_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/LCD/Samples/LCD_Sample/MeadowApp.cs b/Source/LCD/Samples/LCD_Sample/MeadowApp.cs index fd88159a..fbe451db 100644 --- a/Source/LCD/Samples/LCD_Sample/MeadowApp.cs +++ b/Source/LCD/Samples/LCD_Sample/MeadowApp.cs @@ -16,7 +16,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); display = new LCD(Device.CreateI2cBus()); diff --git a/Source/LEDButton/Driver/LEDButton.csproj b/Source/LEDButton/Driver/LEDButton.csproj index c6f1d377..bafb829c 100644 --- a/Source/LEDButton/Driver/LEDButton.csproj +++ b/Source/LEDButton/Driver/LEDButton.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/LEDButton/Driver/Readme.md b/Source/LEDButton/Driver/Readme.md index 7b82d018..57ba6768 100644 --- a/Source/LEDButton/Driver/Readme.md +++ b/Source/LEDButton/Driver/Readme.md @@ -17,7 +17,7 @@ LEDButton ledButton; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); ledButton = new LEDButton(buttonPin: Device.Pins.D12, ledPin: Device.Pins.D13); @@ -25,13 +25,13 @@ public override Task Initialize() ledButton.Clicked += (s, e) => { - Console.WriteLine("Grove Button clicked"); + Resolver.Log.Info("Grove Button clicked"); ledButton.IsLedOn = !ledButton.IsLedOn; }; ledButton.LongClicked += (s, e) => { - Console.WriteLine("Grove Button long clicked"); + Resolver.Log.Info("Grove Button long clicked"); }; return Task.CompletedTask; diff --git a/Source/LEDButton/Sample/LEDButton_Sample/LEDButton_Sample.csproj b/Source/LEDButton/Sample/LEDButton_Sample/LEDButton_Sample.csproj index c6a379ed..15b06bbd 100644 --- a/Source/LEDButton/Sample/LEDButton_Sample/LEDButton_Sample.csproj +++ b/Source/LEDButton/Sample/LEDButton_Sample/LEDButton_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/LEDButton/Sample/LEDButton_Sample/MeadowApp.cs b/Source/LEDButton/Sample/LEDButton_Sample/MeadowApp.cs index c294ffc5..4e421db8 100644 --- a/Source/LEDButton/Sample/LEDButton_Sample/MeadowApp.cs +++ b/Source/LEDButton/Sample/LEDButton_Sample/MeadowApp.cs @@ -15,7 +15,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); ledButton = new LEDButton(buttonPin: Device.Pins.D12, ledPin: Device.Pins.D13); @@ -23,13 +23,13 @@ public override Task Initialize() ledButton.Clicked += (s, e) => { - Console.WriteLine("Grove Button clicked"); + Resolver.Log.Info("Grove Button clicked"); ledButton.IsLedOn = !ledButton.IsLedOn; }; ledButton.LongClicked += (s, e) => { - Console.WriteLine("Grove Button long clicked"); + Resolver.Log.Info("Grove Button long clicked"); }; return Task.CompletedTask; diff --git a/Source/LEDSocket/Driver/LEDSocket.csproj b/Source/LEDSocket/Driver/LEDSocket.csproj index 012ffb58..937a5383 100644 --- a/Source/LEDSocket/Driver/LEDSocket.csproj +++ b/Source/LEDSocket/Driver/LEDSocket.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/LEDSocket/Driver/Readme.md b/Source/LEDSocket/Driver/Readme.md index aa0b9a83..3d802568 100644 --- a/Source/LEDSocket/Driver/Readme.md +++ b/Source/LEDSocket/Driver/Readme.md @@ -17,7 +17,7 @@ LEDSocket led; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); led = new LEDSocket(Device.Pins.D13); diff --git a/Source/LEDSocket/Sample/LEDSocket_Sample/LEDSocket_Sample.csproj b/Source/LEDSocket/Sample/LEDSocket_Sample/LEDSocket_Sample.csproj index 3c3b93bd..65b71c45 100644 --- a/Source/LEDSocket/Sample/LEDSocket_Sample/LEDSocket_Sample.csproj +++ b/Source/LEDSocket/Sample/LEDSocket_Sample/LEDSocket_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/LEDSocket/Sample/LEDSocket_Sample/MeadowApp.cs b/Source/LEDSocket/Sample/LEDSocket_Sample/MeadowApp.cs index f0869f53..0ac519de 100644 --- a/Source/LEDSocket/Sample/LEDSocket_Sample/MeadowApp.cs +++ b/Source/LEDSocket/Sample/LEDSocket_Sample/MeadowApp.cs @@ -15,7 +15,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); led = new LEDSocket(Device.Pins.D13); diff --git a/Source/LightSensor/Driver/LightSensor.cs b/Source/LightSensor/Driver/LightSensor.cs index b58d2225..ba8c9a0e 100644 --- a/Source/LightSensor/Driver/LightSensor.cs +++ b/Source/LightSensor/Driver/LightSensor.cs @@ -21,13 +21,13 @@ public LightSensor(IAnalogInputPort port) : base(port) /// Creates a new LightSensor driver /// public LightSensor( - IPin pin, - int sampleCount = 5, - TimeSpan? sampleInterval = null, + IPin pin, + int sampleCount = 5, + TimeSpan? sampleInterval = null, Voltage? voltage = null) - : this (pin.CreateAnalogInputPort( - sampleCount, - sampleInterval ?? TimeSpan.FromMilliseconds(40), + : this(pin.CreateAnalogInputPort( + sampleCount, + sampleInterval ?? TimeSpan.FromMilliseconds(40), voltage ?? new Voltage(3.3))) { } } diff --git a/Source/LightSensor/Driver/LightSensor.csproj b/Source/LightSensor/Driver/LightSensor.csproj index 67cd7d9d..6b5488de 100644 --- a/Source/LightSensor/Driver/LightSensor.csproj +++ b/Source/LightSensor/Driver/LightSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/LightSensor/Driver/Readme.md b/Source/LightSensor/Driver/Readme.md index 1777360f..4b4bc9f7 100644 --- a/Source/LightSensor/Driver/Readme.md +++ b/Source/LightSensor/Driver/Readme.md @@ -17,12 +17,12 @@ LightSensor sensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new LightSensor(Device.Pins.A01); var consumer = LightSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -34,9 +34,9 @@ public override Task Initialize() sensor.Subscribe(consumer); - sensor.Updated += (sender, result) => + sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -45,7 +45,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/LightSensor/Sample/LightSensor_Sample/LightSensor_Sample.csproj b/Source/LightSensor/Sample/LightSensor_Sample/LightSensor_Sample.csproj index e949e9d5..1711897b 100644 --- a/Source/LightSensor/Sample/LightSensor_Sample/LightSensor_Sample.csproj +++ b/Source/LightSensor/Sample/LightSensor_Sample/LightSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/LightSensor/Sample/LightSensor_Sample/MeadowApp.cs b/Source/LightSensor/Sample/LightSensor_Sample/MeadowApp.cs index 296c3b9e..8620e76c 100644 --- a/Source/LightSensor/Sample/LightSensor_Sample/MeadowApp.cs +++ b/Source/LightSensor/Sample/LightSensor_Sample/MeadowApp.cs @@ -15,12 +15,12 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new LightSensor(Device.Pins.A01); var consumer = LightSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -32,9 +32,9 @@ public override Task Initialize() sensor.Subscribe(consumer); - sensor.Updated += (sender, result) => + sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -43,7 +43,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/LineFinder/Driver/LineFinder.cs b/Source/LineFinder/Driver/LineFinder.cs index f281e274..ed74f173 100644 --- a/Source/LineFinder/Driver/LineFinder.cs +++ b/Source/LineFinder/Driver/LineFinder.cs @@ -8,7 +8,7 @@ namespace Meadow.Foundation.Grove.Sensors.Light /// public class LineFinder { - IDigitalInputPort inputPort; + readonly IDigitalInputPort inputPort; /// /// Returns Line Color diff --git a/Source/LineFinder/Driver/LineFinder.csproj b/Source/LineFinder/Driver/LineFinder.csproj index 9f36e7f1..eb86a695 100644 --- a/Source/LineFinder/Driver/LineFinder.csproj +++ b/Source/LineFinder/Driver/LineFinder.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/LineFinder/Driver/Readme.md b/Source/LineFinder/Driver/Readme.md index def4d8d4..ae5a7a09 100644 --- a/Source/LineFinder/Driver/Readme.md +++ b/Source/LineFinder/Driver/Readme.md @@ -15,13 +15,13 @@ To view all Wilderness Labs open-source projects, including samples, visit [gith ```csharp public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); var lineFinder = new LineFinder(Device.Pins.D13); lineFinder.ColorChanged += (s, e) => { - Console.WriteLine($"line color: {e}"); + Resolver.Log.Info($"line color: {e}"); }; return Task.CompletedTask; diff --git a/Source/LineFinder/Sample/LineFinder_Sample/LineFinder_Sample.csproj b/Source/LineFinder/Sample/LineFinder_Sample/LineFinder_Sample.csproj index 699c0dc7..59eecd69 100644 --- a/Source/LineFinder/Sample/LineFinder_Sample/LineFinder_Sample.csproj +++ b/Source/LineFinder/Sample/LineFinder_Sample/LineFinder_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/LineFinder/Sample/LineFinder_Sample/MeadowApp.cs b/Source/LineFinder/Sample/LineFinder_Sample/MeadowApp.cs index 5e62c9ce..107f6af1 100644 --- a/Source/LineFinder/Sample/LineFinder_Sample/MeadowApp.cs +++ b/Source/LineFinder/Sample/LineFinder_Sample/MeadowApp.cs @@ -13,13 +13,13 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); var lineFinder = new LineFinder(Device.Pins.D13); lineFinder.ColorChanged += (s, e) => { - Console.WriteLine($"line color: {e}"); + Resolver.Log.Info($"line color: {e}"); }; return Task.CompletedTask; diff --git a/Source/LoudnessSensor/Driver/LoudnessSensor.cs b/Source/LoudnessSensor/Driver/LoudnessSensor.cs index 3efa3c60..c034d31f 100644 --- a/Source/LoudnessSensor/Driver/LoudnessSensor.cs +++ b/Source/LoudnessSensor/Driver/LoudnessSensor.cs @@ -22,13 +22,13 @@ public LoudnessSensor(IAnalogInputPort port) : base(port) /// /// AnalogChannel connected to the sensor. public LoudnessSensor( - IPin pin, - int sampleCount = 5, - TimeSpan? sampleInterval = null, + IPin pin, + int sampleCount = 5, + TimeSpan? sampleInterval = null, Voltage? voltage = null) : this(pin.CreateAnalogInputPort( - sampleCount, - sampleInterval ?? TimeSpan.FromMilliseconds(40), + sampleCount, + sampleInterval ?? TimeSpan.FromMilliseconds(40), voltage ?? new Voltage(3.3))) { } } diff --git a/Source/LoudnessSensor/Driver/LoudnessSensor.csproj b/Source/LoudnessSensor/Driver/LoudnessSensor.csproj index 78ab3dfd..9541064f 100644 --- a/Source/LoudnessSensor/Driver/LoudnessSensor.csproj +++ b/Source/LoudnessSensor/Driver/LoudnessSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/LoudnessSensor/Driver/Readme.md b/Source/LoudnessSensor/Driver/Readme.md index 2cbbc6e0..a4ec49a3 100644 --- a/Source/LoudnessSensor/Driver/Readme.md +++ b/Source/LoudnessSensor/Driver/Readme.md @@ -17,12 +17,12 @@ LoudnessSensor sensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new LoudnessSensor(Device.Pins.A01); var consumer = LoudnessSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -35,7 +35,7 @@ public override Task Initialize() sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -44,7 +44,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/LoudnessSensor/Sample/LoudnessSensor_Sample/LoudnessSensor_Sample.csproj b/Source/LoudnessSensor/Sample/LoudnessSensor_Sample/LoudnessSensor_Sample.csproj index 01722b70..0241d840 100644 --- a/Source/LoudnessSensor/Sample/LoudnessSensor_Sample/LoudnessSensor_Sample.csproj +++ b/Source/LoudnessSensor/Sample/LoudnessSensor_Sample/LoudnessSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/LoudnessSensor/Sample/LoudnessSensor_Sample/MeadowApp.cs b/Source/LoudnessSensor/Sample/LoudnessSensor_Sample/MeadowApp.cs index 72e6b806..14c676d4 100644 --- a/Source/LoudnessSensor/Sample/LoudnessSensor_Sample/MeadowApp.cs +++ b/Source/LoudnessSensor/Sample/LoudnessSensor_Sample/MeadowApp.cs @@ -15,12 +15,12 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new LoudnessSensor(Device.Pins.A01); var consumer = LoudnessSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -33,7 +33,7 @@ public override Task Initialize() sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -42,7 +42,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/MagneticSwitch/Driver/MagneticSwitch.cs b/Source/MagneticSwitch/Driver/MagneticSwitch.cs index 0251c4ee..8be8260c 100644 --- a/Source/MagneticSwitch/Driver/MagneticSwitch.cs +++ b/Source/MagneticSwitch/Driver/MagneticSwitch.cs @@ -10,7 +10,7 @@ namespace Meadow.Foundation.Grove.Sensors.Switches /// public class MagneticSwitch : ISwitch { - IDigitalInputPort port; + readonly IDigitalInputPort port; /// /// Returns the state of the switch diff --git a/Source/MagneticSwitch/Driver/MagneticSwitch.csproj b/Source/MagneticSwitch/Driver/MagneticSwitch.csproj index 8a9735a7..d6b08b93 100644 --- a/Source/MagneticSwitch/Driver/MagneticSwitch.csproj +++ b/Source/MagneticSwitch/Driver/MagneticSwitch.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/MagneticSwitch/Driver/Readme.md b/Source/MagneticSwitch/Driver/Readme.md index e9bcbff0..ef0ce983 100644 --- a/Source/MagneticSwitch/Driver/Readme.md +++ b/Source/MagneticSwitch/Driver/Readme.md @@ -15,13 +15,13 @@ To view all Wilderness Labs open-source projects, including samples, visit [gith ```csharp public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); var magneticSwitch = new MagneticSwitch(Device.Pins.D13); magneticSwitch.Changed += (s, e) => { - Console.WriteLine($"Switched - open {magneticSwitch.IsOn}"); + Resolver.Log.Info($"Switched - open {magneticSwitch.IsOn}"); }; return Task.CompletedTask; diff --git a/Source/MagneticSwitch/Sample/MagneticSwitch_Sample/MagneticSwitch_Sample.csproj b/Source/MagneticSwitch/Sample/MagneticSwitch_Sample/MagneticSwitch_Sample.csproj index a6940f8e..983a98a6 100644 --- a/Source/MagneticSwitch/Sample/MagneticSwitch_Sample/MagneticSwitch_Sample.csproj +++ b/Source/MagneticSwitch/Sample/MagneticSwitch_Sample/MagneticSwitch_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/MagneticSwitch/Sample/MagneticSwitch_Sample/MeadowApp.cs b/Source/MagneticSwitch/Sample/MagneticSwitch_Sample/MeadowApp.cs index 8cf20478..a982b7f8 100644 --- a/Source/MagneticSwitch/Sample/MagneticSwitch_Sample/MeadowApp.cs +++ b/Source/MagneticSwitch/Sample/MagneticSwitch_Sample/MeadowApp.cs @@ -13,13 +13,13 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); var magneticSwitch = new MagneticSwitch(Device.Pins.D13); magneticSwitch.Changed += (s, e) => { - Console.WriteLine($"Switched - open {magneticSwitch.IsOn}"); + Resolver.Log.Info($"Switched - open {magneticSwitch.IsOn}"); }; return Task.CompletedTask; diff --git a/Source/MiniPIRMotionSensor/Driver/MiniPIRMotionSensor.csproj b/Source/MiniPIRMotionSensor/Driver/MiniPIRMotionSensor.csproj index 43b23367..f4cffe4c 100644 --- a/Source/MiniPIRMotionSensor/Driver/MiniPIRMotionSensor.csproj +++ b/Source/MiniPIRMotionSensor/Driver/MiniPIRMotionSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/MiniPIRMotionSensor/Driver/Readme.md b/Source/MiniPIRMotionSensor/Driver/Readme.md index 0f93dc1d..ea736188 100644 --- a/Source/MiniPIRMotionSensor/Driver/Readme.md +++ b/Source/MiniPIRMotionSensor/Driver/Readme.md @@ -23,12 +23,12 @@ public override Task Initialize() miniPIRMotionSensor.OnMotionStart += (sender) => { - Console.WriteLine($"Motion start {DateTime.Now}"); + Resolver.Log.Info($"Motion start {DateTime.Now}"); }; miniPIRMotionSensor.OnMotionEnd += (sender) => { - Console.WriteLine($"Motion end {DateTime.Now}"); + Resolver.Log.Info($"Motion end {DateTime.Now}"); }; return Task.CompletedTask; diff --git a/Source/MiniPIRMotionSensor/Sample/MiniPIRMotionSensor_Sample/MeadowApp.cs b/Source/MiniPIRMotionSensor/Sample/MiniPIRMotionSensor_Sample/MeadowApp.cs index a03227ef..69d57e07 100644 --- a/Source/MiniPIRMotionSensor/Sample/MiniPIRMotionSensor_Sample/MeadowApp.cs +++ b/Source/MiniPIRMotionSensor/Sample/MiniPIRMotionSensor_Sample/MeadowApp.cs @@ -22,12 +22,12 @@ public override Task Initialize() miniPIRMotionSensor.OnMotionStart += (sender) => { - Console.WriteLine($"Motion start {DateTime.Now}"); + Resolver.Log.Info($"Motion start {DateTime.Now}"); }; miniPIRMotionSensor.OnMotionEnd += (sender) => { - Console.WriteLine($"Motion end {DateTime.Now}"); + Resolver.Log.Info($"Motion end {DateTime.Now}"); }; return Task.CompletedTask; diff --git a/Source/MiniPIRMotionSensor/Sample/MiniPIRMotionSensor_Sample/MiniPIRMotionSensor_Sample.csproj b/Source/MiniPIRMotionSensor/Sample/MiniPIRMotionSensor_Sample/MiniPIRMotionSensor_Sample.csproj index daa82f9b..4e974b96 100644 --- a/Source/MiniPIRMotionSensor/Sample/MiniPIRMotionSensor_Sample/MiniPIRMotionSensor_Sample.csproj +++ b/Source/MiniPIRMotionSensor/Sample/MiniPIRMotionSensor_Sample/MiniPIRMotionSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/MoistureSensor/Driver/MoistureSensor.cs b/Source/MoistureSensor/Driver/MoistureSensor.cs index 83bb240a..5177711f 100644 --- a/Source/MoistureSensor/Driver/MoistureSensor.cs +++ b/Source/MoistureSensor/Driver/MoistureSensor.cs @@ -23,13 +23,13 @@ public MoistureSensor(IAnalogInputPort port) /// /// AnalogChannel connected to the sensor. public MoistureSensor( - IPin pin, - int sampleCount = 5, - TimeSpan? sampleInterval = null, + IPin pin, + int sampleCount = 5, + TimeSpan? sampleInterval = null, Voltage? voltage = null) : this(pin.CreateAnalogInputPort( - sampleCount, - sampleInterval ?? TimeSpan.FromMilliseconds(40), + sampleCount, + sampleInterval ?? TimeSpan.FromMilliseconds(40), voltage ?? new Voltage(3.3))) { } } diff --git a/Source/MoistureSensor/Driver/MoistureSensor.csproj b/Source/MoistureSensor/Driver/MoistureSensor.csproj index c2c72cf4..cd5bce6e 100644 --- a/Source/MoistureSensor/Driver/MoistureSensor.csproj +++ b/Source/MoistureSensor/Driver/MoistureSensor.csproj @@ -25,6 +25,6 @@ - + diff --git a/Source/MoistureSensor/Driver/Readme.md b/Source/MoistureSensor/Driver/Readme.md index c88760e4..59c460ee 100644 --- a/Source/MoistureSensor/Driver/Readme.md +++ b/Source/MoistureSensor/Driver/Readme.md @@ -17,12 +17,12 @@ MoistureSensor sensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new MoistureSensor(Device.Pins.A01); var consumer = MoistureSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -34,9 +34,9 @@ public override Task Initialize() sensor.Subscribe(consumer); // classical .NET events can also be used: - sensor.Updated += (sender, result) => + sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -45,7 +45,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/MoistureSensor/Sample/MoistureSensor_Sample/MeadowApp.cs b/Source/MoistureSensor/Sample/MoistureSensor_Sample/MeadowApp.cs index 20c002e1..57881bcf 100644 --- a/Source/MoistureSensor/Sample/MoistureSensor_Sample/MeadowApp.cs +++ b/Source/MoistureSensor/Sample/MoistureSensor_Sample/MeadowApp.cs @@ -15,12 +15,12 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new MoistureSensor(Device.Pins.A01); var consumer = MoistureSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -32,9 +32,9 @@ public override Task Initialize() sensor.Subscribe(consumer); // classical .NET events can also be used: - sensor.Updated += (sender, result) => + sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -43,7 +43,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/MoistureSensor/Sample/MoistureSensor_Sample/MoistureSensor_Sample.csproj b/Source/MoistureSensor/Sample/MoistureSensor_Sample/MoistureSensor_Sample.csproj index 005f35c2..0939f5b8 100644 --- a/Source/MoistureSensor/Sample/MoistureSensor_Sample/MoistureSensor_Sample.csproj +++ b/Source/MoistureSensor/Sample/MoistureSensor_Sample/MoistureSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/OLEDDisplay1_12inch/Driver/OLEDDisplay1_12inch.csproj b/Source/OLEDDisplay1_12inch/Driver/OLEDDisplay1_12inch.csproj index 45f65619..3f5bb332 100644 --- a/Source/OLEDDisplay1_12inch/Driver/OLEDDisplay1_12inch.csproj +++ b/Source/OLEDDisplay1_12inch/Driver/OLEDDisplay1_12inch.csproj @@ -23,7 +23,7 @@ - - + + diff --git a/Source/OLEDDisplay1_12inch/Driver/Readme.md b/Source/OLEDDisplay1_12inch/Driver/Readme.md index beca42a3..3fcce7db 100644 --- a/Source/OLEDDisplay1_12inch/Driver/Readme.md +++ b/Source/OLEDDisplay1_12inch/Driver/Readme.md @@ -18,7 +18,7 @@ MicroGraphics graphics; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); display = new OLEDDisplay1_12inch(Device.CreateI2cBus(), OLEDDisplayVersion.Version3x); diff --git a/Source/OLEDDisplay1_12inch/Sample/OLEDDisplay1_12inch_Sample/MeadowApp.cs b/Source/OLEDDisplay1_12inch/Sample/OLEDDisplay1_12inch_Sample/MeadowApp.cs index dfd74b58..1fc54389 100644 --- a/Source/OLEDDisplay1_12inch/Sample/OLEDDisplay1_12inch_Sample/MeadowApp.cs +++ b/Source/OLEDDisplay1_12inch/Sample/OLEDDisplay1_12inch_Sample/MeadowApp.cs @@ -17,7 +17,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); display = new OLEDDisplay1_12inch(Device.CreateI2cBus(), OLEDDisplayVersion.Version3x); diff --git a/Source/OLEDDisplay1_12inch/Sample/OLEDDisplay1_12inch_Sample/OLEDDisplay1_12inch_Sample.csproj b/Source/OLEDDisplay1_12inch/Sample/OLEDDisplay1_12inch_Sample/OLEDDisplay1_12inch_Sample.csproj index 920dc1bc..2914d716 100644 --- a/Source/OLEDDisplay1_12inch/Sample/OLEDDisplay1_12inch_Sample/OLEDDisplay1_12inch_Sample.csproj +++ b/Source/OLEDDisplay1_12inch/Sample/OLEDDisplay1_12inch_Sample/OLEDDisplay1_12inch_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/PIRMotionSensor/Driver/PIRMotionSensor.csproj b/Source/PIRMotionSensor/Driver/PIRMotionSensor.csproj index 3eb77f3a..f7c931a7 100644 --- a/Source/PIRMotionSensor/Driver/PIRMotionSensor.csproj +++ b/Source/PIRMotionSensor/Driver/PIRMotionSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/PIRMotionSensor/Driver/Readme.md b/Source/PIRMotionSensor/Driver/Readme.md index 15b88660..cab9eea4 100644 --- a/Source/PIRMotionSensor/Driver/Readme.md +++ b/Source/PIRMotionSensor/Driver/Readme.md @@ -25,12 +25,12 @@ public override Task Initialize() motionSensor.OnMotionStart += (sender) => { - Console.WriteLine($"Motion start {DateTime.Now}"); + Resolver.Log.Info($"Motion start {DateTime.Now}"); }; motionSensor.OnMotionEnd += (sender) => { - Console.WriteLine($"Motion end {DateTime.Now}"); + Resolver.Log.Info($"Motion end {DateTime.Now}"); }; return Task.CompletedTask; diff --git a/Source/PIRMotionSensor/Sample/PIRMotionSensor_Sample/MeadowApp.cs b/Source/PIRMotionSensor/Sample/PIRMotionSensor_Sample/MeadowApp.cs index 65761dc8..b9f5db24 100644 --- a/Source/PIRMotionSensor/Sample/PIRMotionSensor_Sample/MeadowApp.cs +++ b/Source/PIRMotionSensor/Sample/PIRMotionSensor_Sample/MeadowApp.cs @@ -24,12 +24,12 @@ public override Task Initialize() motionSensor.OnMotionStart += (sender) => { - Console.WriteLine($"Motion start {DateTime.Now}"); + Resolver.Log.Info($"Motion start {DateTime.Now}"); }; motionSensor.OnMotionEnd += (sender) => { - Console.WriteLine($"Motion end {DateTime.Now}"); + Resolver.Log.Info($"Motion end {DateTime.Now}"); }; return Task.CompletedTask; diff --git a/Source/PIRMotionSensor/Sample/PIRMotionSensor_Sample/PIRMotionSensor_Sample.csproj b/Source/PIRMotionSensor/Sample/PIRMotionSensor_Sample/PIRMotionSensor_Sample.csproj index 88e706b3..15d67748 100644 --- a/Source/PIRMotionSensor/Sample/PIRMotionSensor_Sample/PIRMotionSensor_Sample.csproj +++ b/Source/PIRMotionSensor/Sample/PIRMotionSensor_Sample/PIRMotionSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/RTC/Driver/RTC.csproj b/Source/RTC/Driver/RTC.csproj index a08da4ac..f729a2b0 100644 --- a/Source/RTC/Driver/RTC.csproj +++ b/Source/RTC/Driver/RTC.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/RTC/Driver/Readme.md b/Source/RTC/Driver/Readme.md index 8f974c32..de5c2c4a 100644 --- a/Source/RTC/Driver/Readme.md +++ b/Source/RTC/Driver/Readme.md @@ -17,7 +17,7 @@ RTC rtc; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); rtc = new RTC(Device.CreateI2cBus()); @@ -28,23 +28,23 @@ public override Task Run() { var running = rtc.IsRunning; - Console.WriteLine($"{(running ? "is running" : "is not running")}"); + Resolver.Log.Info($"{(running ? "is running" : "is not running")}"); if (!running) { - Console.WriteLine(" Starting RTC..."); + Resolver.Log.Info(" Starting RTC..."); rtc.IsRunning = true; } var dateTime = rtc.GetTime(); - Console.WriteLine($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}"); + Resolver.Log.Info($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}"); - Console.WriteLine($" Setting RTC to : {dateTime:MM/dd/yy HH:mm:ss}"); + Resolver.Log.Info($" Setting RTC to : {dateTime:MM/dd/yy HH:mm:ss}"); dateTime = new DateTime(2030, 2, 15); rtc.SetTime(dateTime); dateTime = rtc.GetTime(); - Console.WriteLine($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}"); + Resolver.Log.Info($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}"); var rand = new Random(); @@ -55,11 +55,11 @@ public override Task Run() data[i] = (byte)rand.Next(256); } - Console.WriteLine($" Writing to RTC RAM : {BitConverter.ToString(data)}"); + Resolver.Log.Info($" Writing to RTC RAM : {BitConverter.ToString(data)}"); rtc.WriteRAM(0, data); - Console.Write($" Reading from RTC RAM : "); + Resolver.Log.Info($" Reading from RTC RAM : "); data = rtc.ReadRAM(0, 56); - Console.WriteLine(BitConverter.ToString(data)); + Resolver.Log.Info(BitConverter.ToString(data)); return Task.CompletedTask; } diff --git a/Source/RTC/Sample/RTC_Sample/MeadowApp.cs b/Source/RTC/Sample/RTC_Sample/MeadowApp.cs index 489f6ee0..dda63b1f 100644 --- a/Source/RTC/Sample/RTC_Sample/MeadowApp.cs +++ b/Source/RTC/Sample/RTC_Sample/MeadowApp.cs @@ -15,7 +15,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); rtc = new RTC(Device.CreateI2cBus()); @@ -26,23 +26,23 @@ public override Task Run() { var running = rtc.IsRunning; - Console.WriteLine($"{(running ? "is running" : "is not running")}"); + Resolver.Log.Info($"{(running ? "is running" : "is not running")}"); if (!running) { - Console.WriteLine(" Starting RTC..."); + Resolver.Log.Info(" Starting RTC..."); rtc.IsRunning = true; } var dateTime = rtc.GetTime(); - Console.WriteLine($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}"); + Resolver.Log.Info($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}"); - Console.WriteLine($" Setting RTC to : {dateTime:MM/dd/yy HH:mm:ss}"); + Resolver.Log.Info($" Setting RTC to : {dateTime:MM/dd/yy HH:mm:ss}"); dateTime = new DateTime(2030, 2, 15); rtc.SetTime(dateTime); dateTime = rtc.GetTime(); - Console.WriteLine($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}"); + Resolver.Log.Info($" RTC current time is: {dateTime:MM/dd/yy HH:mm:ss}"); var rand = new Random(); @@ -53,11 +53,11 @@ public override Task Run() data[i] = (byte)rand.Next(256); } - Console.WriteLine($" Writing to RTC RAM : {BitConverter.ToString(data)}"); + Resolver.Log.Info($" Writing to RTC RAM : {BitConverter.ToString(data)}"); rtc.WriteRAM(0, data); - Console.Write($" Reading from RTC RAM : "); + Resolver.Log.Info($" Reading from RTC RAM : "); data = rtc.ReadRAM(0, 56); - Console.WriteLine(BitConverter.ToString(data)); + Resolver.Log.Info(BitConverter.ToString(data)); return Task.CompletedTask; } diff --git a/Source/RTC/Sample/RTC_Sample/RTC_Sample.csproj b/Source/RTC/Sample/RTC_Sample/RTC_Sample.csproj index 335808d1..fe1de20b 100644 --- a/Source/RTC/Sample/RTC_Sample/RTC_Sample.csproj +++ b/Source/RTC/Sample/RTC_Sample/RTC_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/Relay/Driver/Readme.md b/Source/Relay/Driver/Readme.md index 8f8f29cf..74ccaade 100644 --- a/Source/Relay/Driver/Readme.md +++ b/Source/Relay/Driver/Readme.md @@ -17,7 +17,7 @@ Relay relay; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); relay = new Relay(Device.Pins.D13); @@ -32,7 +32,7 @@ public override async Task Run() { state = !state; - Console.WriteLine($"- State: {state}"); + Resolver.Log.Info($"- State: {state}"); relay.IsOn = state; await Task.Delay(500); diff --git a/Source/Relay/Driver/Relay.cs b/Source/Relay/Driver/Relay.cs index bf631b6e..64e6cb47 100644 --- a/Source/Relay/Driver/Relay.cs +++ b/Source/Relay/Driver/Relay.cs @@ -19,7 +19,7 @@ public Relay(IDigitalOutputPort port) /// Creates a new Relay driver /// /// - public Relay(IPin pin) + public Relay(IPin pin) : base(pin) { } } diff --git a/Source/Relay/Driver/Relay.csproj b/Source/Relay/Driver/Relay.csproj index ef9b5980..44050d55 100644 --- a/Source/Relay/Driver/Relay.csproj +++ b/Source/Relay/Driver/Relay.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/Relay/Sample/Relay_Sample/MeadowApp.cs b/Source/Relay/Sample/Relay_Sample/MeadowApp.cs index 63e06271..6bb938cf 100644 --- a/Source/Relay/Sample/Relay_Sample/MeadowApp.cs +++ b/Source/Relay/Sample/Relay_Sample/MeadowApp.cs @@ -15,7 +15,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); relay = new Relay(Device.Pins.D13); @@ -30,7 +30,7 @@ public override async Task Run() { state = !state; - Console.WriteLine($"- State: {state}"); + Resolver.Log.Info($"- State: {state}"); relay.IsOn = state; await Task.Delay(500); diff --git a/Source/Relay/Sample/Relay_Sample/Relay_Sample.csproj b/Source/Relay/Sample/Relay_Sample/Relay_Sample.csproj index c5ac423e..3a8cfddc 100644 --- a/Source/Relay/Sample/Relay_Sample/Relay_Sample.csproj +++ b/Source/Relay/Sample/Relay_Sample/Relay_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/RotaryAngleSensor/Driver/Readme.md b/Source/RotaryAngleSensor/Driver/Readme.md index 9bb6e79d..0da0e1af 100644 --- a/Source/RotaryAngleSensor/Driver/Readme.md +++ b/Source/RotaryAngleSensor/Driver/Readme.md @@ -17,12 +17,12 @@ RotaryAngleSensor sensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new RotaryAngleSensor(Device.Pins.A01); var consumer = RotaryAngleSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -33,9 +33,9 @@ public override Task Initialize() }); sensor.Subscribe(consumer); - sensor.Updated += (sender, result) => + sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -44,7 +44,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/RotaryAngleSensor/Driver/RotaryAngleSensor.csproj b/Source/RotaryAngleSensor/Driver/RotaryAngleSensor.csproj index b4a41a30..857eb86a 100644 --- a/Source/RotaryAngleSensor/Driver/RotaryAngleSensor.csproj +++ b/Source/RotaryAngleSensor/Driver/RotaryAngleSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/RotaryAngleSensor/Sample/RotaryAngleSensor_Sample/MeadowApp.cs b/Source/RotaryAngleSensor/Sample/RotaryAngleSensor_Sample/MeadowApp.cs index 1e1c5f84..e8aa978a 100644 --- a/Source/RotaryAngleSensor/Sample/RotaryAngleSensor_Sample/MeadowApp.cs +++ b/Source/RotaryAngleSensor/Sample/RotaryAngleSensor_Sample/MeadowApp.cs @@ -15,12 +15,12 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new RotaryAngleSensor(Device.Pins.A01); var consumer = RotaryAngleSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -31,9 +31,9 @@ public override Task Initialize() }); sensor.Subscribe(consumer); - sensor.Updated += (sender, result) => + sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -42,7 +42,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/RotaryAngleSensor/Sample/RotaryAngleSensor_Sample/RotaryAngleSensor_Sample.csproj b/Source/RotaryAngleSensor/Sample/RotaryAngleSensor_Sample/RotaryAngleSensor_Sample.csproj index 5ce8f694..ab86b3c0 100644 --- a/Source/RotaryAngleSensor/Sample/RotaryAngleSensor_Sample/RotaryAngleSensor_Sample.csproj +++ b/Source/RotaryAngleSensor/Sample/RotaryAngleSensor_Sample/RotaryAngleSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/Servo/Driver/Readme.md b/Source/Servo/Driver/Readme.md index 25b1ebc0..112db5d3 100644 --- a/Source/Servo/Driver/Readme.md +++ b/Source/Servo/Driver/Readme.md @@ -17,7 +17,7 @@ Servo servo; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); servo = new Servo(Device.Pins.D13); @@ -33,16 +33,16 @@ public override async Task Run() for (int i = 0; i <= servo.Config.MaximumAngle.Degrees; i++) { await servo.RotateTo(new Angle(i, AU.Degrees)); - Console.WriteLine($"Rotating to {i}"); + Resolver.Log.Info($"Rotating to {i}"); await Task.Delay(40); } await Task.Delay(2000); - + for (int i = 180; i >= servo.Config.MinimumAngle.Degrees; i--) { await servo.RotateTo(new Angle(i, AU.Degrees)); - Console.WriteLine($"Rotating to {i}"); + Resolver.Log.Info($"Rotating to {i}"); await Task.Delay(40); } diff --git a/Source/Servo/Driver/Servo.csproj b/Source/Servo/Driver/Servo.csproj index 2ecc2c61..f6530734 100644 --- a/Source/Servo/Driver/Servo.csproj +++ b/Source/Servo/Driver/Servo.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/Servo/Sample/Servo_Sample/MeadowApp.cs b/Source/Servo/Sample/Servo_Sample/MeadowApp.cs index 5d7dc4fa..8996e74f 100644 --- a/Source/Servo/Sample/Servo_Sample/MeadowApp.cs +++ b/Source/Servo/Sample/Servo_Sample/MeadowApp.cs @@ -17,7 +17,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); servo = new Servo(Device.Pins.D13); @@ -33,16 +33,16 @@ public override async Task Run() for (int i = 0; i <= servo.Config.MaximumAngle.Degrees; i++) { await servo.RotateTo(new Angle(i, AU.Degrees)); - Console.WriteLine($"Rotating to {i}"); + Resolver.Log.Info($"Rotating to {i}"); await Task.Delay(40); } await Task.Delay(2000); - + for (int i = 180; i >= servo.Config.MinimumAngle.Degrees; i--) { await servo.RotateTo(new Angle(i, AU.Degrees)); - Console.WriteLine($"Rotating to {i}"); + Resolver.Log.Info($"Rotating to {i}"); await Task.Delay(40); } diff --git a/Source/Servo/Sample/Servo_Sample/Servo_Sample.csproj b/Source/Servo/Sample/Servo_Sample/Servo_Sample.csproj index 7350b492..154932a0 100644 --- a/Source/Servo/Sample/Servo_Sample/Servo_Sample.csproj +++ b/Source/Servo/Sample/Servo_Sample/Servo_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/SoundSensor/Driver/Readme.md b/Source/SoundSensor/Driver/Readme.md index 6a119ef3..78e01334 100644 --- a/Source/SoundSensor/Driver/Readme.md +++ b/Source/SoundSensor/Driver/Readme.md @@ -17,13 +17,13 @@ SoundSensor sensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); // configure our sensor sensor = new SoundSensor(Device.Pins.A01); var consumer = SoundSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -36,7 +36,7 @@ public override Task Initialize() sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -45,7 +45,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/SoundSensor/Driver/SoundSensor.csproj b/Source/SoundSensor/Driver/SoundSensor.csproj index 52012ea3..95ca92f8 100644 --- a/Source/SoundSensor/Driver/SoundSensor.csproj +++ b/Source/SoundSensor/Driver/SoundSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/SoundSensor/Sample/SoundSensor_Sample/MeadowApp.cs b/Source/SoundSensor/Sample/SoundSensor_Sample/MeadowApp.cs index f3ed324d..9dd4cd05 100644 --- a/Source/SoundSensor/Sample/SoundSensor_Sample/MeadowApp.cs +++ b/Source/SoundSensor/Sample/SoundSensor_Sample/MeadowApp.cs @@ -15,13 +15,13 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); // configure our sensor sensor = new SoundSensor(Device.Pins.A01); var consumer = SoundSensor.CreateObserver( - handler: result => Console.WriteLine($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), + handler: result => Resolver.Log.Info($"Observer filter satisfied: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"), filter: result => { if (result.Old is { } old) @@ -34,7 +34,7 @@ public override Task Initialize() sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -43,7 +43,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/SoundSensor/Sample/SoundSensor_Sample/SoundSensor_Sample.csproj b/Source/SoundSensor/Sample/SoundSensor_Sample/SoundSensor_Sample.csproj index fb5e7ee0..7ba2d725 100644 --- a/Source/SoundSensor/Sample/SoundSensor_Sample/SoundSensor_Sample.csproj +++ b/Source/SoundSensor/Sample/SoundSensor_Sample/SoundSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/Speaker/Driver/Readme.md b/Source/Speaker/Driver/Readme.md index 0c64a116..64c5268d 100644 --- a/Source/Speaker/Driver/Readme.md +++ b/Source/Speaker/Driver/Readme.md @@ -17,7 +17,7 @@ Speaker speaker; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); speaker = new Speaker(Device.Pins.D13); @@ -28,7 +28,7 @@ public override async Task Run() { for (int i = 0; i < 5; i++) { - Console.WriteLine("Playing A major triad starting at A4"); + Resolver.Log.Info("Playing A major triad starting at A4"); await speaker.PlayTone(new Frequency(440, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //A await speaker.PlayTone(new Frequency(554.37f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //C# await speaker.PlayTone(new Frequency(659.25f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //E diff --git a/Source/Speaker/Driver/Speaker.cs b/Source/Speaker/Driver/Speaker.cs index 1153ad0b..b78daa87 100644 --- a/Source/Speaker/Driver/Speaker.cs +++ b/Source/Speaker/Driver/Speaker.cs @@ -1,8 +1,6 @@ using Meadow.Foundation.Audio; using Meadow.Hardware; using Meadow.Units; -using System; -using System.Threading; namespace Meadow.Foundation.Grove.Audio { diff --git a/Source/Speaker/Driver/Speaker.csproj b/Source/Speaker/Driver/Speaker.csproj index e2fcc324..27760add 100644 --- a/Source/Speaker/Driver/Speaker.csproj +++ b/Source/Speaker/Driver/Speaker.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/Speaker/Sample/Speaker_Sample/MeadowApp.cs b/Source/Speaker/Sample/Speaker_Sample/MeadowApp.cs index c431782e..3354d3fc 100644 --- a/Source/Speaker/Sample/Speaker_Sample/MeadowApp.cs +++ b/Source/Speaker/Sample/Speaker_Sample/MeadowApp.cs @@ -16,7 +16,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); speaker = new Speaker(Device.Pins.D13); @@ -27,7 +27,7 @@ public override async Task Run() { for (int i = 0; i < 5; i++) { - Console.WriteLine("Playing A major triad starting at A4"); + Resolver.Log.Info("Playing A major triad starting at A4"); await speaker.PlayTone(new Frequency(440, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //A await speaker.PlayTone(new Frequency(554.37f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //C# await speaker.PlayTone(new Frequency(659.25f, Frequency.UnitType.Hertz), TimeSpan.FromMilliseconds(500)); //E diff --git a/Source/Speaker/Sample/Speaker_Sample/Speaker_Sample.csproj b/Source/Speaker/Sample/Speaker_Sample/Speaker_Sample.csproj index eff15cd6..9b141202 100644 --- a/Source/Speaker/Sample/Speaker_Sample/Speaker_Sample.csproj +++ b/Source/Speaker/Sample/Speaker_Sample/Speaker_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/SwitchP/Driver/Readme.md b/Source/SwitchP/Driver/Readme.md index 596ab4bd..e3428edf 100644 --- a/Source/SwitchP/Driver/Readme.md +++ b/Source/SwitchP/Driver/Readme.md @@ -17,13 +17,13 @@ SwitchP groveSwitch; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); groveSwitch = new SwitchP(Device.Pins.D13); groveSwitch.Changed += (s, e) => { - Console.WriteLine(groveSwitch.IsOn ? "Switch is High" : "Switch is Low"); + Resolver.Log.Info(groveSwitch.IsOn ? "Switch is High" : "Switch is Low"); }; return Task.CompletedTask; diff --git a/Source/SwitchP/Driver/SwitchP.cs b/Source/SwitchP/Driver/SwitchP.cs index 2c634456..1b07ad48 100644 --- a/Source/SwitchP/Driver/SwitchP.cs +++ b/Source/SwitchP/Driver/SwitchP.cs @@ -13,9 +13,9 @@ public class SwitchP : SpdtSwitch /// Creates a SwitchP driver /// /// - public SwitchP(IPin pin) - : base(pin, - InterruptMode.EdgeBoth, + public SwitchP(IPin pin) + : base(pin, + InterruptMode.EdgeBoth, ResistorMode.InternalPullDown, TimeSpan.FromMilliseconds(20), TimeSpan.Zero) diff --git a/Source/SwitchP/Driver/SwitchP.csproj b/Source/SwitchP/Driver/SwitchP.csproj index 953f8707..3a97e83b 100644 --- a/Source/SwitchP/Driver/SwitchP.csproj +++ b/Source/SwitchP/Driver/SwitchP.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/SwitchP/Sample/SwitchP_Sample/MeadowApp.cs b/Source/SwitchP/Sample/SwitchP_Sample/MeadowApp.cs index 19df5da6..7e5edd92 100644 --- a/Source/SwitchP/Sample/SwitchP_Sample/MeadowApp.cs +++ b/Source/SwitchP/Sample/SwitchP_Sample/MeadowApp.cs @@ -15,13 +15,13 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); groveSwitch = new SwitchP(Device.Pins.D13); groveSwitch.Changed += (s, e) => { - Console.WriteLine(groveSwitch.IsOn ? "Switch is High" : "Switch is Low"); + Resolver.Log.Info(groveSwitch.IsOn ? "Switch is High" : "Switch is Low"); }; return Task.CompletedTask; diff --git a/Source/SwitchP/Sample/SwitchP_Sample/SwitchP_Sample.csproj b/Source/SwitchP/Sample/SwitchP_Sample/SwitchP_Sample.csproj index 26e74445..51695704 100644 --- a/Source/SwitchP/Sample/SwitchP_Sample/SwitchP_Sample.csproj +++ b/Source/SwitchP/Sample/SwitchP_Sample/SwitchP_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/Readme.md b/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/Readme.md index a759b242..72f4db6d 100644 --- a/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/Readme.md +++ b/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/Readme.md @@ -17,14 +17,14 @@ TemperatureHumiditySensor_HighAccuracyMini sensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new TemperatureHumiditySensor_HighAccuracyMini(Device.CreateI2cBus()); var consumer = TemperatureHumiditySensor_HighAccuracyMini.CreateObserver( handler: result => { - Console.WriteLine($"Observer: Temp changed by threshold; new temp: {result.New.Temperature?.Celsius:N2}C, old: {result.Old?.Temperature?.Celsius:N2}C"); + Resolver.Log.Info($"Observer: Temp changed by threshold; new temp: {result.New.Temperature?.Celsius:N2}C, old: {result.Old?.Temperature?.Celsius:N2}C"); }, filter: result => { @@ -41,8 +41,8 @@ public override Task Initialize() sensor.Updated += (sender, result) => { - Console.WriteLine($" Temperature: {result.New.Temperature?.Celsius:N2}C"); - Console.WriteLine($" Relative Humidity: {result.New.Humidity?.Percent:N2}%"); + Resolver.Log.Info($" Temperature: {result.New.Temperature?.Celsius:N2}C"); + Resolver.Log.Info($" Relative Humidity: {result.New.Humidity?.Percent:N2}%"); }; return Task.CompletedTask; diff --git a/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/TemperatureHumiditySensor_HighAccuracyMini.cs b/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/TemperatureHumiditySensor_HighAccuracyMini.cs index 437f6103..2c3ebf5a 100644 --- a/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/TemperatureHumiditySensor_HighAccuracyMini.cs +++ b/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/TemperatureHumiditySensor_HighAccuracyMini.cs @@ -12,7 +12,7 @@ public class TemperatureHumiditySensor_HighAccuracyMini : Th02 /// Creates a TemperatureHumiditySensor_HighAccuracyMini driver /// /// - public TemperatureHumiditySensor_HighAccuracyMini(II2cBus i2cBus) + public TemperatureHumiditySensor_HighAccuracyMini(II2cBus i2cBus) : base(i2cBus, 64) { } } diff --git a/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/TemperatureHumiditySensor_HighAccuracyMini.csproj b/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/TemperatureHumiditySensor_HighAccuracyMini.csproj index fc2324b0..ac6395bb 100644 --- a/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/TemperatureHumiditySensor_HighAccuracyMini.csproj +++ b/Source/TemperatureHumiditySensor_HighAccuracyMini/Driver/TemperatureHumiditySensor_HighAccuracyMini.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/TemperatureHumiditySensor_HighAccuracyMini/Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample/MeadowApp.cs b/Source/TemperatureHumiditySensor_HighAccuracyMini/Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample/MeadowApp.cs index 30ce58f8..acadb161 100644 --- a/Source/TemperatureHumiditySensor_HighAccuracyMini/Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample/MeadowApp.cs +++ b/Source/TemperatureHumiditySensor_HighAccuracyMini/Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample/MeadowApp.cs @@ -15,14 +15,14 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new TemperatureHumiditySensor_HighAccuracyMini(Device.CreateI2cBus()); var consumer = TemperatureHumiditySensor_HighAccuracyMini.CreateObserver( handler: result => { - Console.WriteLine($"Observer: Temp changed by threshold; new temp: {result.New.Temperature?.Celsius:N2}C, old: {result.Old?.Temperature?.Celsius:N2}C"); + Resolver.Log.Info($"Observer: Temp changed by threshold; new temp: {result.New.Temperature?.Celsius:N2}C, old: {result.Old?.Temperature?.Celsius:N2}C"); }, filter: result => { @@ -39,8 +39,8 @@ public override Task Initialize() sensor.Updated += (sender, result) => { - Console.WriteLine($" Temperature: {result.New.Temperature?.Celsius:N2}C"); - Console.WriteLine($" Relative Humidity: {result.New.Humidity?.Percent:N2}%"); + Resolver.Log.Info($" Temperature: {result.New.Temperature?.Celsius:N2}C"); + Resolver.Log.Info($" Relative Humidity: {result.New.Humidity?.Percent:N2}%"); }; return Task.CompletedTask; diff --git a/Source/TemperatureHumiditySensor_HighAccuracyMini/Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample.csproj b/Source/TemperatureHumiditySensor_HighAccuracyMini/Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample.csproj index abe7bad3..ed0e2cde 100644 --- a/Source/TemperatureHumiditySensor_HighAccuracyMini/Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample.csproj +++ b/Source/TemperatureHumiditySensor_HighAccuracyMini/Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample/TemperatureHumiditySensor_HighAccuracyMini_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/TemperatureSensor/Driver/Readme.md b/Source/TemperatureSensor/Driver/Readme.md index e1365f38..a5480bc4 100644 --- a/Source/TemperatureSensor/Driver/Readme.md +++ b/Source/TemperatureSensor/Driver/Readme.md @@ -17,16 +17,16 @@ TemperatureSensor sensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new TemperatureSensor(Device.Pins.A01); var consumer = TemperatureSensor.CreateObserver( - handler: result => - { - Console.WriteLine($"Observer filter satisfied - " + + handler: result => + { + Resolver.Log.Info($"Observer filter satisfied - " + $"new: {result.New.Millivolts:N2}mV, " + - $"old: {result.Old?.Millivolts:N2}mV"); + $"old: {result.Old?.Millivolts:N2}mV"); }, filter: result => { @@ -40,7 +40,7 @@ public override Task Initialize() sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -49,7 +49,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/TemperatureSensor/Driver/TemperatureSensor.csproj b/Source/TemperatureSensor/Driver/TemperatureSensor.csproj index 3f72aee1..50066269 100644 --- a/Source/TemperatureSensor/Driver/TemperatureSensor.csproj +++ b/Source/TemperatureSensor/Driver/TemperatureSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/TemperatureSensor/Sample/TemperatureSensor_Sample/MeadowApp.cs b/Source/TemperatureSensor/Sample/TemperatureSensor_Sample/MeadowApp.cs index 9010da90..c0423570 100644 --- a/Source/TemperatureSensor/Sample/TemperatureSensor_Sample/MeadowApp.cs +++ b/Source/TemperatureSensor/Sample/TemperatureSensor_Sample/MeadowApp.cs @@ -15,16 +15,16 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new TemperatureSensor(Device.Pins.A01); var consumer = TemperatureSensor.CreateObserver( - handler: result => - { - Console.WriteLine($"Observer filter satisfied - " + + handler: result => + { + Resolver.Log.Info($"Observer filter satisfied - " + $"new: {result.New.Millivolts:N2}mV, " + - $"old: {result.Old?.Millivolts:N2}mV"); + $"old: {result.Old?.Millivolts:N2}mV"); }, filter: result => { @@ -38,7 +38,7 @@ public override Task Initialize() sensor.Updated += (sender, result) => { - Console.WriteLine($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); + Resolver.Log.Info($"Voltage Changed, new: {result.New.Millivolts:N2}mV, old: {result.Old?.Millivolts:N2}mV"); }; return Task.CompletedTask; @@ -47,7 +47,7 @@ public override Task Initialize() public override async Task Run() { var result = await sensor.Read(); - Console.WriteLine($"Initial read: {result.Millivolts:N2}mV"); + Resolver.Log.Info($"Initial read: {result.Millivolts:N2}mV"); sensor.StartUpdating(TimeSpan.FromMilliseconds(1000)); } diff --git a/Source/TemperatureSensor/Sample/TemperatureSensor_Sample/TemperatureSensor_Sample.csproj b/Source/TemperatureSensor/Sample/TemperatureSensor_Sample/TemperatureSensor_Sample.csproj index a94086be..68534280 100644 --- a/Source/TemperatureSensor/Sample/TemperatureSensor_Sample/TemperatureSensor_Sample.csproj +++ b/Source/TemperatureSensor/Sample/TemperatureSensor_Sample/TemperatureSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/ThumbJoystick/Driver/Readme.md b/Source/ThumbJoystick/Driver/Readme.md index 2b22e0c2..a0fe45d0 100644 --- a/Source/ThumbJoystick/Driver/Readme.md +++ b/Source/ThumbJoystick/Driver/Readme.md @@ -17,7 +17,7 @@ ThumbJoystick joystick; public override Task Initialize() { - Console.WriteLine("Initializing hardware..."); + Resolver.Log.Info("Initializing hardware..."); joystick = new ThumbJoystick( Device.CreateAnalogInputPort(Device.Pins.A01, 1, TimeSpan.FromMilliseconds(10), new Voltage(3.3)), @@ -38,8 +38,8 @@ public override async Task Run() private void JoystickUpdated(object sender, IChangeResult e) { - Console.WriteLine($"Horizontal: {e.New.Horizontal:n2}, Vertical: {e.New.Vertical:n2}"); - Console.WriteLine($"Digital position: {joystick.DigitalPosition}"); + Resolver.Log.Info($"Horizontal: {e.New.Horizontal:n2}, Vertical: {e.New.Vertical:n2}"); + Resolver.Log.Info($"Digital position: {joystick.DigitalPosition}"); } ``` diff --git a/Source/ThumbJoystick/Driver/ThumbJoystick.cs b/Source/ThumbJoystick/Driver/ThumbJoystick.cs index 1ad23ffb..49dbe6b8 100644 --- a/Source/ThumbJoystick/Driver/ThumbJoystick.cs +++ b/Source/ThumbJoystick/Driver/ThumbJoystick.cs @@ -49,12 +49,12 @@ public ThumbJoystick( /// /// public ThumbJoystick( - IAnalogInputPort horizontalInputPort, - IAnalogInputPort verticalInputPort, - JoystickCalibration calibration = null) + IAnalogInputPort horizontalInputPort, + IAnalogInputPort verticalInputPort, + JoystickCalibration calibration = null) : base( - horizontalInputPort, - verticalInputPort, + horizontalInputPort, + verticalInputPort, calibration) { } } diff --git a/Source/ThumbJoystick/Driver/ThumbJoystick.csproj b/Source/ThumbJoystick/Driver/ThumbJoystick.csproj index d114273f..c6d051e0 100644 --- a/Source/ThumbJoystick/Driver/ThumbJoystick.csproj +++ b/Source/ThumbJoystick/Driver/ThumbJoystick.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/ThumbJoystick/Sample/ThumbJoystick_Sample/MeadowApp.cs b/Source/ThumbJoystick/Sample/ThumbJoystick_Sample/MeadowApp.cs index 9337b52c..b1a9ba56 100644 --- a/Source/ThumbJoystick/Sample/ThumbJoystick_Sample/MeadowApp.cs +++ b/Source/ThumbJoystick/Sample/ThumbJoystick_Sample/MeadowApp.cs @@ -17,7 +17,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initializing hardware..."); + Resolver.Log.Info("Initializing hardware..."); joystick = new ThumbJoystick( Device.CreateAnalogInputPort(Device.Pins.A01, 1, TimeSpan.FromMilliseconds(10), new Voltage(3.3)), @@ -38,8 +38,8 @@ public override async Task Run() private void JoystickUpdated(object sender, IChangeResult e) { - Console.WriteLine($"Horizontal: {e.New.Horizontal:n2}, Vertical: {e.New.Vertical:n2}"); - Console.WriteLine($"Digital position: {joystick.DigitalPosition}"); + Resolver.Log.Info($"Horizontal: {e.New.Horizontal:n2}, Vertical: {e.New.Vertical:n2}"); + Resolver.Log.Info($"Digital position: {joystick.DigitalPosition}"); } // diff --git a/Source/ThumbJoystick/Sample/ThumbJoystick_Sample/ThumbJoystick_Sample.csproj b/Source/ThumbJoystick/Sample/ThumbJoystick_Sample/ThumbJoystick_Sample.csproj index c3ba4e7c..5506b642 100644 --- a/Source/ThumbJoystick/Sample/ThumbJoystick_Sample/ThumbJoystick_Sample.csproj +++ b/Source/ThumbJoystick/Sample/ThumbJoystick_Sample/ThumbJoystick_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/Tilt/Driver/Readme.md b/Source/Tilt/Driver/Readme.md index 1e665088..627113b0 100644 --- a/Source/Tilt/Driver/Readme.md +++ b/Source/Tilt/Driver/Readme.md @@ -17,13 +17,13 @@ Tilt tiltSwitch; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); tiltSwitch = new Tilt(Device.Pins.D13); tiltSwitch.Changed += (s, e) => { - Console.WriteLine(tiltSwitch.IsOn ? "Switch is High" : "Switch is Low"); + Resolver.Log.Info(tiltSwitch.IsOn ? "Switch is High" : "Switch is Low"); }; return Task.CompletedTask; diff --git a/Source/Tilt/Driver/Tilt.cs b/Source/Tilt/Driver/Tilt.cs index 898cfa6b..e1c6dab1 100644 --- a/Source/Tilt/Driver/Tilt.cs +++ b/Source/Tilt/Driver/Tilt.cs @@ -13,9 +13,9 @@ public class Tilt : SpdtSwitch /// Creates a Tilt driver /// /// - public Tilt(IPin pin) - : base(pin, - InterruptMode.EdgeBoth, + public Tilt(IPin pin) + : base(pin, + InterruptMode.EdgeBoth, ResistorMode.InternalPullDown, TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(2)) diff --git a/Source/Tilt/Driver/Tilt.csproj b/Source/Tilt/Driver/Tilt.csproj index b31142f2..33620b0e 100644 --- a/Source/Tilt/Driver/Tilt.csproj +++ b/Source/Tilt/Driver/Tilt.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/Tilt/Sample/Tilt_Sample/MeadowApp.cs b/Source/Tilt/Sample/Tilt_Sample/MeadowApp.cs index b08a709d..95060eb8 100644 --- a/Source/Tilt/Sample/Tilt_Sample/MeadowApp.cs +++ b/Source/Tilt/Sample/Tilt_Sample/MeadowApp.cs @@ -15,13 +15,13 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); tiltSwitch = new Tilt(Device.Pins.D13); tiltSwitch.Changed += (s, e) => { - Console.WriteLine(tiltSwitch.IsOn ? "Switch is High" : "Switch is Low"); + Resolver.Log.Info(tiltSwitch.IsOn ? "Switch is High" : "Switch is Low"); }; return Task.CompletedTask; diff --git a/Source/Tilt/Sample/Tilt_Sample/Tilt_Sample.csproj b/Source/Tilt/Sample/Tilt_Sample/Tilt_Sample.csproj index bb6ce12f..35733f30 100644 --- a/Source/Tilt/Sample/Tilt_Sample/Tilt_Sample.csproj +++ b/Source/Tilt/Sample/Tilt_Sample/Tilt_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/Touch/Driver/Readme.md b/Source/Touch/Driver/Readme.md index 4d902067..ff9140c6 100644 --- a/Source/Touch/Driver/Readme.md +++ b/Source/Touch/Driver/Readme.md @@ -17,19 +17,19 @@ Touch touch; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); touch = new Touch(Device.Pins.D04); touch.LongClickedThreshold = TimeSpan.FromMilliseconds(1500); touch.Clicked += (s, e) => { - Console.WriteLine("Grove Touch pressed"); + Resolver.Log.Info("Grove Touch pressed"); }; touch.LongClicked += (s, e) => { - Console.WriteLine("Grove Touch long pressed"); + Resolver.Log.Info("Grove Touch long pressed"); }; return Task.CompletedTask; diff --git a/Source/Touch/Driver/Touch.csproj b/Source/Touch/Driver/Touch.csproj index 5c08dcca..096ab2ce 100644 --- a/Source/Touch/Driver/Touch.csproj +++ b/Source/Touch/Driver/Touch.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/Touch/Sample/Touch_Sample/MeadowApp.cs b/Source/Touch/Sample/Touch_Sample/MeadowApp.cs index 4b379608..afaed30b 100644 --- a/Source/Touch/Sample/Touch_Sample/MeadowApp.cs +++ b/Source/Touch/Sample/Touch_Sample/MeadowApp.cs @@ -15,19 +15,19 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); touch = new Touch(Device.Pins.D04); touch.LongClickedThreshold = TimeSpan.FromMilliseconds(1500); touch.Clicked += (s, e) => { - Console.WriteLine("Grove Touch pressed"); + Resolver.Log.Info("Grove Touch pressed"); }; touch.LongClicked += (s, e) => { - Console.WriteLine("Grove Touch long pressed"); + Resolver.Log.Info("Grove Touch long pressed"); }; return Task.CompletedTask; diff --git a/Source/Touch/Sample/Touch_Sample/Touch_Sample.csproj b/Source/Touch/Sample/Touch_Sample/Touch_Sample.csproj index 09d98136..de2b5fdb 100644 --- a/Source/Touch/Sample/Touch_Sample/Touch_Sample.csproj +++ b/Source/Touch/Sample/Touch_Sample/Touch_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/VibrationMotor/Driver/Readme.md b/Source/VibrationMotor/Driver/Readme.md index a07cc335..7ec778a1 100644 --- a/Source/VibrationMotor/Driver/Readme.md +++ b/Source/VibrationMotor/Driver/Readme.md @@ -17,7 +17,7 @@ VibrationMotor vibrationMotor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); vibrationMotor = new VibrationMotor(Device.Pins.D13); @@ -28,11 +28,11 @@ public override async Task Run() { for (int i = 0; i < 5; i++) { - Console.WriteLine("Motor on"); + Resolver.Log.Info("Motor on"); vibrationMotor.IsVibrating = true; await Task.Delay(1000); - Console.WriteLine("Motor off"); + Resolver.Log.Info("Motor off"); vibrationMotor.IsVibrating = false; await Task.Delay(1000); } diff --git a/Source/VibrationMotor/Driver/VibrationMotor.cs b/Source/VibrationMotor/Driver/VibrationMotor.cs index e7d92c2c..da65b82a 100644 --- a/Source/VibrationMotor/Driver/VibrationMotor.cs +++ b/Source/VibrationMotor/Driver/VibrationMotor.cs @@ -12,7 +12,7 @@ public class VibrationMotor /// /// Gets/Sets vibration motor status /// - public bool IsVibrating + public bool IsVibrating { get => isVibrating; set @@ -36,7 +36,7 @@ public VibrationMotor(IDigitalOutputPort port) /// Creates a VibrationMotor driver /// /// - public VibrationMotor(IPin pin) + public VibrationMotor(IPin pin) : this(pin.CreateDigitalOutputPort(false)) { } } diff --git a/Source/VibrationMotor/Driver/VibrationMotor.csproj b/Source/VibrationMotor/Driver/VibrationMotor.csproj index 0d241c2b..2b1df1d9 100644 --- a/Source/VibrationMotor/Driver/VibrationMotor.csproj +++ b/Source/VibrationMotor/Driver/VibrationMotor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/VibrationMotor/Sample/VibrationMotor_Sample/MeadowApp.cs b/Source/VibrationMotor/Sample/VibrationMotor_Sample/MeadowApp.cs index 981ee3aa..431764c8 100644 --- a/Source/VibrationMotor/Sample/VibrationMotor_Sample/MeadowApp.cs +++ b/Source/VibrationMotor/Sample/VibrationMotor_Sample/MeadowApp.cs @@ -15,7 +15,7 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); vibrationMotor = new VibrationMotor(Device.Pins.D13); @@ -26,11 +26,11 @@ public override async Task Run() { for (int i = 0; i < 5; i++) { - Console.WriteLine("Motor on"); + Resolver.Log.Info("Motor on"); vibrationMotor.IsVibrating = true; await Task.Delay(1000); - Console.WriteLine("Motor off"); + Resolver.Log.Info("Motor off"); vibrationMotor.IsVibrating = false; await Task.Delay(1000); } diff --git a/Source/VibrationMotor/Sample/VibrationMotor_Sample/VibrationMotor_Sample.csproj b/Source/VibrationMotor/Sample/VibrationMotor_Sample/VibrationMotor_Sample.csproj index 88c7ac3d..1c358ac8 100644 --- a/Source/VibrationMotor/Sample/VibrationMotor_Sample/VibrationMotor_Sample.csproj +++ b/Source/VibrationMotor/Sample/VibrationMotor_Sample/VibrationMotor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/VibrationSensor/Driver/Readme.md b/Source/VibrationSensor/Driver/Readme.md index 3ca8d6e5..e27c5d5f 100644 --- a/Source/VibrationSensor/Driver/Readme.md +++ b/Source/VibrationSensor/Driver/Readme.md @@ -17,13 +17,13 @@ VibrationSensor sensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new VibrationSensor(Device.Pins.D13); sensor.VibrationDetected += (s, e) => { - Console.WriteLine("Motion detected"); + Resolver.Log.Info("Motion detected"); }; return Task.CompletedTask; diff --git a/Source/VibrationSensor/Driver/VibrationSensor.csproj b/Source/VibrationSensor/Driver/VibrationSensor.csproj index fbf14ae3..4b9aded9 100644 --- a/Source/VibrationSensor/Driver/VibrationSensor.csproj +++ b/Source/VibrationSensor/Driver/VibrationSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/VibrationSensor/Sample/VibrationSensor_Sample/MeadowApp.cs b/Source/VibrationSensor/Sample/VibrationSensor_Sample/MeadowApp.cs index 5d797475..afca64e8 100644 --- a/Source/VibrationSensor/Sample/VibrationSensor_Sample/MeadowApp.cs +++ b/Source/VibrationSensor/Sample/VibrationSensor_Sample/MeadowApp.cs @@ -15,13 +15,13 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); sensor = new VibrationSensor(Device.Pins.D13); sensor.VibrationDetected += (s, e) => { - Console.WriteLine("Motion detected"); + Resolver.Log.Info("Motion detected"); }; return Task.CompletedTask; diff --git a/Source/VibrationSensor/Sample/VibrationSensor_Sample/VibrationSensor_Sample.csproj b/Source/VibrationSensor/Sample/VibrationSensor_Sample/VibrationSensor_Sample.csproj index 6309c61b..607fd42e 100644 --- a/Source/VibrationSensor/Sample/VibrationSensor_Sample/VibrationSensor_Sample.csproj +++ b/Source/VibrationSensor/Sample/VibrationSensor_Sample/VibrationSensor_Sample.csproj @@ -6,7 +6,7 @@ App - + diff --git a/Source/WaterSensor/Driver/Readme.md b/Source/WaterSensor/Driver/Readme.md index 380fdbc3..3e387289 100644 --- a/Source/WaterSensor/Driver/Readme.md +++ b/Source/WaterSensor/Driver/Readme.md @@ -17,18 +17,18 @@ WaterSensor waterSensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); waterSensor = new WaterSensor(Device.Pins.A01); waterSensor.Subscribe(WaterSensor.CreateObserver( - h => Console.WriteLine($"Water level changed by 10 mm; new: {h.New}, old: {h.Old}"), + h => Resolver.Log.Info($"Water level changed by 10 mm; new: {h.New}, old: {h.Old}"), null //e => { return Math.Abs(e.Delta) > 0.1f; } )); - waterSensor.Updated += (object sender, IChangeResult e) => + waterSensor.Updated += (object sender, IChangeResult e) => { - Console.WriteLine($"Level Changed, level: {e.New}cm"); + Resolver.Log.Info($"Level Changed, level: {e.New}cm"); }; return Task.CompletedTask; @@ -37,7 +37,7 @@ public override Task Initialize() public override async Task Run() { var conditions = await waterSensor.Read(); - Console.WriteLine($"Initial level: {conditions}"); + Resolver.Log.Info($"Initial level: {conditions}"); waterSensor.StartUpdating(TimeSpan.FromSeconds(5)); } diff --git a/Source/WaterSensor/Driver/WaterSensor.cs b/Source/WaterSensor/Driver/WaterSensor.cs index e9a7cee5..8b723199 100644 --- a/Source/WaterSensor/Driver/WaterSensor.cs +++ b/Source/WaterSensor/Driver/WaterSensor.cs @@ -10,7 +10,7 @@ public WaterSensor(IAnalogInputPort analogInputPort, Calibration calibration = n : base(analogInputPort, calibration) { } - public WaterSensor(IPin analogPin, Calibration calibration = null, TimeSpan? updateInterval = null) + public WaterSensor(IPin analogPin, Calibration calibration = null, TimeSpan? updateInterval = null) : base(analogPin, calibration, updateInterval) { } } diff --git a/Source/WaterSensor/Driver/WaterSensor.csproj b/Source/WaterSensor/Driver/WaterSensor.csproj index 18a76b84..f5d479aa 100644 --- a/Source/WaterSensor/Driver/WaterSensor.csproj +++ b/Source/WaterSensor/Driver/WaterSensor.csproj @@ -23,6 +23,6 @@ - + diff --git a/Source/WaterSensor/Sample/WaterSensor_Sample/MeadowApp.cs b/Source/WaterSensor/Sample/WaterSensor_Sample/MeadowApp.cs index 0e62da07..82466f3b 100644 --- a/Source/WaterSensor/Sample/WaterSensor_Sample/MeadowApp.cs +++ b/Source/WaterSensor/Sample/WaterSensor_Sample/MeadowApp.cs @@ -15,18 +15,18 @@ public class MeadowApp : App public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); waterSensor = new WaterSensor(Device.Pins.A01); waterSensor.Subscribe(WaterSensor.CreateObserver( - h => Console.WriteLine($"Water level changed by 10 mm; new: {h.New}, old: {h.Old}"), + h => Resolver.Log.Info($"Water level changed by 10 mm; new: {h.New}, old: {h.Old}"), null //e => { return Math.Abs(e.Delta) > 0.1f; } )); - waterSensor.Updated += (object sender, IChangeResult e) => + waterSensor.Updated += (object sender, IChangeResult e) => { - Console.WriteLine($"Level Changed, level: {e.New}cm"); + Resolver.Log.Info($"Level Changed, level: {e.New}cm"); }; return Task.CompletedTask; @@ -35,7 +35,7 @@ public override Task Initialize() public override async Task Run() { var conditions = await waterSensor.Read(); - Console.WriteLine($"Initial level: {conditions}"); + Resolver.Log.Info($"Initial level: {conditions}"); waterSensor.StartUpdating(TimeSpan.FromSeconds(5)); } diff --git a/Source/WaterSensor/Sample/WaterSensor_Sample/WaterSensor_Sample.csproj b/Source/WaterSensor/Sample/WaterSensor_Sample/WaterSensor_Sample.csproj index 0d970ccd..35e5ae51 100644 --- a/Source/WaterSensor/Sample/WaterSensor_Sample/WaterSensor_Sample.csproj +++ b/Source/WaterSensor/Sample/WaterSensor_Sample/WaterSensor_Sample.csproj @@ -6,7 +6,7 @@ App - +