From 3986373920fc17d20bbea4fb6caead575c17e4bf Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Sun, 14 Jan 2024 13:28:40 -0800 Subject: [PATCH] Update readmes --- .../Driver/Readme.md | 10 ++--- .../Driver/Readme.md | 10 ++--- .../Driver/Readme.md | 44 +++++++++---------- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/Source/Relays.ElectromagneticRelayModule/Driver/Readme.md b/Source/Relays.ElectromagneticRelayModule/Driver/Readme.md index 05b0193..36a4b56 100644 --- a/Source/Relays.ElectromagneticRelayModule/Driver/Readme.md +++ b/Source/Relays.ElectromagneticRelayModule/Driver/Readme.md @@ -17,7 +17,7 @@ private ElectromagneticRelayModule module; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); module = new ElectromagneticRelayModule(Device.CreateI2cBus(), ElectromagneticRelayModule.GetAddressFromPins(false, false, false)); @@ -28,26 +28,26 @@ public override Task Run() { for (int i = 0; i < 5; i++) { - Console.Write("All on (closed)"); + Resolver.Log.Info("All on (closed)"); module.SetAllOn(); Thread.Sleep(1000); - Console.Write("All off (open)"); + Resolver.Log.Info("All off (open)"); module.SetAllOff(); Thread.Sleep(1000); for (int j = 0; j < (int)RelayIndex.Relay4; j++) { - Console.Write($"{(RelayIndex)j} on (closed)"); + Resolver.Log.Info($"{(RelayIndex)j} on (closed)"); module.Relays[j].State = RelayState.Closed; Thread.Sleep(1000); } for (int j = 0; j < (int)RelayIndex.Relay4; j++) { - Console.Write($"{(RelayIndex)j} off (open)"); + Resolver.Log.Info($"{(RelayIndex)j} off (open)"); module.Relays[j].State = RelayState.Open; Thread.Sleep(1000); } diff --git a/Source/Sensors.Motion.UsefulSensors.PersonSensor/Driver/Readme.md b/Source/Sensors.Motion.UsefulSensors.PersonSensor/Driver/Readme.md index bd6b786..06a0394 100644 --- a/Source/Sensors.Motion.UsefulSensors.PersonSensor/Driver/Readme.md +++ b/Source/Sensors.Motion.UsefulSensors.PersonSensor/Driver/Readme.md @@ -17,7 +17,7 @@ PersonSensor personSensor; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); personSensor = new PersonSensor(Device.CreateI2cBus()); @@ -39,18 +39,14 @@ private void DisplaySensorData(PersonSensorResults sensorData) { if (sensorData.NumberOfFaces == 0) { - Console.WriteLine("No faces found"); + Resolver.Log.Info("No faces found"); return; } for (int i = 0; i < sensorData.NumberOfFaces; ++i) { var face = sensorData.FaceData[i]; - Console.Write($"Face #{i}: "); - Console.Write($"{face.BoxConfidence} confidence, "); - Console.Write($"({face.BoxLeft}, {face.BoxTop}), "); - Console.Write($"({face.BoxRight}, {face.BoxBottom}), "); - Console.WriteLine(face.IsFacing == 1 ? "facing" : "not facing"); + Resolver.Log.Info($"Face #{i}: {face.BoxConfidence} confidence, ({face.BoxLeft}, {face.BoxTop}), ({face.BoxRight}, {face.BoxBottom}), facing: {face.IsFacing}"); } } diff --git a/Source/Sensors.UsefulSensors.TinyCodeReader/Driver/Readme.md b/Source/Sensors.UsefulSensors.TinyCodeReader/Driver/Readme.md index bd6b786..c44db33 100644 --- a/Source/Sensors.UsefulSensors.TinyCodeReader/Driver/Readme.md +++ b/Source/Sensors.UsefulSensors.TinyCodeReader/Driver/Readme.md @@ -13,45 +13,41 @@ To view all Wilderness Labs open-source projects, including samples, visit [gith ## Usage ```csharp -PersonSensor personSensor; +TinyCodeReader tinyCodeReader; public override Task Initialize() { - Console.WriteLine("Initialize..."); + Resolver.Log.Info("Initialize..."); - personSensor = new PersonSensor(Device.CreateI2cBus()); + tinyCodeReader = new TinyCodeReader(Device.CreateI2cBus()); return Task.CompletedTask; } public override Task Run() { - while (true) - { - var sensorData = personSensor.GetSensorData(); - DisplaySensorData(sensorData); - - Thread.Sleep(1500); - } -} + //one time read + var qrCode = tinyCodeReader.ReadCode(); -private void DisplaySensorData(PersonSensorResults sensorData) -{ - if (sensorData.NumberOfFaces == 0) + if (qrCode != null) { - Console.WriteLine("No faces found"); - return; + Resolver.Log.Info($"QR Code: {qrCode}"); } - - for (int i = 0; i < sensorData.NumberOfFaces; ++i) + else { - var face = sensorData.FaceData[i]; - Console.Write($"Face #{i}: "); - Console.Write($"{face.BoxConfidence} confidence, "); - Console.Write($"({face.BoxLeft}, {face.BoxTop}), "); - Console.Write($"({face.BoxRight}, {face.BoxBottom}), "); - Console.WriteLine(face.IsFacing == 1 ? "facing" : "not facing"); + Resolver.Log.Info("No QR Code Found"); } + + //continuous read + tinyCodeReader.CodeRead += TinyCodeReader_CodeRead; + tinyCodeReader.StartUpdating(TimeSpan.FromSeconds(1)); + + return Task.CompletedTask; +} + +private void TinyCodeReader_CodeRead(object sender, string e) +{ + Resolver.Log.Info($"QRCode message: {e} ({DateTime.Now})"); } ```