Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Update Color reference
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgedevs committed Dec 13, 2023
1 parent f28f855 commit 344d4dd
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Source/Azure/AzureIoTHub/Views/DisplayController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Meadow.Foundation;
using Meadow;
using Meadow.Foundation.Graphics;
using Meadow.Foundation.Graphics.Buffers;
using Meadow.Units;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Meadow.Foundation;
using Meadow;
using Meadow.Foundation.Leds;
using System;
using System.Threading;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ public class TemperatureController

AnalogTemperature analogTemperature;

private TemperatureController()
private TemperatureController()
{
Initialize();
}

private void Initialize()
{
analogTemperature = new AnalogTemperature(MeadowApp.Device.Pins.A01,
analogTemperature = new AnalogTemperature(MeadowApp.Device.Pins.A01,
AnalogTemperature.KnownSensorType.LM35);
analogTemperature.TemperatureUpdated += AnalogTemperatureUpdated;
analogTemperature.Updated += AnalogTemperatureUpdated;
}

void AnalogTemperatureUpdated(object sender, Meadow.IChangeResult<Temperature> e)
{
TemperatureUpdated.Invoke(this, e.New);
}

public void StartUpdating(TimeSpan timeSpan)
public void StartUpdating(TimeSpan timeSpan)
{
analogTemperature.StartUpdating(timeSpan);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Meadow.Foundation;
using Meadow;
using Meadow.Foundation.Leds;
using System;
using System.Threading;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Meadow.Foundation;
using Meadow;
using Meadow.Foundation.Leds;
using System;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Meadow.Foundation;
using Meadow;
using Meadow.Foundation.Sensors.Temperature;
using Meadow.Peripherals.Sensors;
using Meadow.Units;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Meadow.Foundation;
using Meadow;
using Meadow.Foundation.Web.Maple;
using Meadow.Foundation.Web.Maple.Routing;
using MeadowMapleTemperature.Controllers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Meadow.Foundation;
using Meadow;
using Meadow.Foundation.Displays;
using Meadow.Foundation.Graphics;

Expand Down
28 changes: 16 additions & 12 deletions Source/Hackster/PlantMonitor/DisplayController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Meadow.Foundation;
using Meadow;
using Meadow.Foundation.Displays;
using Meadow.Foundation.Graphics;
using Meadow.Units;
using SimpleJpegDecoder;
using System.IO;
using System.Reflection;
using Meadow.Units;

namespace PlantMonitor
{
Expand All @@ -13,7 +13,7 @@ public class DisplayController
MicroGraphics graphics;

public DisplayController(St7789 display)
{
{
graphics = new MicroGraphics(display);
graphics.CurrentFont = new Font12x20();
graphics.Stroke = 3;
Expand Down Expand Up @@ -78,30 +78,34 @@ byte[] LoadResource(string filename)
}
}

public void UpdateMoistureImage(double moistureReadings)
public void UpdateMoistureImage(double moistureReadings)
{
double moisture = moistureReadings;

if (moisture > 1) moisture = 1f;
else if (moisture < 0) moisture = 0f;

if (moisture > 0 && moisture <= 0.25) {

if (moisture > 0 && moisture <= 0.25)
{
UpdateImage(0, 42, 10);
}
else if (moisture > 0.25 && moisture <= 0.50) {
else if (moisture > 0.25 && moisture <= 0.50)
{
UpdateImage(1, 28, 4);
}
else if (moisture > 0.50 && moisture <= 0.75) {
else if (moisture > 0.50 && moisture <= 0.75)
{
UpdateImage(2, 31, 5);
}
else if (moisture > 0.75 && moisture <= 1.0) {
else if (moisture > 0.75 && moisture <= 1.0)
{
UpdateImage(3, 35, 5);
}

graphics.Show();
}

public void UpdateMoisturePercentage(double newValue, double oldValue)
public void UpdateMoisturePercentage(double newValue, double oldValue)
{
if (newValue > 1) newValue = 1f;
else if (newValue < 0) newValue = 0f;
Expand All @@ -111,9 +115,9 @@ public void UpdateMoisturePercentage(double newValue, double oldValue)
graphics.Show();
}

public void UpdateTemperatureValue(Temperature newValue, Temperature oldValue)
public void UpdateTemperatureValue(Temperature newValue, Temperature oldValue)
{
string t = $"{(int)oldValue.Celsius}C";
string t = $"{(int)oldValue.Celsius}C";
graphics.DrawText(240 - t.Length * 24, 208, t, Color.White, ScaleFactor.X2);

t = $"{(int)newValue.Celsius}C";
Expand Down
3 changes: 1 addition & 2 deletions Source/Hackster/TemperatureMonitor/MeadowApp.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Meadow;
using Meadow.Devices;
using Meadow.Foundation;
using Meadow.Foundation.Displays;
using Meadow.Foundation.Graphics;
using Meadow.Foundation.Leds;
Expand Down Expand Up @@ -36,7 +35,7 @@ public override Task Initialize()
analogPin: Device.Pins.A00,
sensorType: AnalogTemperature.KnownSensorType.LM35
);
analogTemperature.TemperatureUpdated += AnalogTemperatureUpdated;
analogTemperature.Updated += AnalogTemperatureUpdated;

var st7789 = new St7789(
spiBus: Device.CreateSpiBus(),
Expand Down
2 changes: 1 addition & 1 deletion Source/Hackster/WifiWeather/Views/WeatherView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Meadow.Foundation;
using Meadow;
using Meadow.Foundation.Displays;
using Meadow.Foundation.Graphics;
using SimpleJpegDecoder;
Expand Down

0 comments on commit 344d4dd

Please sign in to comment.