Skip to content

Commit

Permalink
Update readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianstevens committed Jan 14, 2024
1 parent a4efc7b commit 3986373
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 36 deletions.
10 changes: 5 additions & 5 deletions Source/Relays.ElectromagneticRelayModule/Driver/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PersonSensor personSensor;

public override Task Initialize()
{
Console.WriteLine("Initialize...");
Resolver.Log.Info("Initialize...");

personSensor = new PersonSensor(Device.CreateI2cBus());

Expand All @@ -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}");
}
}

Expand Down
44 changes: 20 additions & 24 deletions Source/Sensors.UsefulSensors.TinyCodeReader/Driver/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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})");
}

```
Expand Down

0 comments on commit 3986373

Please sign in to comment.