diff --git a/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Connectivity/BluetoothServer.cs b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Connectivity/BluetoothServer.cs new file mode 100644 index 00000000..95b62e78 --- /dev/null +++ b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Connectivity/BluetoothServer.cs @@ -0,0 +1,107 @@ +using Meadow; +using Meadow.Gateways.Bluetooth; +using MeadowBleLed.Controllers; + +namespace MeadowBleLed.Connectivity; + +public class BluetoothServer +{ + readonly string ON = "73cfbc6f61fa4d80a92feec2a90f8a3e"; + readonly string OFF = "6315119dd61949bba21def9e99941948"; + readonly string PULSING = "d755180131fc435da9941e7f15e17baf"; + readonly string BLINKING = "3a6cc4f2a6ab4709a9bfc9611c6bf892"; + readonly string RUNNING_COLORS = "30df1258f42b4788af2ea8ed9d0b932f"; + + private CommandController commandController; + + ICharacteristic LedOn; + ICharacteristic LedOff; + ICharacteristic LedBlink; + ICharacteristic LedPulse; + ICharacteristic LedRunColors; + + public BluetoothServer() + { + commandController = Resolver.Services.Get(); + } + + private void LedOnCharacteristicValueSet(ICharacteristic c, object data) + { + commandController.FireLedOn(); + } + + private void LedOffCharacteristicValueSet(ICharacteristic c, object data) + { + commandController.FireLedOff(); + } + + private void LedBlinkCharacteristicValueSet(ICharacteristic c, object data) + { + commandController.FireLedBlink(); + } + + private void LedPulseCharacteristicValueSet(ICharacteristic c, object data) + { + commandController.FireLedPulse(); + } + + private void LedRunColorsCharacteristicValueSet(ICharacteristic c, object data) + { + commandController.FireLedRunColors(); + } + + public Definition GetDefinition() + { + LedOn = new CharacteristicBool( + name: nameof(LedOn), + uuid: ON, + permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, + properties: CharacteristicProperty.Read | CharacteristicProperty.Write); + LedOn.ValueSet += LedOnCharacteristicValueSet; + + LedOff = new CharacteristicBool( + name: nameof(LedOff), + uuid: OFF, + permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, + properties: CharacteristicProperty.Read | CharacteristicProperty.Write); + LedOff.ValueSet += LedOffCharacteristicValueSet; + + LedBlink = new CharacteristicBool( + name: nameof(LedBlink), + uuid: BLINKING, + permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, + properties: CharacteristicProperty.Read | CharacteristicProperty.Write); + LedBlink.ValueSet += LedBlinkCharacteristicValueSet; + + LedPulse = new CharacteristicBool( + name: nameof(LedPulse), + uuid: PULSING, + permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, + properties: CharacteristicProperty.Read | CharacteristicProperty.Write); + LedPulse.ValueSet += LedPulseCharacteristicValueSet; + + LedRunColors = new CharacteristicBool( + name: nameof(LedRunColors), + uuid: RUNNING_COLORS, + permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, + properties: CharacteristicProperty.Read | CharacteristicProperty.Write); + LedRunColors.ValueSet += LedRunColorsCharacteristicValueSet; + + ICharacteristic[] characteristics = + { + LedOn, + LedOff, + LedBlink, + LedPulse, + LedRunColors + }; + + var service = new Service( + name: "Service", + uuid: 253, + characteristics + ); + + return new Definition("MeadowRGB", service); + } +} \ No newline at end of file diff --git a/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/CommandController.cs b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/CommandController.cs new file mode 100644 index 00000000..e3cf3e33 --- /dev/null +++ b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/CommandController.cs @@ -0,0 +1,43 @@ +using Meadow; +using System; + +namespace MeadowBleLed.Controllers; + +public class CommandController +{ + public event EventHandler LedOnValueSet = default!; + public event EventHandler LedOffValueSet = default!; + public event EventHandler LedBlinkValueSet = default!; + public event EventHandler LedPulseValueSet = default!; + public event EventHandler LedRunColorsValueSet = default!; + + public CommandController() + { + Resolver.Services.Add(this); + } + + public void FireLedOn() + { + LedOnValueSet?.Invoke(this, true); + } + + public void FireLedOff() + { + LedOffValueSet?.Invoke(this, true); + } + + public void FireLedBlink() + { + LedBlinkValueSet?.Invoke(this, true); + } + + public void FireLedPulse() + { + LedPulseValueSet?.Invoke(this, true); + } + + public void FireLedRunColors() + { + LedRunColorsValueSet?.Invoke(this, true); + } +} \ No newline at end of file diff --git a/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/LedController.cs b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/LedController.cs index c05422a9..ffdb77c2 100644 --- a/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/LedController.cs +++ b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/LedController.cs @@ -1,24 +1,23 @@ using Meadow; using Meadow.Foundation.Leds; +using Meadow.Hardware; +using Meadow.Peripherals.Leds; using System; using System.Threading; using System.Threading.Tasks; -namespace MeadowBleLed.Controller; +namespace MeadowBleLed.Controllers; public class LedController { - RgbPwmLed rgbPwmLed; + IRgbPwmLed rgbPwmLed; Task animationTask = null; CancellationTokenSource cancellationTokenSource = null; - public LedController() + public LedController(IPin redPwmPin, IPin greenPwmPin, IPin bluePwmPin) { - rgbPwmLed = new RgbPwmLed( - redPwmPin: MeadowApp.Device.Pins.D12, - greenPwmPin: MeadowApp.Device.Pins.D11, - bluePwmPin: MeadowApp.Device.Pins.D10); + rgbPwmLed = new RgbPwmLed(redPwmPin, greenPwmPin, bluePwmPin); } void Stop() diff --git a/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/MainController.cs b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/MainController.cs new file mode 100644 index 00000000..63b2fc58 --- /dev/null +++ b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/Controllers/MainController.cs @@ -0,0 +1,61 @@ +using Meadow; +using Meadow.Devices; +using Meadow.Gateways; +using MeadowBleLed.Connectivity; + +namespace MeadowBleLed.Controllers; + +public class MainController +{ + private IBluetoothAdapter bluetooth; + + private LedController ledController; + private BluetoothServer bluetoothServer; + private CommandController commandController; + + public MainController(F7FeatherV2 hardware, IBluetoothAdapter bluetooth) + { + this.bluetooth = bluetooth; + + commandController = new CommandController(); + + ledController = new LedController(hardware.Pins.OnboardLedRed, hardware.Pins.OnboardLedGreen, hardware.Pins.OnboardLedBlue); + //ledController = new LedController(hardware.Pins.D12, hardware.Pins.D11, hardware.Pins.D12); + + StartBluetoothServer(); + } + + private void StartBluetoothServer() + { + bluetoothServer = new BluetoothServer(); + + var definition = bluetoothServer.GetDefinition(); + bluetooth.StartBluetoothServer(definition); + + commandController.LedOnValueSet += (s, e) => + { + Resolver.Log.Info("LedOnValueSet"); + ledController.TurnOn(); + }; + commandController.LedOffValueSet += (s, e) => + { + Resolver.Log.Info("LedOffValueSet"); + ledController.TurnOff(); + }; + commandController.LedBlinkValueSet += (s, e) => + { + Resolver.Log.Info("LedBlinkValueSet"); + ledController.StartBlink(); + }; + commandController.LedPulseValueSet += (s, e) => + { + Resolver.Log.Info("LedPulseValueSet"); + ledController.StartPulse(); + }; + commandController.LedRunColorsValueSet += (s, e) => + { + Resolver.Log.Info("LedRunColorsValueSet"); + ledController.StartRunningColors(); + }; + } +} \ No newline at end of file diff --git a/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/MeadowApp.cs b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/MeadowApp.cs index bf076230..54dd5ab8 100644 --- a/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/MeadowApp.cs +++ b/Source/Meadow F7 Feather/Bluetooth/MeadowBleLed/MeadowApp.cs @@ -1,7 +1,6 @@ using Meadow; using Meadow.Devices; -using Meadow.Gateways.Bluetooth; -using MeadowBleLed.Controller; +using MeadowBleLed.Controllers; using System.Threading.Tasks; namespace MeadowBleLed; @@ -9,74 +8,14 @@ namespace MeadowBleLed; // public class MeadowApp : App <- If you have a Meadow F7v1.* public class MeadowApp : App { - LedController ledController; - - readonly string ON = "73cfbc6f61fa4d80a92feec2a90f8a3e"; - readonly string OFF = "6315119dd61949bba21def9e99941948"; - readonly string PULSING = "d755180131fc435da9941e7f15e17baf"; - readonly string BLINKING = "3a6cc4f2a6ab4709a9bfc9611c6bf892"; - readonly string RUNNING_COLORS = "30df1258f42b4788af2ea8ed9d0b932f"; - - IDefinition bleTreeDefinition; - - ICharacteristic On; - ICharacteristic Off; - ICharacteristic StartPulse; - ICharacteristic StartBlink; - ICharacteristic StartRunningColors; - public override Task Initialize() { - ledController = new LedController(); - - ledController.SetColor(Color.Red); + Resolver.Log.Info("Initialize..."); - bleTreeDefinition = GetDefinition(); - Device.BluetoothAdapter.StartBluetoothServer(bleTreeDefinition); + var ble = Device.BluetoothAdapter; - On.ValueSet += (s, e) => { ledController.TurnOn(); }; - Off.ValueSet += (s, e) => { ledController.TurnOff(); }; - StartPulse.ValueSet += (s, e) => { ledController.StartPulse(); }; - StartBlink.ValueSet += (s, e) => { ledController.StartBlink(); }; - StartRunningColors.ValueSet += (s, e) => { ledController.StartRunningColors(); }; - - ledController.SetColor(Color.Green); + var mainController = new MainController(Device, ble); return base.Initialize(); } - - Definition GetDefinition() - { - var service = new Service( - name: "MeadowRGBService", - uuid: 253, - On = new CharacteristicBool( - name: nameof(On), - uuid: ON, - permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, - properties: CharacteristicProperty.Read | CharacteristicProperty.Write), - Off = new CharacteristicBool( - name: nameof(Off), - uuid: OFF, - permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, - properties: CharacteristicProperty.Read | CharacteristicProperty.Write), - StartPulse = new CharacteristicBool( - name: nameof(StartPulse), - uuid: PULSING, - permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, - properties: CharacteristicProperty.Read | CharacteristicProperty.Write), - StartBlink = new CharacteristicBool( - name: nameof(StartBlink), - uuid: BLINKING, - permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, - properties: CharacteristicProperty.Read | CharacteristicProperty.Write), - StartRunningColors = new CharacteristicBool( - name: nameof(StartRunningColors), - uuid: RUNNING_COLORS, - permissions: CharacteristicPermission.Read | CharacteristicPermission.Write, - properties: CharacteristicProperty.Read | CharacteristicProperty.Write) - ); - - return new Definition("MeadowRGB", service); - } } \ No newline at end of file diff --git a/Source/Meadow.Cloud/ProjectLab_ApiClient/DTOs/CommonDTOs.cs b/Source/Meadow.Cloud/ProjectLab_ApiClient/DTOs/CommonDTOs.cs index d1b9ea9e..bde8afb7 100644 --- a/Source/Meadow.Cloud/ProjectLab_ApiClient/DTOs/CommonDTOs.cs +++ b/Source/Meadow.Cloud/ProjectLab_ApiClient/DTOs/CommonDTOs.cs @@ -3,17 +3,6 @@ namespace ProjectLab_ApiClient.DTOs; -public class GreenhouseModel -{ - public double TemperatureCelsius { get; set; } - public double HumidityPercentage { get; set; } - public double SoilMoisturePercentage { get; set; } - public bool IsLightOn { get; set; } - public bool IsHeaterOn { get; set; } - public bool IsSprinklerOn { get; set; } - public bool IsVentilationOn { get; set; } -} - public class MeasurementData { public string temperature { get; set; } @@ -49,5 +38,5 @@ public class Root { public Data data { get; set; } public bool isSuccessful { get; set; } - public object errorMessage { get; set; } + public string errorMessage { get; set; } } \ No newline at end of file diff --git a/Source/Meadow.Cloud/ProjectLab_ApiClient/app.config.yaml b/Source/Meadow.Cloud/ProjectLab_ApiClient/app.config.yaml index 0a50d5ad..790ef57a 100644 --- a/Source/Meadow.Cloud/ProjectLab_ApiClient/app.config.yaml +++ b/Source/Meadow.Cloud/ProjectLab_ApiClient/app.config.yaml @@ -21,10 +21,10 @@ Logging: Default: Trace # Meadow.Cloud configuration. -MeadowCloud: +#MeadowCloud: # Enable Logging, Events, Command + Control - Enabled: true +# Enabled: true # Enable Over-the-air Updates # EnableUpdates: false diff --git a/Source/Meadow.Cloud/ProjectLab_Logging/Controllers/MainController.cs b/Source/Meadow.Cloud/ProjectLab_Logging/Controllers/MainController.cs index 0e588b91..7f5e24e1 100644 --- a/Source/Meadow.Cloud/ProjectLab_Logging/Controllers/MainController.cs +++ b/Source/Meadow.Cloud/ProjectLab_Logging/Controllers/MainController.cs @@ -67,9 +67,9 @@ private void RecordSensor() { "humidity", $"{hardware.HumiditySensor.Humidity.Value.Percent:N2}" }, }); - displayController.UpdateSyncStatus(false); displayController.UpdateStatus("Data sent!"); Thread.Sleep(2000); + displayController.UpdateSyncStatus(false); displayController.UpdateStatus(DateTime.Now.AddHours(TIMEZONE_OFFSET).ToString("hh:mm tt dd/MM/yy")); displayController.UpdateLastUpdated(DateTime.Now.AddHours(TIMEZONE_OFFSET).ToString("hh:mm tt dd/MM/yy")); diff --git a/Source/Meadow.Cloud/ProjectLab_OTA/info.json b/Source/Meadow.Cloud/ProjectLab_OTA/info.json index 8048eb14..5100e54c 100644 --- a/Source/Meadow.Cloud/ProjectLab_OTA/info.json +++ b/Source/Meadow.Cloud/ProjectLab_OTA/info.json @@ -1 +1 @@ -{"v":"1.0","osVersion":"1.9.0.0"} \ No newline at end of file +{"v":"1.0","osVersion":"1.10.0.2"} \ No newline at end of file diff --git a/Source/Meadow.Desktop/WinForms/WinFormsMeadow.csproj b/Source/Meadow.Desktop/HMI_Views/HMI_Views.csproj similarity index 100% rename from Source/Meadow.Desktop/WinForms/WinFormsMeadow.csproj rename to Source/Meadow.Desktop/HMI_Views/HMI_Views.csproj diff --git a/Source/Meadow.Desktop/HMI_Views/MeadowApp.cs b/Source/Meadow.Desktop/HMI_Views/MeadowApp.cs new file mode 100644 index 00000000..f987a804 --- /dev/null +++ b/Source/Meadow.Desktop/HMI_Views/MeadowApp.cs @@ -0,0 +1,58 @@ +using HMI_Views.Views; +using Meadow; +using Meadow.Foundation.Displays; +using System.Threading; +using System.Threading.Tasks; + +namespace HMI_Views; + +public class MeadowApp : App +{ + public override Task Initialize() + { + // Default WinForms screen (800,600) + //_display = new WinFormsDisplay(); + //var views = new RotatingCube(_display); + + // Screen size of a ILI9488 display + //_display = new WinFormsDisplay(320, 480); + //var views = new WiFiWeather(_display); + + // Screen size of a EPD4IN2bV2 e-paper display + //_display = new WinFormsDisplay(300, 400); + //var views = new HomeWidget(_display); + + // Screen size of a ILI9341 display + //var views = new CultivarView(Device.Display); + //var views = new ProjectLabDemoView(Device.Display); + //var views = new AtmosphericHMI(Device.Display); + var views = new WifiWeatherV2(Device.Display); + + _ = Task.Run(() => + { + Thread.Sleep(2000); + views.Run(); + }); + + return Task.CompletedTask; + } + + public override Task Run() + { + // NOTE: this will not return until the display is closed + ExecutePlatformDisplayRunner(); + + return Task.CompletedTask; + } + + private void ExecutePlatformDisplayRunner() + { +#if WINDOWS + System.Windows.Forms.Application.Run(Device.Display as System.Windows.Forms.Form); +#endif + if (Device.Display is GtkDisplay gtk) + { + gtk.Run(); + } + } +} \ No newline at end of file diff --git a/Source/Meadow.Desktop/WinForms/Program.cs b/Source/Meadow.Desktop/HMI_Views/Program.cs similarity index 90% rename from Source/Meadow.Desktop/WinForms/Program.cs rename to Source/Meadow.Desktop/HMI_Views/Program.cs index c286f84d..3a28d03f 100644 --- a/Source/Meadow.Desktop/WinForms/Program.cs +++ b/Source/Meadow.Desktop/HMI_Views/Program.cs @@ -1,7 +1,7 @@ using Meadow; using System.Threading.Tasks; -namespace WinFormsMeadow; +namespace HMI_Views; public class Program { diff --git a/Source/Meadow.Desktop/WinForms/Resources/img-green.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img-green.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img-green.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img-green.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img-red.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img-red.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img-red.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img-red.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img-sync-fade.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img-sync-fade.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img-sync-fade.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img-sync-fade.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img-sync.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img-sync.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img-sync.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img-sync.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img-wifi-fade.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img-wifi-fade.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img-wifi-fade.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img-wifi-fade.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img-wifi.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img-wifi.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img-wifi.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img-wifi.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img_meadow.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img_meadow.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img_meadow.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img_meadow.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img_refreshed.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img_refreshed.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img_refreshed.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img_refreshed.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img_refreshing.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img_refreshing.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img_refreshing.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img_refreshing.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img_wifi_connected.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img_wifi_connected.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img_wifi_connected.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img_wifi_connected.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/img_wifi_connecting.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/img_wifi_connecting.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/img_wifi_connecting.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/img_wifi_connecting.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/w_clear.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/w_clear.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/w_clear.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/w_clear.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/w_cloudy.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/w_cloudy.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/w_cloudy.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/w_cloudy.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/w_drizzle.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/w_drizzle.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/w_drizzle.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/w_drizzle.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/w_misc.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/w_misc.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/w_misc.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/w_misc.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/w_rain.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/w_rain.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/w_rain.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/w_rain.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/w_snow.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/w_snow.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/w_snow.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/w_snow.bmp diff --git a/Source/Meadow.Desktop/WinForms/Resources/w_storm.bmp b/Source/Meadow.Desktop/HMI_Views/Resources/w_storm.bmp similarity index 100% rename from Source/Meadow.Desktop/WinForms/Resources/w_storm.bmp rename to Source/Meadow.Desktop/HMI_Views/Resources/w_storm.bmp diff --git a/Source/Meadow.Desktop/HMI_Views/Views/AtmosphericHMI.cs b/Source/Meadow.Desktop/HMI_Views/Views/AtmosphericHMI.cs new file mode 100644 index 00000000..a512b4cc --- /dev/null +++ b/Source/Meadow.Desktop/HMI_Views/Views/AtmosphericHMI.cs @@ -0,0 +1,145 @@ +using Meadow.Foundation.Graphics; +using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; +using System; +using System.Threading.Tasks; + +namespace HMI_Views.Views; + +public class AtmosphericHMI +{ + int rowHeight = 60; + int rowMargin = 15; + + protected DisplayScreen DisplayScreen { get; set; } + + protected Label Light { get; set; } + + protected Label Pressure { get; set; } + + protected Label Humidity { get; set; } + + protected Label Temperature { get; set; } + + Meadow.Color backgroundColor = Meadow.Color.FromHex("#F3F7FA"); + Meadow.Color foregroundColor = Meadow.Color.Black; + + Font12x20 font12X20 = new Font12x20(); + + public AtmosphericHMI(IPixelDisplay display) + { + DisplayScreen = new DisplayScreen(display) + { + BackgroundColor = backgroundColor + }; + + DisplayScreen.Controls.Add(new GradientBox(0, 0, display.Width, display.Height) + { + StartColor = Meadow.Color.FromHex("#5AC0EA"), + EndColor = Meadow.Color.FromHex("#B8E4F6") + }); + + DisplayScreen.Controls.Add(new Label(rowMargin, 0, DisplayScreen.Width / 2, rowHeight) + { + Text = $"LIGHT", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Left + }); + DisplayScreen.Controls.Add(new Label(rowMargin, rowHeight, DisplayScreen.Width / 2, rowHeight) + { + Text = $"PRESSURE", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Left + }); + DisplayScreen.Controls.Add(new Label(rowMargin, rowHeight * 2, DisplayScreen.Width / 2, rowHeight) + { + Text = $"HUMIDITY", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Left + }); + DisplayScreen.Controls.Add(new Label(rowMargin, rowHeight * 3, DisplayScreen.Width / 2, rowHeight) + { + Text = $"TEMPERATURE", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Left + }); + + Light = new Label(DisplayScreen.Width / 2 - rowMargin, 0, DisplayScreen.Width / 2, rowHeight) + { + Text = $"- Lx", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(Light); + + Pressure = new Label(DisplayScreen.Width / 2 - rowMargin, rowHeight, DisplayScreen.Width / 2, rowHeight) + { + Text = $"- Mb", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(Pressure); + + Humidity = new Label(DisplayScreen.Width / 2 - rowMargin, rowHeight * 2, DisplayScreen.Width / 2, rowHeight) + { + Text = $"- %", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(Humidity); + + Temperature = new Label(DisplayScreen.Width / 2 - rowMargin, rowHeight * 3, DisplayScreen.Width / 2, rowHeight) + { + Text = $"- °C", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(Temperature); + } + + public void UpdateAtmosphericConditions(string light, string pressure, string humidity, string temperature) + { + DisplayScreen.BeginUpdate(); + + Light.Text = light; + Pressure.Text = pressure; + Humidity.Text = humidity; + Temperature.Text = temperature; + + DisplayScreen.EndUpdate(); + } + + + public async Task Run() + { + var random = new Random(); + + while (true) + { + UpdateAtmosphericConditions( + $"{random.Next(70, 80)} Lx", + $"{random.Next(1000, 1010)} Mb", + $"{random.Next(25, 35)} % ", + $"{random.Next(25, 35)} °C" + ); + + await Task.Delay(1000); + } + } +} diff --git a/Source/Meadow.Desktop/HMI_Views/Views/CultivarView.cs b/Source/Meadow.Desktop/HMI_Views/Views/CultivarView.cs new file mode 100644 index 00000000..864f8c3d --- /dev/null +++ b/Source/Meadow.Desktop/HMI_Views/Views/CultivarView.cs @@ -0,0 +1,259 @@ +using Meadow.Foundation.Graphics; +using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; +using System; +using System.Threading.Tasks; + +namespace HMI_Views.Views; + +public class CultivarView +{ + DisplayScreen screen; + + Image imgWifi = Image.LoadFromResource("HMI_Views.Resources.img-wifi.bmp"); + Image imgSync = Image.LoadFromResource("HMI_Views.Resources.img-sync.bmp"); + + Image imgRed = Image.LoadFromResource("HMI_Views.Resources.img-red.bmp"); + Image imgGreen = Image.LoadFromResource("HMI_Views.Resources.img-green.bmp"); + Image imgWifiFade = Image.LoadFromResource("HMI_Views.Resources.img-wifi-fade.bmp"); + Image imgSyncFade = Image.LoadFromResource("HMI_Views.Resources.img-sync-fade.bmp"); + + protected Label StatusLabel { get; set; } + + protected Label TemperatureLabel { get; set; } + + protected Label HumidityLabel { get; set; } + + protected Label SoilMoistureLabel { get; set; } + + protected Picture ledLights { get; set; } + + protected Picture wifi { get; set; } + + protected Picture sync { get; set; } + + protected Picture ledWater { get; set; } + + protected Picture ledVents { get; set; } + + protected Picture ledHeater { get; set; } + + public CultivarView(IPixelDisplay _display) + { + screen = new DisplayScreen(_display); + + screen.Controls.Add(new Box(0, 0, screen.Width, screen.Height) { ForeColor = Meadow.Color.White }); + screen.Controls.Add(new Box(0, 27, 106, 93) { ForeColor = Meadow.Color.FromHex("#B35E2C") }); + screen.Controls.Add(new Box(106, 27, 108, 93) { ForeColor = Meadow.Color.FromHex("#1A80AA") }); + screen.Controls.Add(new Box(214, 27, 106, 93) { ForeColor = Meadow.Color.FromHex("#98A645") }); + + screen.Controls.Add(new Box(160, 120, 1, screen.Height) { ForeColor = Meadow.Color.Black, IsFilled = false }); + screen.Controls.Add(new Box(0, 180, screen.Width, 1) { ForeColor = Meadow.Color.Black, IsFilled = false }); + + StatusLabel = new Label(2, 6, 12, 16) + { + Text = "Hello Meadow", + Font = new Font12x20(), + TextColor = Meadow.Color.Black + }; + screen.Controls.Add(StatusLabel); + + wifi = new Picture(286, 3, 30, 21, imgWifi); + screen.Controls.Add(wifi); + + sync = new Picture(260, 3, 21, 21, imgSync); + screen.Controls.Add(sync); + + screen.Controls.Add(new Label(5, 32, 12, 16) + { + Text = "TEMP.", + Font = new Font12x16(), + TextColor = Meadow.Color.White + }); + screen.Controls.Add(new Label(77, 99, 12, 16) + { + Text = "°C", + Font = new Font12x20(), + TextColor = Meadow.Color.White + }); + + screen.Controls.Add(new Label(111, 32, 12, 16) + { + Text = "HUM.", + Font = new Font12x16(), + TextColor = Meadow.Color.White + }); + screen.Controls.Add(new Label(197, 99, 12, 16) + { + Text = "%", + Font = new Font12x20(), + TextColor = Meadow.Color.White + }); + + screen.Controls.Add(new Label(219, 32, 12, 16) + { + Text = "S.M.", + Font = new Font12x16(), + TextColor = Meadow.Color.White + }); + screen.Controls.Add(new Label(303, 99, 12, 16) + { + Text = "%", + Font = new Font12x20(), + TextColor = Meadow.Color.White + }); + + TemperatureLabel = new Label(50, 70, 12, 16, ScaleFactor.X2) + { + Text = "31", + Font = new Font12x16(), + TextColor = Meadow.Color.White, + HorizontalAlignment = HorizontalAlignment.Center, + }; + screen.Controls.Add(TemperatureLabel); + HumidityLabel = new Label(155, 70, 12, 16, ScaleFactor.X2) + { + Text = "33", + Font = new Font12x16(), + TextColor = Meadow.Color.White, + HorizontalAlignment = HorizontalAlignment.Center, + }; + screen.Controls.Add(HumidityLabel); + SoilMoistureLabel = new Label(260, 70, 12, 16, ScaleFactor.X2) + { + Text = "23", + Font = new Font12x16(), + TextColor = Meadow.Color.White, + HorizontalAlignment = HorizontalAlignment.Center, + }; + screen.Controls.Add(SoilMoistureLabel); + + + ledLights = new Picture(8, 128, 46, 46, imgGreen) + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + screen.Controls.Add(ledLights); + screen.Controls.Add(new Label(60, 145, 12, 16, ScaleFactor.X2) + { + Text = "Lights", + Font = new Font8x12(), + TextColor = Meadow.Color.Black + }); + + ledWater = new Picture(168, 128, 46, 46, imgGreen) + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + screen.Controls.Add(ledWater); + screen.Controls.Add(new Label(60, 205, 12, 16, ScaleFactor.X2) + { + Text = "Water", + Font = new Font8x12(), + TextColor = Meadow.Color.Black + }); + + ledVents = new Picture(8, 188, 46, 46, imgGreen) + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + screen.Controls.Add(ledVents); + screen.Controls.Add(new Label(220, 145, 12, 16, ScaleFactor.X2) + { + Text = "Vents", + Font = new Font8x12(), + TextColor = Meadow.Color.Black + }); + + ledHeater = new Picture(168, 188, 46, 46, imgGreen) + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + screen.Controls.Add(ledHeater); + screen.Controls.Add(new Label(220, 205, 12, 16, ScaleFactor.X2) + { + Text = "Heater", + Font = new Font8x12(), + TextColor = Meadow.Color.Black + }); + } + + public void UpdateWifi(bool on) + { + wifi.Image = on ? imgWifi : imgWifiFade; + } + + public void UpdateSync(bool on) + { + sync.Image = on ? imgSync : imgSyncFade; + } + + public void UpdateStatus(string status) + { + StatusLabel.Text = status; + } + + public void UpdateTemperature(double temp) + { + TemperatureLabel.Text = temp.ToString("N0"); + } + + public void UpdateHumidity(double humidity) + { + HumidityLabel.Text = humidity.ToString("N0"); + } + + public void UpdateSoilMoisture(double moisture) + { + SoilMoistureLabel.Text = moisture.ToString("N0"); + } + + public void UpdateLights(bool on) + { + ledLights.Image = on ? imgGreen : imgRed; + } + + public void UpdateHeater(bool on) + { + ledHeater.Image = on ? imgGreen : imgRed; + } + + public void UpdateWater(bool on) + { + ledWater.Image = on ? imgGreen : imgRed; + } + + public void UpdateVents(bool on) + { + ledVents.Image = on ? imgGreen : imgRed; + } + + public async Task Run() + { + bool status = false; + + while (true) + { + var random = new Random(); + + UpdateWifi(status); + UpdateSync(status); + + UpdateTemperature(random.Next(20, 25)); + UpdateHumidity(random.Next(30, 35)); + UpdateSoilMoisture(random.Next(40, 45)); + + UpdateLights(status); + UpdateHeater(status); + UpdateWater(status); + UpdateVents(status); + status = !status; + + await Task.Delay(1000); + } + } +} \ No newline at end of file diff --git a/Source/Meadow.Desktop/HMI_Views/Views/HomeWidget.cs b/Source/Meadow.Desktop/HMI_Views/Views/HomeWidget.cs new file mode 100644 index 00000000..bb09c81b --- /dev/null +++ b/Source/Meadow.Desktop/HMI_Views/Views/HomeWidget.cs @@ -0,0 +1,270 @@ +using Meadow; +using Meadow.Foundation.Graphics; +using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; +using System; +using System.Threading.Tasks; + +namespace HMI_Views.Views; + +public class HomeWidget +{ + Image _weatherIcon = Image.LoadFromResource("HMI_Views.Resources.w_misc.bmp"); + + int padding = 10; + int small_padding = 5; + + protected DisplayScreen DisplayScreen { get; set; } + + protected Label YearMonth { get; set; } + + protected Label WeekdayDay { get; set; } + + protected Label Time { get; set; } + + protected Picture Weather { get; set; } + + protected Label WeatherTemperature { get; set; } + + protected Label WeatherHumidity { get; set; } + + protected Label Temperature { get; set; } + + protected Label Humidity { get; set; } + + protected Label UpcomingWeekMealA { get; set; } + + protected Label UpcomingWeekMealB { get; set; } + + protected Label WeekAfterMealA { get; set; } + + protected Label WeekAfterMealB { get; set; } + + Color backgroundColor = Color.White; + Color foregroundColor = Color.Black; + + Font12x20 font12X20 = new Font12x20(); + Font6x8 font6x8 = new Font6x8(); + + public HomeWidget(IPixelDisplay display) + { + DisplayScreen = new DisplayScreen(display) + { + BackgroundColor = backgroundColor + }; + + Weather = new Picture(padding, padding, 100, 100, _weatherIcon); + DisplayScreen.Controls.Add(Weather); + + DisplayScreen.Controls.Add(new Box(padding, padding, 100, 100) + { + ForeColor = Color.Black, + IsFilled = false + }); + + WeatherTemperature = new Label(padding + 2, padding + 2, font6x8.Width * 4, font6x8.Height) + { + Text = $"--C", + TextColor = foregroundColor, + Font = font6x8 + }; + DisplayScreen.Controls.Add(WeatherTemperature); + + WeatherHumidity = new Label(84, padding + 2, font6x8.Width * 4, font6x8.Height) + { + Text = $"--%", + TextColor = foregroundColor, + Font = font6x8, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(WeatherHumidity); + + YearMonth = new Label(120, padding, 170, font12X20.Height) + { + Text = $"---- ----", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(YearMonth); + + WeekdayDay = new Label(120, 40, 170, font12X20.Height) + { + Text = $"---- ----", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(WeekdayDay); + + Time = new Label(120, 70, 170, font12X20.Height * 2) + { + Text = $"--:--", + TextColor = foregroundColor, + Font = font12X20, + ScaleFactor = ScaleFactor.X2, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(Time); + + DisplayScreen.Controls.Add(new Label(padding, 120, 135, font12X20.Height) + { + Text = $"TEMPERATURE", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }); + + DisplayScreen.Controls.Add(new Label(155, 120, 135, font12X20.Height) + { + Text = $"HUMIDITY", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }); + + Temperature = new Label(padding, 150, 135, font12X20.Height * 2) + { + Text = $"--.-°C", + TextColor = foregroundColor, + Font = font12X20, + ScaleFactor = ScaleFactor.X2, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }; + DisplayScreen.Controls.Add(Temperature); + + Humidity = new Label(155, 150, 135, font12X20.Height * 2) + { + Text = $"--%", + TextColor = foregroundColor, + Font = font12X20, + ScaleFactor = ScaleFactor.X2, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(Humidity); + + DisplayScreen.Controls.Add(new Box(padding, 204, 280, 1) + { + ForeColor = Color.Black + }); + + DisplayScreen.Controls.Add(new Label(padding, 220, DisplayScreen.Width / 2, font12X20.Height) + { + Text = $"UPCOMING WEEK (#2):", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }); + + UpcomingWeekMealA = new Label(padding, 250, DisplayScreen.Width / 2, font12X20.Height) + { + Text = $"- Meal A", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }; + DisplayScreen.Controls.Add(UpcomingWeekMealA); + + UpcomingWeekMealB = new Label(padding, 280, DisplayScreen.Width / 2, font12X20.Height) + { + Text = $"- Meal B", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }; + DisplayScreen.Controls.Add(UpcomingWeekMealB); + + DisplayScreen.Controls.Add(new Label(padding, 310, DisplayScreen.Width / 2, font12X20.Height) + { + Text = $"WEEK AFTER (#3):", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }); + + WeekAfterMealA = new Label(padding, 340, DisplayScreen.Width / 2, font12X20.Height) + { + Text = $"- Meal A", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }; + DisplayScreen.Controls.Add(WeekAfterMealA); + + WeekAfterMealB = new Label(padding, 370, DisplayScreen.Width / 2, font12X20.Height) + { + Text = $"- Meal B", + TextColor = foregroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }; + DisplayScreen.Controls.Add(WeekAfterMealB); + } + + private static string GetOrdinalSuffix(int num) + { + string number = num.ToString(); + if (number.EndsWith("1")) return "st"; + if (number.EndsWith("2")) return "nd"; + if (number.EndsWith("3")) return "rd"; + if (number.EndsWith("11")) return "th"; + if (number.EndsWith("12")) return "th"; + if (number.EndsWith("13")) return "th"; + return "th"; + } + + public void UpdateDisplay( + string weatherIcon, + double weatherTemperature, + double weatherHumidity, + double temperature, + double humidity) + { + DisplayScreen.BeginUpdate(); + + _weatherIcon = Image.LoadFromResource(weatherIcon); + Weather.Image = _weatherIcon; + + int TIMEZONE_OFFSET = -8; + var today = DateTime.Now.AddHours(TIMEZONE_OFFSET); + + YearMonth.Text = today.ToString("yyyy MMMM"); + WeekdayDay.Text = $"{today.DayOfWeek},{today.Day}{GetOrdinalSuffix(today.Day)}"; + Time.Text = today.ToString("hh:mm"); + + WeatherTemperature.Text = $"{weatherTemperature:N0}°C"; + WeatherHumidity.Text = $"{weatherHumidity:N0}%"; + Temperature.Text = $"{temperature:N1}°C"; + Humidity.Text = $"{humidity:N0}%"; + + DisplayScreen.EndUpdate(); + } + + public async Task Run() + { + while (true) + { + UpdateDisplay( + weatherIcon: $"HMI_Views.Resources.w_drizzle.bmp", + weatherTemperature: 10, + weatherHumidity: 78, + temperature: 23, + humidity: 93); + + await Task.Delay(TimeSpan.FromSeconds(1)); + } + } +} \ No newline at end of file diff --git a/Source/Meadow.Desktop/HMI_Views/Views/ProjectLabDemoView.cs b/Source/Meadow.Desktop/HMI_Views/Views/ProjectLabDemoView.cs new file mode 100644 index 00000000..b11d5974 --- /dev/null +++ b/Source/Meadow.Desktop/HMI_Views/Views/ProjectLabDemoView.cs @@ -0,0 +1,717 @@ +using Meadow.Foundation.Graphics; +using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; +using System; +using System.Threading.Tasks; + +namespace HMI_Views.Views; + +internal class ProjectLabDemoView +{ + readonly int margin = 5; + readonly int smallMargin = 3; + readonly int graphHeight = 106; + + readonly int measureBoxWidth = 82; + + readonly int column1 = 96; + readonly int column2 = 206; + readonly int columnWidth = 109; + + readonly int rowHeight = 30; + readonly int row1 = 135; + readonly int row2 = 170; + readonly int row3 = 205; + + readonly int sensorBarHeight = 14; + readonly int sensorBarInitialWidth = 6; + readonly int sensorBarX = 184; + readonly int sensorBarY = 202; + readonly int sensorBarZ = 220; + + readonly int clockX = 244; + readonly int clockWidth = 71; + + readonly int dPadSize = 9; + + protected DisplayScreen DisplayScreen { get; set; } + + protected AbsoluteLayout SplashLayout { get; set; } + + protected AbsoluteLayout DataLayout { get; set; } + + public LineChartSeries LineChartSeries { get; set; } + + protected LineChart LineChart { get; set; } + + protected Picture WifiStatus { get; set; } + + protected Picture SyncStatus { get; set; } + + protected Label Status { get; set; } + + protected Box TemperatureBox { get; set; } + protected Label TemperatureLabel { get; set; } + protected Label TemperatureValue { get; set; } + + protected Box PressureBox { get; set; } + protected Label PressureLabel { get; set; } + protected Label PressureValue { get; set; } + + protected Box HumidityBox { get; set; } + protected Label HumidityLabel { get; set; } + protected Label HumidityValue { get; set; } + + protected Box LuminanceBox { get; set; } + protected Label LuminanceLabel { get; set; } + protected Label LuminanceValue { get; set; } + + protected Label Date { get; set; } + protected Label Time { get; set; } + + protected Box Up { get; set; } + protected Box Down { get; set; } + protected Box Left { get; set; } + protected Box Right { get; set; } + + protected Box AccelerometerX { get; set; } + protected Box AccelerometerY { get; set; } + protected Box AccelerometerZ { get; set; } + + protected Box GyroscopeX { get; set; } + protected Box GyroscopeY { get; set; } + protected Box GyroscopeZ { get; set; } + + protected Label ConnectionErrorLabel { get; set; } + + private Meadow.Color backgroundColor = Meadow.Color.FromHex("10485E"); + private Meadow.Color selectedColor = Meadow.Color.FromHex("C9DB31"); + private Meadow.Color accentColor = Meadow.Color.FromHex("EF7D3B"); + private Meadow.Color ForegroundColor = Meadow.Color.FromHex("EEEEEE"); + private Font12x20 font12X20 = new Font12x20(); + private Font8x12 font8x12 = new Font8x12(); + private Font8x16 font8x16 = new Font8x16(); + private Font6x8 font6x8 = new Font6x8(); + + public ProjectLabDemoView(IPixelDisplay display) + { + DisplayScreen = new DisplayScreen(display) + { + BackgroundColor = backgroundColor + }; + + LoadSplashLayout(); + + DisplayScreen.Controls.Add(SplashLayout); + + LoadDataLayout(); + + DisplayScreen.Controls.Add(DataLayout); + } + + private void LoadSplashLayout() + { + SplashLayout = new AbsoluteLayout(DisplayScreen, 0, 0, DisplayScreen.Width, DisplayScreen.Height) + { + IsVisible = false + }; + + var image = Image.LoadFromResource("HMI_Views.Resources.img_meadow.bmp"); + var displayImage = new Picture(0, 0, DisplayScreen.Width, DisplayScreen.Height, image) + { + BackColor = Meadow.Color.FromHex("#14607F"), + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + + SplashLayout.Controls.Add(displayImage); + } + + + + private void LoadDataLayout() + { + DataLayout = new AbsoluteLayout(DisplayScreen, 0, 0, DisplayScreen.Width, DisplayScreen.Height) + { + BackgroundColor = backgroundColor, + IsVisible = false + }; + + DataLayout.Controls.Add(new Label( + margin, + margin, + DisplayScreen.Width / 2, + font8x16.Height) + { + Text = $"Project Lab v3", + TextColor = Meadow.Color.White, + Font = font8x16 + }); + + var wifiImage = Image.LoadFromResource("HMI_Views.Resources.img_wifi_connecting.bmp"); + WifiStatus = new Picture( + DisplayScreen.Width - wifiImage.Width - margin, + margin, + wifiImage.Width, + font8x16.Height, + wifiImage) + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + DataLayout.Controls.Add(WifiStatus); + + var syncImage = Image.LoadFromResource("HMI_Views.Resources.img_refreshed.bmp"); + SyncStatus = new Picture( + DisplayScreen.Width - syncImage.Width - wifiImage.Width - margin * 2, + margin, + syncImage.Width, + font8x16.Height, + syncImage) + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + DataLayout.Controls.Add(SyncStatus); + + LineChart = new LineChart( + margin, + margin + font8x16.Height + smallMargin, + DisplayScreen.Width - margin * 2, + graphHeight) + { + BackgroundColor = Meadow.Color.FromHex("082936"), + AxisColor = ForegroundColor, + ShowYAxisLabels = true, + IsVisible = false, + AlwaysShowYOrigin = false, + }; + LineChartSeries = new LineChartSeries() + { + LineColor = selectedColor, + PointColor = selectedColor, + LineStroke = 1, + PointSize = 2, + ShowLines = true, + ShowPoints = true, + }; + LineChart.Series.Add(LineChartSeries); + DataLayout.Controls.Add(LineChart); + + #region TEMPERATURE + TemperatureBox = new Box(margin, row1, measureBoxWidth, rowHeight) + { + ForeColor = selectedColor + }; + DataLayout.Controls.Add(TemperatureBox); + TemperatureLabel = new Label( + margin + smallMargin, + row1 + smallMargin, + measureBoxWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"TEMPERATURE", + TextColor = backgroundColor, + Font = font6x8 + }; + DataLayout.Controls.Add(TemperatureLabel); + TemperatureValue = new Label( + margin + smallMargin, + row1 + font6x8.Height + smallMargin * 2, + measureBoxWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"-.-C", + TextColor = backgroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(TemperatureValue); + #endregion + + #region PRESSURE + PressureBox = new Box( + margin, + row2, + measureBoxWidth, + rowHeight) + { + ForeColor = backgroundColor + }; + DataLayout.Controls.Add(PressureBox); + PressureLabel = new Label( + margin + smallMargin, + row2 + smallMargin, + measureBoxWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"PRESSURE", + TextColor = ForegroundColor, + Font = font6x8 + }; + DataLayout.Controls.Add(PressureLabel); + PressureValue = new Label( + margin + smallMargin, + row2 + font6x8.Height + smallMargin * 2, + measureBoxWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"-.-atm", + TextColor = ForegroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(PressureValue); + #endregion + + #region HUMIDITY + HumidityBox = new Box( + margin, + row3, + measureBoxWidth, + rowHeight) + { + ForeColor = backgroundColor + }; + DataLayout.Controls.Add(HumidityBox); + HumidityLabel = new Label( + margin + smallMargin, + row3 + smallMargin, + measureBoxWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"HUMIDITY", + TextColor = ForegroundColor, + Font = font6x8 + }; + DataLayout.Controls.Add(HumidityLabel); + HumidityValue = new Label( + margin + smallMargin, + row3 + font6x8.Height + smallMargin * 2, + columnWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"-.-%", + TextColor = ForegroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(HumidityValue); + #endregion + + #region LUMINANCE + LuminanceBox = new Box( + column1, + row1, + columnWidth, + rowHeight) + { + ForeColor = backgroundColor + }; + DataLayout.Controls.Add(LuminanceBox); + LuminanceLabel = new Label( + column1 + smallMargin, + row1 + smallMargin, + columnWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"LUMINANCE", + TextColor = ForegroundColor, + Font = font6x8 + }; + DataLayout.Controls.Add(LuminanceLabel); + LuminanceValue = new Label( + column1 + smallMargin, + row1 + font6x8.Height + smallMargin * 2, + columnWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"0Lux", + TextColor = ForegroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(LuminanceValue); + #endregion + + #region ACCELEROMETER + DataLayout.Controls.Add(new Label( + column1 + smallMargin, + row2 + smallMargin, + columnWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"ACCELEROMETER (g)", + TextColor = Meadow.Color.White, + Font = font6x8 + }); + + DataLayout.Controls.Add(new Label( + column1 + smallMargin, + sensorBarX, + font6x8.Width * 2, + font6x8.Height * 2) + { + Text = $"X", + TextColor = Meadow.Color.White, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }); + AccelerometerX = new Box( + column1 + font6x8.Width * 2 + margin, + sensorBarX, + sensorBarInitialWidth, + sensorBarHeight) + { + ForeColor = Meadow.Color.FromHex("98A645") + }; + DataLayout.Controls.Add(AccelerometerX); + + DataLayout.Controls.Add(new Label( + column1 + smallMargin, + sensorBarY, + font6x8.Width * 2, + font6x8.Height * 2) + { + Text = $"Y", + TextColor = Meadow.Color.White, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }); + AccelerometerY = new Box( + column1 + font6x8.Width * 2 + margin, + sensorBarY, + sensorBarInitialWidth, + sensorBarHeight) + { + ForeColor = Meadow.Color.FromHex("C9DB31") + }; + DataLayout.Controls.Add(AccelerometerY); + + DataLayout.Controls.Add(new Label( + column1 + smallMargin, + sensorBarZ, + font6x8.Width * 2, + font6x8.Height * 2) + { + Text = $"Z", + TextColor = Meadow.Color.White, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }); + AccelerometerZ = new Box( + column1 + font6x8.Width * 2 + margin, + sensorBarZ, + sensorBarInitialWidth, + sensorBarHeight) + { + ForeColor = Meadow.Color.FromHex("E1EB8B") + }; + DataLayout.Controls.Add(AccelerometerZ); + #endregion + + #region GYROSCOPE + DataLayout.Controls.Add(new Label( + column2 + smallMargin, + row2 + smallMargin, + columnWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"GYROSCOPE (rpm)", + TextColor = Meadow.Color.White, + Font = font6x8 + }); + + DataLayout.Controls.Add(new Label( + column2 + smallMargin, + sensorBarX, + font6x8.Width * 2, + font6x8.Height * 2) + { + Text = $"X", + TextColor = Meadow.Color.White, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }); + GyroscopeX = new Box( + column2 + font6x8.Width * 2 + margin, + sensorBarX, + sensorBarInitialWidth, + sensorBarHeight) + { + ForeColor = Meadow.Color.FromHex("98A645") + }; + DataLayout.Controls.Add(GyroscopeX); + + DataLayout.Controls.Add(new Label( + column2 + smallMargin, + sensorBarY, + font6x8.Width * 2, + font6x8.Height * 2) + { + Text = $"Y", + TextColor = Meadow.Color.White, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }); + GyroscopeY = new Box( + column2 + font6x8.Width * 2 + margin, + sensorBarY, + sensorBarInitialWidth, + sensorBarHeight) + { + ForeColor = Meadow.Color.FromHex("C9DB31") + }; + DataLayout.Controls.Add(GyroscopeY); + + DataLayout.Controls.Add(new Label( + column2 + smallMargin, + sensorBarZ, + font6x8.Width * 2, + font6x8.Height * 2) + { + Text = $"Z", + TextColor = Meadow.Color.White, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }); + GyroscopeZ = new Box( + column2 + font6x8.Width * 2 + margin, + sensorBarZ, + sensorBarInitialWidth, + sensorBarHeight) + { + ForeColor = Meadow.Color.FromHex("E1EB8B") + }; + DataLayout.Controls.Add(GyroscopeZ); + #endregion + + #region CLOCK + DataLayout.Controls.Add(new Box( + clockX, + row1, + clockWidth, + rowHeight) + { + ForeColor = ForegroundColor + }); + Date = new Label( + clockX, + row1 + smallMargin, + clockWidth, + font6x8.Height) + { + Text = $"----/--/--", + TextColor = backgroundColor, + HorizontalAlignment = HorizontalAlignment.Center, + Font = font6x8 + }; + DataLayout.Controls.Add(Date); + Time = new Label( + clockX, + row1 + font6x8.Height + smallMargin * 2, + clockWidth, + font6x8.Height * 2) + { + Text = $"--:--", + TextColor = backgroundColor, + HorizontalAlignment = HorizontalAlignment.Center, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(Time); + #endregion + + #region D-PAD + Up = new Box( + 218, + 136, + dPadSize, + dPadSize) + { + ForeColor = ForegroundColor + }; + DataLayout.Controls.Add(Up); + Down = new Box( + 218, + 156, + dPadSize, + dPadSize) + { + ForeColor = ForegroundColor + }; + DataLayout.Controls.Add(Down); + Left = new Box( + 208, + 146, + dPadSize, + dPadSize) + { + ForeColor = ForegroundColor + }; + DataLayout.Controls.Add(Left); + Right = new Box( + 228, + 146, + dPadSize, + dPadSize) + { + ForeColor = ForegroundColor + }; + DataLayout.Controls.Add(Right); + + #endregion + } + + public void ShowSplashScreen() + { + DataLayout.IsVisible = false; + SplashLayout.IsVisible = true; + } + + public void ShowDataScreen() + { + SplashLayout.IsVisible = false; + DataLayout.IsVisible = true; + } + + public void UpdateStatus(string status) + { + Status.Text = status; + } + + public void UpdateWiFiStatus(bool isConnected) + { + var imageWiFi = isConnected + ? Image.LoadFromResource("HMI_Views.Resources.img_wifi_connected.bmp") + : Image.LoadFromResource("HMI_Views.Resources.img_wifi_connecting.bmp"); + WifiStatus.Image = imageWiFi; + } + + public void UpdateSyncStatus(bool isSyncing) + { + var imageSync = isSyncing + ? Image.LoadFromResource("HMI_Views.Resources.img_refreshing.bmp") + : Image.LoadFromResource("HMI_Views.Resources.img_refreshed.bmp"); + SyncStatus.Image = imageSync; + } + + protected void UpdateReadings(double temperature, double pressure, double humidity, double luminance) + { + DisplayScreen.BeginUpdate(); + + TemperatureValue.Text = $"{temperature:N1}C"; + PressureValue.Text = $"{pressure:N1}atm"; + HumidityValue.Text = $"{humidity:N1}%"; + LuminanceValue.Text = $"{luminance:N0}Lx"; + + DisplayScreen.EndUpdate(); + } + + protected void UpdateDateTime() + { + DisplayScreen.BeginUpdate(); + + var today = DateTime.Now; + Date.Text = today.ToString("yyyy/MM/dd"); + Time.Text = today.ToString("HH:mm"); + + DisplayScreen.EndUpdate(); + } + + public void UpdateDirectionalPad(int direction, bool pressed) + { + switch (direction) + { + case 0: Up.ForeColor = pressed ? accentColor : ForegroundColor; break; + case 1: Down.ForeColor = pressed ? accentColor : ForegroundColor; break; + case 2: Left.ForeColor = pressed ? accentColor : ForegroundColor; break; + case 3: Right.ForeColor = pressed ? accentColor : ForegroundColor; break; + } + } + + protected void UpdateSelectReading(int reading) + { + TemperatureBox.ForeColor = PressureBox.ForeColor = HumidityBox.ForeColor = LuminanceBox.ForeColor = backgroundColor; + TemperatureLabel.TextColor = PressureLabel.TextColor = HumidityLabel.TextColor = LuminanceLabel.TextColor = ForegroundColor; + TemperatureValue.TextColor = PressureValue.TextColor = HumidityValue.TextColor = LuminanceValue.TextColor = ForegroundColor; + + switch (reading) + { + case 0: + TemperatureBox.ForeColor = selectedColor; + TemperatureLabel.TextColor = backgroundColor; + TemperatureValue.TextColor = backgroundColor; + break; + case 1: + PressureBox.ForeColor = selectedColor; + PressureLabel.TextColor = backgroundColor; + PressureValue.TextColor = backgroundColor; + break; + case 2: + HumidityBox.ForeColor = selectedColor; + HumidityLabel.TextColor = backgroundColor; + HumidityValue.TextColor = backgroundColor; + break; + case 3: + LuminanceBox.ForeColor = selectedColor; + LuminanceLabel.TextColor = backgroundColor; + LuminanceValue.TextColor = backgroundColor; + break; + } + } + + protected void UpdateAccelerometerReading(double x, double y, double z) + { + DisplayScreen.BeginUpdate(); + AccelerometerX.Width = (int)x * 10 + 5; + AccelerometerY.Width = (int)y * 10 + 5; + AccelerometerZ.Width = (int)z * 10 + 5; + DisplayScreen.EndUpdate(); + } + + protected void UpdateGyroscopeReading(double x, double y, double z) + { + DisplayScreen.BeginUpdate(); + GyroscopeX.Width = (int)x * 10 + 5; + GyroscopeY.Width = (int)y * 10 + 5; + GyroscopeZ.Width = (int)z * 10 + 5; + DisplayScreen.EndUpdate(); + } + + public async Task Run() + { + //ShowSplashScreen(); + //Thread.Sleep(3000); + ShowDataScreen(); + + var random = new Random(); + + int x = 0; + + while (true) + { + UpdateDateTime(); + + UpdateReadings( + random.Next(25, 35), + random.Next(0, 2), + random.Next(75, 90), + random.Next(100, 4000) + ); + + UpdateDirectionalPad(random.Next(0, 5), true); + + UpdateSelectReading(random.Next(0, 4)); + + UpdateAccelerometerReading(random.Next(0, 3), random.Next(0, 3), random.Next(0, 3)); + + UpdateGyroscopeReading(random.Next(0, 3), random.Next(0, 3), random.Next(0, 3)); + + this.LineChartSeries.Points.Add(x, random.Next(2, 8)); + x++; + + await Task.Delay(1000); + } + } +} \ No newline at end of file diff --git a/Source/Meadow.Desktop/HMI_Views/Views/RotatingCube.cs b/Source/Meadow.Desktop/HMI_Views/Views/RotatingCube.cs new file mode 100644 index 00000000..e324ee8b --- /dev/null +++ b/Source/Meadow.Desktop/HMI_Views/Views/RotatingCube.cs @@ -0,0 +1,136 @@ +using Meadow; +using Meadow.Foundation.Graphics; +using Meadow.Peripherals.Displays; +using System; + +namespace HMI_Views.Views; + +public class RotatingCube +{ + Color backgroundColor = Color.FromHex("91E46C"); + Color foregroundColor = Color.FromHex("000000"); + + private MicroGraphics _graphics = default!; + + //needs cleanup - quick port from c code + private double rot, rotationX, rotationY, rotationZ; + private double rotationXX, rotationYY, rotationZZ; + private double rotationXXX, rotationYYY, rotationZZZ; + + private int[,] cubeWireframe = new int[12, 3]; + private int[,] cubeVertices; + + public RotatingCube(IPixelDisplay display) + { + int cubeSize = 100; + + cubeVertices = new int[8, 3] { + { -cubeSize, -cubeSize, cubeSize}, + { cubeSize, -cubeSize, cubeSize}, + { cubeSize, cubeSize, cubeSize}, + { -cubeSize, cubeSize, cubeSize}, + { -cubeSize, -cubeSize, -cubeSize}, + { cubeSize, -cubeSize, -cubeSize}, + { cubeSize, cubeSize, -cubeSize}, + { -cubeSize, cubeSize, -cubeSize}, + }; + + _graphics = new MicroGraphics(display) + { + CurrentFont = new Font12x20(), + Stroke = 5 + }; + } + + public void Run() + { + int originX = (int)_graphics.Width / 2; + int originY = (int)_graphics.Height / 2; + + int angle = 0; + + ulong frames = 0; + var start = 0; + string frameRate = ""; + + start = Environment.TickCount; + + while (true) + { + _graphics.Clear(backgroundColor); + _graphics.DrawText(5, 5, frameRate, foregroundColor); + + angle++; + for (int i = 0; i < 8; i++) + { + rot = angle * 0.0174532; //0.0174532 = one degree + + //rotateY + rotationZ = cubeVertices[i, 2] * Math.Cos(rot) - cubeVertices[i, 0] * Math.Sin(rot); + rotationX = cubeVertices[i, 2] * Math.Sin(rot) + cubeVertices[i, 0] * Math.Cos(rot); + rotationY = cubeVertices[i, 1]; + + //rotateX + rotationYY = rotationY * Math.Cos(rot) - rotationZ * Math.Sin(rot); + rotationZZ = rotationY * Math.Sin(rot) + rotationZ * Math.Cos(rot); + rotationXX = rotationX; + + //rotateZ + rotationXXX = rotationXX * Math.Cos(rot) - rotationYY * Math.Sin(rot); + rotationYYY = rotationXX * Math.Sin(rot) + rotationYY * Math.Cos(rot); + rotationZZZ = rotationZZ; + + //orthographic projection + rotationXXX = rotationXXX + originX; + rotationYYY = rotationYYY + originY; + + //store new vertices values for wireframe drawing + cubeWireframe[i, 0] = (int)rotationXXX; + cubeWireframe[i, 1] = (int)rotationYYY; + cubeWireframe[i, 2] = (int)rotationZZZ; + + DrawVertices(); + } + + DrawWireframe(); + + _graphics.Show(); + + if (++frames % 1000 == 0) + { + var now = Environment.TickCount; + var et = (now - start) / 1000d; + + frameRate = $"{(1000 / et):0.0}fps"; + start = Environment.TickCount; + } + } + } + + void DrawVertices() + { + _graphics.DrawPixel((int)rotationXXX, (int)rotationYYY); + } + + void DrawWireframe() + { + _graphics.DrawLine(cubeWireframe[0, 0], cubeWireframe[0, 1], cubeWireframe[1, 0], cubeWireframe[1, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[1, 0], cubeWireframe[1, 1], cubeWireframe[2, 0], cubeWireframe[2, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[2, 0], cubeWireframe[2, 1], cubeWireframe[3, 0], cubeWireframe[3, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[3, 0], cubeWireframe[3, 1], cubeWireframe[0, 0], cubeWireframe[0, 1], foregroundColor); + + //cross face above + _graphics.DrawLine(cubeWireframe[1, 0], cubeWireframe[1, 1], cubeWireframe[3, 0], cubeWireframe[3, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[0, 0], cubeWireframe[0, 1], cubeWireframe[2, 0], cubeWireframe[2, 1], foregroundColor); + + _graphics.DrawLine(cubeWireframe[4, 0], cubeWireframe[4, 1], cubeWireframe[5, 0], cubeWireframe[5, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[5, 0], cubeWireframe[5, 1], cubeWireframe[6, 0], cubeWireframe[6, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[6, 0], cubeWireframe[6, 1], cubeWireframe[7, 0], cubeWireframe[7, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[7, 0], cubeWireframe[7, 1], cubeWireframe[4, 0], cubeWireframe[4, 1], foregroundColor); + + _graphics.DrawLine(cubeWireframe[0, 0], cubeWireframe[0, 1], cubeWireframe[4, 0], cubeWireframe[4, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[1, 0], cubeWireframe[1, 1], cubeWireframe[5, 0], cubeWireframe[5, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[2, 0], cubeWireframe[2, 1], cubeWireframe[6, 0], cubeWireframe[6, 1], foregroundColor); + _graphics.DrawLine(cubeWireframe[3, 0], cubeWireframe[3, 1], cubeWireframe[7, 0], cubeWireframe[7, 1], foregroundColor); + } +} \ No newline at end of file diff --git a/Source/Meadow.Desktop/HMI_Views/Views/WiFiWeather.cs b/Source/Meadow.Desktop/HMI_Views/Views/WiFiWeather.cs new file mode 100644 index 00000000..e1d747e3 --- /dev/null +++ b/Source/Meadow.Desktop/HMI_Views/Views/WiFiWeather.cs @@ -0,0 +1,265 @@ +using Meadow.Foundation.Graphics; +using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; +using System; +using System.Threading.Tasks; + +namespace HMI_Views.Views; + +public class WiFiWeather +{ + Image _weatherIcon = Image.LoadFromResource("HMI_Views.Resources.w_clear.bmp"); + + int x_padding = 20; + + protected DisplayScreen DisplayScreen { get; set; } + + protected Label DayOfWeek { get; set; } + + protected Label Month { get; set; } + + protected Label Year { get; set; } + + protected Label Time { get; set; } + + protected Picture Weather { get; set; } + + protected Label Temperature { get; set; } + + protected Label Humidity { get; set; } + + protected Label Pressure { get; set; } + + protected Label FeelsLike { get; set; } + + protected Label WindDirection { get; set; } + + protected Label WindSpeed { get; set; } + + Meadow.Color backgroundColor = Meadow.Color.FromHex("#F3F7FA"); + Meadow.Color foregroundColor = Meadow.Color.Black; + + Font12x20 font12X20 = new Font12x20(); + Font12x16 font12X16 = new Font12x16(); + Font8x16 font8X16 = new Font8x16(); + + public WiFiWeather(IPixelDisplay display) + { + DisplayScreen = new DisplayScreen(display) + { + BackgroundColor = backgroundColor + }; + + Weather = new Picture(x_padding, 25, 100, 100, _weatherIcon); + DisplayScreen.Controls.Add(Weather); + + DayOfWeek = new Label(DisplayScreen.Width / 2 - x_padding, 25, DisplayScreen.Width / 2, font12X20.Height) + { + Text = $"Monday,1st", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(DayOfWeek); + + Month = new Label(DisplayScreen.Width / 2 - x_padding, 50, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) + { + Text = $"Jan", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(Month); + + Year = new Label(DisplayScreen.Width / 2 - x_padding, 95, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) + { + Text = $"0000", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X16, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(Year); + + Time = new Label(0, 150, DisplayScreen.Width, font12X20.Height * 2, ScaleFactor.X2) + { + Text = $"00:00:00 AM", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Center + }; + DisplayScreen.Controls.Add(Time); + + DisplayScreen.Controls.Add(new Label(x_padding, 215, DisplayScreen.Width / 2, font12X20.Height * 2) + { + Text = $"Temperature", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }); + DisplayScreen.Controls.Add(new Label(x_padding, 304, DisplayScreen.Width / 2, font12X20.Height * 2) + { + Text = $"Humidity", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }); + DisplayScreen.Controls.Add(new Label(x_padding, 393, DisplayScreen.Width / 2, font12X20.Height * 2) + { + Text = $"Pressure", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }); + DisplayScreen.Controls.Add(new Label(DisplayScreen.Width / 2 + x_padding, 215, DisplayScreen.Width / 2 - x_padding * 2, font12X20.Height * 2) + { + Text = $"Feels like", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }); + DisplayScreen.Controls.Add(new Label(DisplayScreen.Width / 2 - x_padding, 304, DisplayScreen.Width / 2, font12X20.Height * 2) + { + Text = $"Wind Dir", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }); + DisplayScreen.Controls.Add(new Label(DisplayScreen.Width / 2 - x_padding, 393, DisplayScreen.Width / 2, font12X20.Height * 2) + { + Text = $"Wind Spd", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }); + + Temperature = new Label(x_padding, 245, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) + { + Text = $"23°C", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }; + DisplayScreen.Controls.Add(Temperature); + Humidity = new Label(x_padding, 334, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) + { + Text = $"93%", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }; + DisplayScreen.Controls.Add(Humidity); + Pressure = new Label(x_padding, 423, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) + { + Text = $"1102hPa", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font8X16, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left + }; + DisplayScreen.Controls.Add(Pressure); + + FeelsLike = new Label(DisplayScreen.Width / 2 - x_padding, 245, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) + { + Text = $"26°C", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(FeelsLike); + WindDirection = new Label(DisplayScreen.Width / 2 - x_padding, 334, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) + { + Text = $"178°", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font12X20, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(WindDirection); + WindSpeed = new Label(DisplayScreen.Width / 2 - x_padding, 423, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) + { + Text = $"19m/s", + TextColor = foregroundColor, + BackColor = backgroundColor, + Font = font8X16, + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Right + }; + DisplayScreen.Controls.Add(WindSpeed); + } + + private static string GetOrdinalSuffix(int num) + { + string number = num.ToString(); + if (number.EndsWith("1")) return "st"; + if (number.EndsWith("2")) return "nd"; + if (number.EndsWith("3")) return "rd"; + if (number.EndsWith("11")) return "th"; + if (number.EndsWith("12")) return "th"; + if (number.EndsWith("13")) return "th"; + return "th"; + } + + public void UpdateDisplay(string weatherIcon, string temperature, string humidity, string pressure, string feelsLike, string windDirection, string windSpeed) + { + _weatherIcon = Image.LoadFromResource(weatherIcon); + Weather.Image = _weatherIcon; + + Temperature.Text = temperature; + Humidity.Text = humidity; + Pressure.Text = pressure; + FeelsLike.Text = feelsLike; + WindDirection.Text = windDirection; + WindSpeed.Text = windSpeed; + } + + public async Task Run() + { + UpdateDisplay( + weatherIcon: $"HMI_Views.Resources.w_drizzle.bmp", + temperature: $"23°C", + humidity: $"93%", + pressure: $"1102hPa", + feelsLike: $"26°C", + windDirection: $"178°", + windSpeed: $"19m/s"); + + while (true) + { + var today = DateTime.Now; + + DayOfWeek.Text = $"{today.DayOfWeek},{today.Day}{GetOrdinalSuffix(today.Day)}"; + Month.Text = $"{today.ToString("MMMM").Substring(0, today.ToString("MMMM").Length > 6 ? 7 : today.ToString("MMMM").Length)}"; + Year.Text = $"{today.ToString("yyyy")}"; + Time.Text = DateTime.Now.ToString("hh:mm:ss tt"); + await Task.Delay(TimeSpan.FromSeconds(1)); + } + } +} \ No newline at end of file diff --git a/Source/Meadow.Desktop/HMI_Views/Views/WifiWeatherV2.cs b/Source/Meadow.Desktop/HMI_Views/Views/WifiWeatherV2.cs new file mode 100644 index 00000000..1b4577e7 --- /dev/null +++ b/Source/Meadow.Desktop/HMI_Views/Views/WifiWeatherV2.cs @@ -0,0 +1,488 @@ +using Meadow; +using Meadow.Foundation.Graphics; +using Meadow.Foundation.Graphics.MicroLayout; +using Meadow.Peripherals.Displays; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace HMI_Views.Views; + +internal class WifiWeatherV2 +{ + private Color backgroundColor = Color.FromHex("10485E"); + private Color outdoorColor = Color.FromHex("C9DB31"); + private Color ForegroundColor = Color.FromHex("EEEEEE"); + private Font8x16 font8x16 = new Font8x16(); + private Font6x8 font6x8 = new Font6x8(); + + private int margin = 5; + readonly int smallMargin = 3; + readonly int graphHeight = 105; + + readonly int measureBoxWidth = 82; + + readonly int columnWidth = 100; + + readonly int rowHeight = 30; + readonly int row1 = 135; + readonly int row2 = 170; + readonly int row3 = 205; + + Image weatherIcon = Image.LoadFromResource($"HMI_Views.Resources.w_misc.bmp"); + + public LineChartSeries OutdoorSeries { get; set; } + protected DisplayScreen DisplayScreen { get; set; } + protected AbsoluteLayout SplashLayout { get; set; } + protected AbsoluteLayout DataLayout { get; set; } + protected LineChart LineChart { get; set; } + protected Picture WifiStatus { get; set; } + protected Picture SyncStatus { get; set; } + protected Picture Weather { get; set; } + protected Label Status { get; set; } + + protected Box TemperatureBox { get; set; } + protected Label TemperatureLabel { get; set; } + protected Label TemperatureValue { get; set; } + + protected Box PressureBox { get; set; } + protected Label PressureLabel { get; set; } + protected Label PressureValue { get; set; } + + protected Box HumidityBox { get; set; } + protected Label HumidityLabel { get; set; } + protected Label HumidityValue { get; set; } + + protected Label FeelsLike { get; set; } + protected Label Sunrise { get; set; } + protected Label Sunset { get; set; } + + public WifiWeatherV2(IPixelDisplay display) + { + DisplayScreen = new DisplayScreen(display) + { + BackgroundColor = backgroundColor + }; + + LoadSplashLayout(); + + DisplayScreen.Controls.Add(SplashLayout); + + LoadDataLayout(); + + DisplayScreen.Controls.Add(DataLayout); + } + + private void LoadSplashLayout() + { + SplashLayout = new AbsoluteLayout(DisplayScreen, 0, 0, DisplayScreen.Width, DisplayScreen.Height) + { + IsVisible = false + }; + + var image = Image.LoadFromResource("HMI_Views.Resources.img_meadow.bmp"); + var displayImage = new Picture(0, 0, DisplayScreen.Width, DisplayScreen.Height, image) + { + BackColor = Color.FromHex("#14607F"), + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + + SplashLayout.Controls.Add(displayImage); + } + + private void LoadDataLayout() + { + DataLayout = new AbsoluteLayout(DisplayScreen, 0, 0, DisplayScreen.Width, DisplayScreen.Height) + { + BackgroundColor = backgroundColor, + IsVisible = false + }; + + Status = new Label( + margin, + margin + 2, + 152, + font8x16.Height) + { + Text = $"Project Lab v3", + TextColor = Color.White, + Font = font8x16, + VerticalAlignment = VerticalAlignment.Center, + }; + DataLayout.Controls.Add(Status); + + var wifiImage = Image.LoadFromResource("HMI_Views.Resources.img_wifi_connecting.bmp"); + WifiStatus = new Picture( + DisplayScreen.Width - wifiImage.Width - margin, + margin, + wifiImage.Width, + font8x16.Height, + wifiImage) + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + DataLayout.Controls.Add(WifiStatus); + + var syncImage = Image.LoadFromResource("HMI_Views.Resources.img_refreshed.bmp"); + SyncStatus = new Picture( + DisplayScreen.Width - syncImage.Width - wifiImage.Width - margin * 2, + margin, + syncImage.Width, + font8x16.Height, + syncImage) + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + DataLayout.Controls.Add(SyncStatus); + + LineChart = new LineChart( + margin, + 25, + DisplayScreen.Width - margin * 2, + graphHeight) + { + BackgroundColor = Color.FromHex("082936"), + AxisColor = ForegroundColor, + ShowYAxisLabels = true, + IsVisible = false, + AlwaysShowYOrigin = false, + }; + OutdoorSeries = new LineChartSeries() + { + LineColor = outdoorColor, + PointColor = outdoorColor, + LineStroke = 1, + PointSize = 2, + ShowLines = true, + ShowPoints = true, + }; + LineChart.Series.Add(OutdoorSeries); + DataLayout.Controls.Add(LineChart); + + var weatherImage = Image.LoadFromResource("HMI_Views.Resources.w_misc.bmp"); + Weather = new Picture( + margin, + row1, + 100, + 100, + weatherImage) + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + }; + DataLayout.Controls.Add(Weather); + + #region TEMPERATURE + TemperatureBox = new Box( + columnWidth + margin * 2, + row1, + columnWidth, + rowHeight) + { + ForeColor = outdoorColor + }; + DataLayout.Controls.Add(TemperatureBox); + TemperatureLabel = new Label( + columnWidth + margin * 2 + smallMargin, + row1 + smallMargin, + measureBoxWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"TEMPERATURE", + TextColor = backgroundColor, + Font = font6x8 + }; + DataLayout.Controls.Add(TemperatureLabel); + TemperatureValue = new Label( + columnWidth + margin * 2 + smallMargin, + row1 + font6x8.Height + smallMargin * 2, + measureBoxWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"-.-C", + TextColor = backgroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(TemperatureValue); + #endregion + + #region PRESSURE + PressureBox = new Box( + columnWidth + margin * 2, + row2, + columnWidth, + rowHeight) + { + ForeColor = backgroundColor + }; + DataLayout.Controls.Add(PressureBox); + PressureLabel = new Label( + columnWidth + margin * 2 + smallMargin, + row2 + smallMargin, + measureBoxWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"PRESSURE", + TextColor = ForegroundColor, + Font = font6x8 + }; + DataLayout.Controls.Add(PressureLabel); + PressureValue = new Label( + columnWidth + margin * 2 + smallMargin, + row2 + font6x8.Height + smallMargin * 2, + measureBoxWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"-.-hPa", + TextColor = ForegroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(PressureValue); + #endregion + + #region HUMIDITY + HumidityBox = new Box( + columnWidth + margin * 2, + row3, + columnWidth, + rowHeight) + { + ForeColor = backgroundColor + }; + DataLayout.Controls.Add(HumidityBox); + HumidityLabel = new Label( + columnWidth + margin * 2 + smallMargin, + row3 + smallMargin, + measureBoxWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"HUMIDITY", + TextColor = ForegroundColor, + Font = font6x8 + }; + DataLayout.Controls.Add(HumidityLabel); + HumidityValue = new Label( + columnWidth + margin * 2 + smallMargin, + row3 + font6x8.Height + smallMargin * 2, + columnWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"-.-%", + TextColor = ForegroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(HumidityValue); + #endregion + + DataLayout.Controls.Add(new Label( + columnWidth * 2 + margin * 3 + smallMargin, + row1 + smallMargin, + measureBoxWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"FEELS LIKE", + TextColor = ForegroundColor, + Font = font6x8 + }); + FeelsLike = new Label( + columnWidth * 2 + margin * 3 + smallMargin, + row1 + font6x8.Height + smallMargin * 2, + columnWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"-.-C", + TextColor = ForegroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(FeelsLike); + + DataLayout.Controls.Add(new Label( + columnWidth * 2 + margin * 3 + smallMargin, + row2 + smallMargin, + measureBoxWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"SUNRISE", + TextColor = ForegroundColor, + Font = font6x8 + }); + Sunrise = new Label( + columnWidth * 2 + margin * 3 + smallMargin, + row2 + font6x8.Height + smallMargin * 2, + columnWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"--:-- --", + TextColor = ForegroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(Sunrise); + + DataLayout.Controls.Add(new Label( + columnWidth * 2 + margin * 3 + smallMargin, + row3 + smallMargin, + measureBoxWidth - smallMargin * 2, + font6x8.Height) + { + Text = $"SUNSET", + TextColor = ForegroundColor, + Font = font6x8 + }); + Sunset = new Label( + columnWidth * 2 + margin * 3 + smallMargin, + row3 + font6x8.Height + smallMargin * 2, + columnWidth - smallMargin * 2, + font6x8.Height * 2) + { + Text = $"--:-- --", + TextColor = ForegroundColor, + Font = font6x8, + ScaleFactor = ScaleFactor.X2 + }; + DataLayout.Controls.Add(Sunset); + } + + public void ShowSplashScreen() + { + DataLayout.IsVisible = false; + SplashLayout.IsVisible = true; + } + + public void ShowDataScreen() + { + SplashLayout.IsVisible = false; + DataLayout.IsVisible = true; + } + + public void UpdateStatus(string status) + { + Status.Text = status; + } + + public void UpdateWiFiStatus(bool isConnected) + { + var imageWiFi = isConnected + ? Image.LoadFromResource("HMI_Views.Resources.img_wifi_connected.bmp") + : Image.LoadFromResource("HMI_Views.Resources.img_wifi_connecting.bmp"); + WifiStatus.Image = imageWiFi; + } + + public void UpdateSyncStatus(bool isSyncing) + { + var imageSync = isSyncing + ? Image.LoadFromResource("HMI_Views.Resources.img_refreshing.bmp") + : Image.LoadFromResource("HMI_Views.Resources.img_refreshed.bmp"); + SyncStatus.Image = imageSync; + } + + private void UpdateReadingType(int type) + { + TemperatureBox.ForeColor = PressureBox.ForeColor = HumidityBox.ForeColor = backgroundColor; + TemperatureLabel.TextColor = PressureLabel.TextColor = HumidityLabel.TextColor = ForegroundColor; + TemperatureValue.TextColor = PressureValue.TextColor = HumidityValue.TextColor = ForegroundColor; + + switch (type) + { + case 0: + TemperatureBox.ForeColor = outdoorColor; + TemperatureLabel.TextColor = backgroundColor; + TemperatureValue.TextColor = backgroundColor; + break; + case 1: + PressureBox.ForeColor = outdoorColor; + PressureLabel.TextColor = backgroundColor; + PressureValue.TextColor = backgroundColor; + break; + case 2: + HumidityBox.ForeColor = outdoorColor; + HumidityLabel.TextColor = backgroundColor; + HumidityLabel.TextColor = backgroundColor; + break; + } + } + + public void UpdateReadings( + int readingType, + string icon, + double temperature, + double humidity, + double pressure, + double feelsLike, + DateTime sunrise, + DateTime sunset, + List outdoorReadings) + { + DisplayScreen.BeginUpdate(); + + UpdateReadingType(readingType); + + weatherIcon = Image.LoadFromResource(icon); + Weather.Image = weatherIcon; + + TemperatureValue.Text = $"{temperature:N1}C"; + HumidityValue.Text = $"{humidity:N1}%"; + PressureValue.Text = $"{pressure:N2}atm"; + FeelsLike.Text = $"{feelsLike:N1}C"; + Sunrise.Text = $"{sunrise:hh:mm tt}"; + Sunset.Text = $"{sunset:hh:mm tt}"; + + OutdoorSeries.Points.Clear(); + + for (var p = 0; p < outdoorReadings.Count; p++) + { + OutdoorSeries.Points.Add(p * 2, outdoorReadings[p]); + } + + DisplayScreen.EndUpdate(); + } + + public async Task Run() + { + //ShowSplashScreen(); + //Thread.Sleep(3000); + ShowDataScreen(); + + var random = new Random(); + + int x = 0; + + var outdoorList = new List + { + 25.3, + 26.1, + 25.7, + 27.9, + 26.3, + 25.6, + 26.3, + 27.2, + 27.6 + }; + + while (true) + { + UpdateStatus(DateTime.Now.ToString("hh:mm tt | dd/MM/yy")); + + UpdateReadings( + readingType: 0, + icon: "HMI_Views.Resources.w_clear.bmp", + temperature: random.Next(10, 13), + humidity: random.Next(65, 75), + pressure: 1 + random.NextDouble(), + feelsLike: random.Next(22, 25), + sunrise: DateTime.Now, + sunset: DateTime.Now.AddHours(8), + outdoorReadings: outdoorList); + + await Task.Delay(1000); + } + } +} \ No newline at end of file diff --git a/Source/Meadow.Desktop/WinForms/readme.md b/Source/Meadow.Desktop/HMI_Views/readme.md similarity index 100% rename from Source/Meadow.Desktop/WinForms/readme.md rename to Source/Meadow.Desktop/HMI_Views/readme.md diff --git a/Source/Meadow.Desktop/WinForms/MeadowApp.cs b/Source/Meadow.Desktop/WinForms/MeadowApp.cs deleted file mode 100644 index eda4e8e0..00000000 --- a/Source/Meadow.Desktop/WinForms/MeadowApp.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Meadow; -using Meadow.Foundation.Displays; -using System.Threading; -using System.Threading.Tasks; -using WinFormsMeadow.Views; - -namespace WinFormsMeadow -{ - public class MeadowApp : App - { - public override Task Initialize() - { - // Default WinForms screen (800,600) - //_display = new WinFormsDisplay(); - //var views = new RotatingCube(_display); - - // Screen size of a ILI9488 display - //_display = new WinFormsDisplay(320, 480); - //var views = new WiFiWeather(_display); - - // Screen size of a EPD4IN2bV2 e-paper display - //_display = new WinFormsDisplay(300, 400); - //var views = new HomeWidget(_display); - - // Screen size of a ILI9341 display - //_display = new WinFormsDisplay(320, 240); - //var views = new CultivarView(Device.Display); - //var views = new ProjectLabDemoView(Device.Display); - //var views = new AtmosphericHMI(Device.Display); - var views = new WifiWeatherV2(Device.Display); - - _ = Task.Run(() => - { - Thread.Sleep(2000); - views.Run(); - }); - - return Task.CompletedTask; - } - - public override Task Run() - { - // NOTE: this will not return until the display is closed - ExecutePlatformDisplayRunner(); - - return Task.CompletedTask; - } - - private void ExecutePlatformDisplayRunner() - { -#if WINDOWS - System.Windows.Forms.Application.Run(Device.Display as System.Windows.Forms.Form); -#endif - if (Device.Display is GtkDisplay gtk) - { - gtk.Run(); - } - } - } -} \ No newline at end of file diff --git a/Source/Meadow.Desktop/WinForms/Views/AtmosphericHMI.cs b/Source/Meadow.Desktop/WinForms/Views/AtmosphericHMI.cs deleted file mode 100644 index 54665a1f..00000000 --- a/Source/Meadow.Desktop/WinForms/Views/AtmosphericHMI.cs +++ /dev/null @@ -1,146 +0,0 @@ -using Meadow.Foundation.Graphics; -using Meadow.Foundation.Graphics.MicroLayout; -using Meadow.Peripherals.Displays; -using System; -using System.Threading.Tasks; - -namespace WinFormsMeadow.Views -{ - public class AtmosphericHMI - { - int rowHeight = 60; - int rowMargin = 15; - - protected DisplayScreen DisplayScreen { get; set; } - - protected Label Light { get; set; } - - protected Label Pressure { get; set; } - - protected Label Humidity { get; set; } - - protected Label Temperature { get; set; } - - Meadow.Color backgroundColor = Meadow.Color.FromHex("#F3F7FA"); - Meadow.Color foregroundColor = Meadow.Color.Black; - - Font12x20 font12X20 = new Font12x20(); - - public AtmosphericHMI(IPixelDisplay display) - { - DisplayScreen = new DisplayScreen(display) - { - BackgroundColor = backgroundColor - }; - - DisplayScreen.Controls.Add(new GradientBox(0, 0, display.Width, display.Height) - { - StartColor = Meadow.Color.FromHex("#5AC0EA"), - EndColor = Meadow.Color.FromHex("#B8E4F6") - }); - - DisplayScreen.Controls.Add(new Label(rowMargin, 0, DisplayScreen.Width / 2, rowHeight) - { - Text = $"LIGHT", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Left - }); - DisplayScreen.Controls.Add(new Label(rowMargin, rowHeight, DisplayScreen.Width / 2, rowHeight) - { - Text = $"PRESSURE", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Left - }); - DisplayScreen.Controls.Add(new Label(rowMargin, rowHeight * 2, DisplayScreen.Width / 2, rowHeight) - { - Text = $"HUMIDITY", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Left - }); - DisplayScreen.Controls.Add(new Label(rowMargin, rowHeight * 3, DisplayScreen.Width / 2, rowHeight) - { - Text = $"TEMPERATURE", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Left - }); - - Light = new Label(DisplayScreen.Width / 2 - rowMargin, 0, DisplayScreen.Width / 2, rowHeight) - { - Text = $"- Lx", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(Light); - - Pressure = new Label(DisplayScreen.Width / 2 - rowMargin, rowHeight, DisplayScreen.Width / 2, rowHeight) - { - Text = $"- Mb", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(Pressure); - - Humidity = new Label(DisplayScreen.Width / 2 - rowMargin, rowHeight * 2, DisplayScreen.Width / 2, rowHeight) - { - Text = $"- %", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(Humidity); - - Temperature = new Label(DisplayScreen.Width / 2 - rowMargin, rowHeight * 3, DisplayScreen.Width / 2, rowHeight) - { - Text = $"- °C", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Center, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(Temperature); - } - - public void UpdateAtmosphericConditions(string light, string pressure, string humidity, string temperature) - { - DisplayScreen.BeginUpdate(); - - Light.Text = light; - Pressure.Text = pressure; - Humidity.Text = humidity; - Temperature.Text = temperature; - - DisplayScreen.EndUpdate(); - } - - - public async Task Run() - { - var random = new Random(); - - while (true) - { - UpdateAtmosphericConditions( - $"{random.Next(70, 80)} Lx", - $"{random.Next(1000, 1010)} Mb", - $"{random.Next(25, 35)} % ", - $"{random.Next(25, 35)} °C" - ); - - await Task.Delay(1000); - } - } - } -} diff --git a/Source/Meadow.Desktop/WinForms/Views/CultivarView.cs b/Source/Meadow.Desktop/WinForms/Views/CultivarView.cs deleted file mode 100644 index 19b21c37..00000000 --- a/Source/Meadow.Desktop/WinForms/Views/CultivarView.cs +++ /dev/null @@ -1,260 +0,0 @@ -using Meadow.Foundation.Graphics; -using Meadow.Foundation.Graphics.MicroLayout; -using Meadow.Peripherals.Displays; -using System; -using System.Threading.Tasks; - -namespace WinFormsMeadow.Views -{ - public class CultivarView - { - DisplayScreen screen; - - Image imgWifi = Image.LoadFromResource("WinFormsMeadow.Resources.img-wifi.bmp"); - Image imgSync = Image.LoadFromResource("WinFormsMeadow.Resources.img-sync.bmp"); - - Image imgRed = Image.LoadFromResource("WinFormsMeadow.Resources.img-red.bmp"); - Image imgGreen = Image.LoadFromResource("WinFormsMeadow.Resources.img-green.bmp"); - Image imgWifiFade = Image.LoadFromResource("WinFormsMeadow.Resources.img-wifi-fade.bmp"); - Image imgSyncFade = Image.LoadFromResource("WinFormsMeadow.Resources.img-sync-fade.bmp"); - - protected Label StatusLabel { get; set; } - - protected Label TemperatureLabel { get; set; } - - protected Label HumidityLabel { get; set; } - - protected Label SoilMoistureLabel { get; set; } - - protected Picture ledLights { get; set; } - - protected Picture wifi { get; set; } - - protected Picture sync { get; set; } - - protected Picture ledWater { get; set; } - - protected Picture ledVents { get; set; } - - protected Picture ledHeater { get; set; } - - public CultivarView(IPixelDisplay _display) - { - screen = new DisplayScreen(_display); - - screen.Controls.Add(new Box(0, 0, screen.Width, screen.Height) { ForeColor = Meadow.Color.White }); - screen.Controls.Add(new Box(0, 27, 106, 93) { ForeColor = Meadow.Color.FromHex("#B35E2C") }); - screen.Controls.Add(new Box(106, 27, 108, 93) { ForeColor = Meadow.Color.FromHex("#1A80AA") }); - screen.Controls.Add(new Box(214, 27, 106, 93) { ForeColor = Meadow.Color.FromHex("#98A645") }); - - screen.Controls.Add(new Box(160, 120, 1, screen.Height) { ForeColor = Meadow.Color.Black, IsFilled = false }); - screen.Controls.Add(new Box(0, 180, screen.Width, 1) { ForeColor = Meadow.Color.Black, IsFilled = false }); - - StatusLabel = new Label(2, 6, 12, 16) - { - Text = "Hello Meadow", - Font = new Font12x20(), - TextColor = Meadow.Color.Black - }; - screen.Controls.Add(StatusLabel); - - wifi = new Picture(286, 3, 30, 21, imgWifi); - screen.Controls.Add(wifi); - - sync = new Picture(260, 3, 21, 21, imgSync); - screen.Controls.Add(sync); - - screen.Controls.Add(new Label(5, 32, 12, 16) - { - Text = "TEMP.", - Font = new Font12x16(), - TextColor = Meadow.Color.White - }); - screen.Controls.Add(new Label(77, 99, 12, 16) - { - Text = "°C", - Font = new Font12x20(), - TextColor = Meadow.Color.White - }); - - screen.Controls.Add(new Label(111, 32, 12, 16) - { - Text = "HUM.", - Font = new Font12x16(), - TextColor = Meadow.Color.White - }); - screen.Controls.Add(new Label(197, 99, 12, 16) - { - Text = "%", - Font = new Font12x20(), - TextColor = Meadow.Color.White - }); - - screen.Controls.Add(new Label(219, 32, 12, 16) - { - Text = "S.M.", - Font = new Font12x16(), - TextColor = Meadow.Color.White - }); - screen.Controls.Add(new Label(303, 99, 12, 16) - { - Text = "%", - Font = new Font12x20(), - TextColor = Meadow.Color.White - }); - - TemperatureLabel = new Label(50, 70, 12, 16, ScaleFactor.X2) - { - Text = "31", - Font = new Font12x16(), - TextColor = Meadow.Color.White, - HorizontalAlignment = HorizontalAlignment.Center, - }; - screen.Controls.Add(TemperatureLabel); - HumidityLabel = new Label(155, 70, 12, 16, ScaleFactor.X2) - { - Text = "33", - Font = new Font12x16(), - TextColor = Meadow.Color.White, - HorizontalAlignment = HorizontalAlignment.Center, - }; - screen.Controls.Add(HumidityLabel); - SoilMoistureLabel = new Label(260, 70, 12, 16, ScaleFactor.X2) - { - Text = "23", - Font = new Font12x16(), - TextColor = Meadow.Color.White, - HorizontalAlignment = HorizontalAlignment.Center, - }; - screen.Controls.Add(SoilMoistureLabel); - - - ledLights = new Picture(8, 128, 46, 46, imgGreen) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - screen.Controls.Add(ledLights); - screen.Controls.Add(new Label(60, 145, 12, 16, ScaleFactor.X2) - { - Text = "Lights", - Font = new Font8x12(), - TextColor = Meadow.Color.Black - }); - - ledWater = new Picture(168, 128, 46, 46, imgGreen) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - screen.Controls.Add(ledWater); - screen.Controls.Add(new Label(60, 205, 12, 16, ScaleFactor.X2) - { - Text = "Water", - Font = new Font8x12(), - TextColor = Meadow.Color.Black - }); - - ledVents = new Picture(8, 188, 46, 46, imgGreen) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - screen.Controls.Add(ledVents); - screen.Controls.Add(new Label(220, 145, 12, 16, ScaleFactor.X2) - { - Text = "Vents", - Font = new Font8x12(), - TextColor = Meadow.Color.Black - }); - - ledHeater = new Picture(168, 188, 46, 46, imgGreen) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - screen.Controls.Add(ledHeater); - screen.Controls.Add(new Label(220, 205, 12, 16, ScaleFactor.X2) - { - Text = "Heater", - Font = new Font8x12(), - TextColor = Meadow.Color.Black - }); - } - - public void UpdateWifi(bool on) - { - wifi.Image = on ? imgWifi : imgWifiFade; - } - - public void UpdateSync(bool on) - { - sync.Image = on ? imgSync : imgSyncFade; - } - - public void UpdateStatus(string status) - { - StatusLabel.Text = status; - } - - public void UpdateTemperature(double temp) - { - TemperatureLabel.Text = temp.ToString("N0"); - } - - public void UpdateHumidity(double humidity) - { - HumidityLabel.Text = humidity.ToString("N0"); - } - - public void UpdateSoilMoisture(double moisture) - { - SoilMoistureLabel.Text = moisture.ToString("N0"); - } - - public void UpdateLights(bool on) - { - ledLights.Image = on ? imgGreen : imgRed; - } - - public void UpdateHeater(bool on) - { - ledHeater.Image = on ? imgGreen : imgRed; - } - - public void UpdateWater(bool on) - { - ledWater.Image = on ? imgGreen : imgRed; - } - - public void UpdateVents(bool on) - { - ledVents.Image = on ? imgGreen : imgRed; - } - - public async Task Run() - { - bool status = false; - - while (true) - { - var random = new Random(); - - UpdateWifi(status); - UpdateSync(status); - - UpdateTemperature(random.Next(20, 25)); - UpdateHumidity(random.Next(30, 35)); - UpdateSoilMoisture(random.Next(40, 45)); - - UpdateLights(status); - UpdateHeater(status); - UpdateWater(status); - UpdateVents(status); - status = !status; - - await Task.Delay(1000); - } - } - } -} \ No newline at end of file diff --git a/Source/Meadow.Desktop/WinForms/Views/HomeWidget.cs b/Source/Meadow.Desktop/WinForms/Views/HomeWidget.cs deleted file mode 100644 index cac2c173..00000000 --- a/Source/Meadow.Desktop/WinForms/Views/HomeWidget.cs +++ /dev/null @@ -1,271 +0,0 @@ -using Meadow; -using Meadow.Foundation.Graphics; -using Meadow.Foundation.Graphics.MicroLayout; -using Meadow.Peripherals.Displays; -using System; -using System.Threading.Tasks; - -namespace WinFormsMeadow.Views -{ - public class HomeWidget - { - Image _weatherIcon = Image.LoadFromResource("WinFormsMeadow.Resources.w_misc.bmp"); - - int padding = 10; - int small_padding = 5; - - protected DisplayScreen DisplayScreen { get; set; } - - protected Label YearMonth { get; set; } - - protected Label WeekdayDay { get; set; } - - protected Label Time { get; set; } - - protected Picture Weather { get; set; } - - protected Label WeatherTemperature { get; set; } - - protected Label WeatherHumidity { get; set; } - - protected Label Temperature { get; set; } - - protected Label Humidity { get; set; } - - protected Label UpcomingWeekMealA { get; set; } - - protected Label UpcomingWeekMealB { get; set; } - - protected Label WeekAfterMealA { get; set; } - - protected Label WeekAfterMealB { get; set; } - - Color backgroundColor = Color.White; - Color foregroundColor = Color.Black; - - Font12x20 font12X20 = new Font12x20(); - Font6x8 font6x8 = new Font6x8(); - - public HomeWidget(IPixelDisplay display) - { - DisplayScreen = new DisplayScreen(display) - { - BackgroundColor = backgroundColor - }; - - Weather = new Picture(padding, padding, 100, 100, _weatherIcon); - DisplayScreen.Controls.Add(Weather); - - DisplayScreen.Controls.Add(new Box(padding, padding, 100, 100) - { - ForeColor = Color.Black, - IsFilled = false - }); - - WeatherTemperature = new Label(padding + 2, padding + 2, font6x8.Width * 4, font6x8.Height) - { - Text = $"--C", - TextColor = foregroundColor, - Font = font6x8 - }; - DisplayScreen.Controls.Add(WeatherTemperature); - - WeatherHumidity = new Label(84, padding + 2, font6x8.Width * 4, font6x8.Height) - { - Text = $"--%", - TextColor = foregroundColor, - Font = font6x8, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(WeatherHumidity); - - YearMonth = new Label(120, padding, 170, font12X20.Height) - { - Text = $"---- ----", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(YearMonth); - - WeekdayDay = new Label(120, 40, 170, font12X20.Height) - { - Text = $"---- ----", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(WeekdayDay); - - Time = new Label(120, 70, 170, font12X20.Height * 2) - { - Text = $"--:--", - TextColor = foregroundColor, - Font = font12X20, - ScaleFactor = ScaleFactor.X2, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(Time); - - DisplayScreen.Controls.Add(new Label(padding, 120, 135, font12X20.Height) - { - Text = $"TEMPERATURE", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }); - - DisplayScreen.Controls.Add(new Label(155, 120, 135, font12X20.Height) - { - Text = $"HUMIDITY", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }); - - Temperature = new Label(padding, 150, 135, font12X20.Height * 2) - { - Text = $"--.-°C", - TextColor = foregroundColor, - Font = font12X20, - ScaleFactor = ScaleFactor.X2, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }; - DisplayScreen.Controls.Add(Temperature); - - Humidity = new Label(155, 150, 135, font12X20.Height * 2) - { - Text = $"--%", - TextColor = foregroundColor, - Font = font12X20, - ScaleFactor = ScaleFactor.X2, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(Humidity); - - DisplayScreen.Controls.Add(new Box(padding, 204, 280, 1) - { - ForeColor = Color.Black - }); - - DisplayScreen.Controls.Add(new Label(padding, 220, DisplayScreen.Width / 2, font12X20.Height) - { - Text = $"UPCOMING WEEK (#2):", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }); - - UpcomingWeekMealA = new Label(padding, 250, DisplayScreen.Width / 2, font12X20.Height) - { - Text = $"- Meal A", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }; - DisplayScreen.Controls.Add(UpcomingWeekMealA); - - UpcomingWeekMealB = new Label(padding, 280, DisplayScreen.Width / 2, font12X20.Height) - { - Text = $"- Meal B", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }; - DisplayScreen.Controls.Add(UpcomingWeekMealB); - - DisplayScreen.Controls.Add(new Label(padding, 310, DisplayScreen.Width / 2, font12X20.Height) - { - Text = $"WEEK AFTER (#3):", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }); - - WeekAfterMealA = new Label(padding, 340, DisplayScreen.Width / 2, font12X20.Height) - { - Text = $"- Meal A", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }; - DisplayScreen.Controls.Add(WeekAfterMealA); - - WeekAfterMealB = new Label(padding, 370, DisplayScreen.Width / 2, font12X20.Height) - { - Text = $"- Meal B", - TextColor = foregroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }; - DisplayScreen.Controls.Add(WeekAfterMealB); - } - - private static string GetOrdinalSuffix(int num) - { - string number = num.ToString(); - if (number.EndsWith("1")) return "st"; - if (number.EndsWith("2")) return "nd"; - if (number.EndsWith("3")) return "rd"; - if (number.EndsWith("11")) return "th"; - if (number.EndsWith("12")) return "th"; - if (number.EndsWith("13")) return "th"; - return "th"; - } - - public void UpdateDisplay( - string weatherIcon, - double weatherTemperature, - double weatherHumidity, - double temperature, - double humidity) - { - DisplayScreen.BeginUpdate(); - - _weatherIcon = Image.LoadFromResource(weatherIcon); - Weather.Image = _weatherIcon; - - int TIMEZONE_OFFSET = -8; - var today = DateTime.Now.AddHours(TIMEZONE_OFFSET); - - YearMonth.Text = today.ToString("yyyy MMMM"); - WeekdayDay.Text = $"{today.DayOfWeek},{today.Day}{GetOrdinalSuffix(today.Day)}"; - Time.Text = today.ToString("hh:mm"); - - WeatherTemperature.Text = $"{weatherTemperature:N0}°C"; - WeatherHumidity.Text = $"{weatherHumidity:N0}%"; - Temperature.Text = $"{temperature:N1}°C"; - Humidity.Text = $"{humidity:N0}%"; - - DisplayScreen.EndUpdate(); - } - - public async Task Run() - { - while (true) - { - UpdateDisplay( - weatherIcon: $"WinFormsMeadow.Resources.w_drizzle.bmp", - weatherTemperature: 10, - weatherHumidity: 78, - temperature: 23, - humidity: 93); - - await Task.Delay(TimeSpan.FromSeconds(1)); - } - } - } -} \ No newline at end of file diff --git a/Source/Meadow.Desktop/WinForms/Views/ProjectLabDemoView.cs b/Source/Meadow.Desktop/WinForms/Views/ProjectLabDemoView.cs deleted file mode 100644 index c8a33c0e..00000000 --- a/Source/Meadow.Desktop/WinForms/Views/ProjectLabDemoView.cs +++ /dev/null @@ -1,718 +0,0 @@ -using Meadow.Foundation.Graphics; -using Meadow.Foundation.Graphics.MicroLayout; -using Meadow.Peripherals.Displays; -using System; -using System.Threading.Tasks; - -namespace WinFormsMeadow.Views -{ - internal class ProjectLabDemoView - { - readonly int margin = 5; - readonly int smallMargin = 3; - readonly int graphHeight = 106; - - readonly int measureBoxWidth = 82; - - readonly int column1 = 96; - readonly int column2 = 206; - readonly int columnWidth = 109; - - readonly int rowHeight = 30; - readonly int row1 = 135; - readonly int row2 = 170; - readonly int row3 = 205; - - readonly int sensorBarHeight = 14; - readonly int sensorBarInitialWidth = 6; - readonly int sensorBarX = 184; - readonly int sensorBarY = 202; - readonly int sensorBarZ = 220; - - readonly int clockX = 244; - readonly int clockWidth = 71; - - readonly int dPadSize = 9; - - protected DisplayScreen DisplayScreen { get; set; } - - protected AbsoluteLayout SplashLayout { get; set; } - - protected AbsoluteLayout DataLayout { get; set; } - - public LineChartSeries LineChartSeries { get; set; } - - protected LineChart LineChart { get; set; } - - protected Picture WifiStatus { get; set; } - - protected Picture SyncStatus { get; set; } - - protected Label Status { get; set; } - - protected Box TemperatureBox { get; set; } - protected Label TemperatureLabel { get; set; } - protected Label TemperatureValue { get; set; } - - protected Box PressureBox { get; set; } - protected Label PressureLabel { get; set; } - protected Label PressureValue { get; set; } - - protected Box HumidityBox { get; set; } - protected Label HumidityLabel { get; set; } - protected Label HumidityValue { get; set; } - - protected Box LuminanceBox { get; set; } - protected Label LuminanceLabel { get; set; } - protected Label LuminanceValue { get; set; } - - protected Label Date { get; set; } - protected Label Time { get; set; } - - protected Box Up { get; set; } - protected Box Down { get; set; } - protected Box Left { get; set; } - protected Box Right { get; set; } - - protected Box AccelerometerX { get; set; } - protected Box AccelerometerY { get; set; } - protected Box AccelerometerZ { get; set; } - - protected Box GyroscopeX { get; set; } - protected Box GyroscopeY { get; set; } - protected Box GyroscopeZ { get; set; } - - protected Label ConnectionErrorLabel { get; set; } - - private Meadow.Color backgroundColor = Meadow.Color.FromHex("10485E"); - private Meadow.Color selectedColor = Meadow.Color.FromHex("C9DB31"); - private Meadow.Color accentColor = Meadow.Color.FromHex("EF7D3B"); - private Meadow.Color ForegroundColor = Meadow.Color.FromHex("EEEEEE"); - private Font12x20 font12X20 = new Font12x20(); - private Font8x12 font8x12 = new Font8x12(); - private Font8x16 font8x16 = new Font8x16(); - private Font6x8 font6x8 = new Font6x8(); - - public ProjectLabDemoView(IPixelDisplay display) - { - DisplayScreen = new DisplayScreen(display) - { - BackgroundColor = backgroundColor - }; - - LoadSplashLayout(); - - DisplayScreen.Controls.Add(SplashLayout); - - LoadDataLayout(); - - DisplayScreen.Controls.Add(DataLayout); - } - - private void LoadSplashLayout() - { - SplashLayout = new AbsoluteLayout(DisplayScreen, 0, 0, DisplayScreen.Width, DisplayScreen.Height) - { - IsVisible = false - }; - - var image = Image.LoadFromResource("WinFormsMeadow.Resources.img_meadow.bmp"); - var displayImage = new Picture(0, 0, DisplayScreen.Width, DisplayScreen.Height, image) - { - BackColor = Meadow.Color.FromHex("#14607F"), - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - - SplashLayout.Controls.Add(displayImage); - } - - - - private void LoadDataLayout() - { - DataLayout = new AbsoluteLayout(DisplayScreen, 0, 0, DisplayScreen.Width, DisplayScreen.Height) - { - BackgroundColor = backgroundColor, - IsVisible = false - }; - - DataLayout.Controls.Add(new Label( - margin, - margin, - DisplayScreen.Width / 2, - font8x16.Height) - { - Text = $"Project Lab v3", - TextColor = Meadow.Color.White, - Font = font8x16 - }); - - var wifiImage = Image.LoadFromResource("WinFormsMeadow.Resources.img_wifi_connecting.bmp"); - WifiStatus = new Picture( - DisplayScreen.Width - wifiImage.Width - margin, - margin, - wifiImage.Width, - font8x16.Height, - wifiImage) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - DataLayout.Controls.Add(WifiStatus); - - var syncImage = Image.LoadFromResource("WinFormsMeadow.Resources.img_refreshed.bmp"); - SyncStatus = new Picture( - DisplayScreen.Width - syncImage.Width - wifiImage.Width - margin * 2, - margin, - syncImage.Width, - font8x16.Height, - syncImage) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - DataLayout.Controls.Add(SyncStatus); - - LineChart = new LineChart( - margin, - margin + font8x16.Height + smallMargin, - DisplayScreen.Width - margin * 2, - graphHeight) - { - BackgroundColor = Meadow.Color.FromHex("082936"), - AxisColor = ForegroundColor, - ShowYAxisLabels = true, - IsVisible = false, - AlwaysShowYOrigin = false, - }; - LineChartSeries = new LineChartSeries() - { - LineColor = selectedColor, - PointColor = selectedColor, - LineStroke = 1, - PointSize = 2, - ShowLines = true, - ShowPoints = true, - }; - LineChart.Series.Add(LineChartSeries); - DataLayout.Controls.Add(LineChart); - - #region TEMPERATURE - TemperatureBox = new Box(margin, row1, measureBoxWidth, rowHeight) - { - ForeColor = selectedColor - }; - DataLayout.Controls.Add(TemperatureBox); - TemperatureLabel = new Label( - margin + smallMargin, - row1 + smallMargin, - measureBoxWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"TEMPERATURE", - TextColor = backgroundColor, - Font = font6x8 - }; - DataLayout.Controls.Add(TemperatureLabel); - TemperatureValue = new Label( - margin + smallMargin, - row1 + font6x8.Height + smallMargin * 2, - measureBoxWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"-.-C", - TextColor = backgroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(TemperatureValue); - #endregion - - #region PRESSURE - PressureBox = new Box( - margin, - row2, - measureBoxWidth, - rowHeight) - { - ForeColor = backgroundColor - }; - DataLayout.Controls.Add(PressureBox); - PressureLabel = new Label( - margin + smallMargin, - row2 + smallMargin, - measureBoxWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"PRESSURE", - TextColor = ForegroundColor, - Font = font6x8 - }; - DataLayout.Controls.Add(PressureLabel); - PressureValue = new Label( - margin + smallMargin, - row2 + font6x8.Height + smallMargin * 2, - measureBoxWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"-.-atm", - TextColor = ForegroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(PressureValue); - #endregion - - #region HUMIDITY - HumidityBox = new Box( - margin, - row3, - measureBoxWidth, - rowHeight) - { - ForeColor = backgroundColor - }; - DataLayout.Controls.Add(HumidityBox); - HumidityLabel = new Label( - margin + smallMargin, - row3 + smallMargin, - measureBoxWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"HUMIDITY", - TextColor = ForegroundColor, - Font = font6x8 - }; - DataLayout.Controls.Add(HumidityLabel); - HumidityValue = new Label( - margin + smallMargin, - row3 + font6x8.Height + smallMargin * 2, - columnWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"-.-%", - TextColor = ForegroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(HumidityValue); - #endregion - - #region LUMINANCE - LuminanceBox = new Box( - column1, - row1, - columnWidth, - rowHeight) - { - ForeColor = backgroundColor - }; - DataLayout.Controls.Add(LuminanceBox); - LuminanceLabel = new Label( - column1 + smallMargin, - row1 + smallMargin, - columnWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"LUMINANCE", - TextColor = ForegroundColor, - Font = font6x8 - }; - DataLayout.Controls.Add(LuminanceLabel); - LuminanceValue = new Label( - column1 + smallMargin, - row1 + font6x8.Height + smallMargin * 2, - columnWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"0Lux", - TextColor = ForegroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(LuminanceValue); - #endregion - - #region ACCELEROMETER - DataLayout.Controls.Add(new Label( - column1 + smallMargin, - row2 + smallMargin, - columnWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"ACCELEROMETER (g)", - TextColor = Meadow.Color.White, - Font = font6x8 - }); - - DataLayout.Controls.Add(new Label( - column1 + smallMargin, - sensorBarX, - font6x8.Width * 2, - font6x8.Height * 2) - { - Text = $"X", - TextColor = Meadow.Color.White, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }); - AccelerometerX = new Box( - column1 + font6x8.Width * 2 + margin, - sensorBarX, - sensorBarInitialWidth, - sensorBarHeight) - { - ForeColor = Meadow.Color.FromHex("98A645") - }; - DataLayout.Controls.Add(AccelerometerX); - - DataLayout.Controls.Add(new Label( - column1 + smallMargin, - sensorBarY, - font6x8.Width * 2, - font6x8.Height * 2) - { - Text = $"Y", - TextColor = Meadow.Color.White, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }); - AccelerometerY = new Box( - column1 + font6x8.Width * 2 + margin, - sensorBarY, - sensorBarInitialWidth, - sensorBarHeight) - { - ForeColor = Meadow.Color.FromHex("C9DB31") - }; - DataLayout.Controls.Add(AccelerometerY); - - DataLayout.Controls.Add(new Label( - column1 + smallMargin, - sensorBarZ, - font6x8.Width * 2, - font6x8.Height * 2) - { - Text = $"Z", - TextColor = Meadow.Color.White, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }); - AccelerometerZ = new Box( - column1 + font6x8.Width * 2 + margin, - sensorBarZ, - sensorBarInitialWidth, - sensorBarHeight) - { - ForeColor = Meadow.Color.FromHex("E1EB8B") - }; - DataLayout.Controls.Add(AccelerometerZ); - #endregion - - #region GYROSCOPE - DataLayout.Controls.Add(new Label( - column2 + smallMargin, - row2 + smallMargin, - columnWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"GYROSCOPE (rpm)", - TextColor = Meadow.Color.White, - Font = font6x8 - }); - - DataLayout.Controls.Add(new Label( - column2 + smallMargin, - sensorBarX, - font6x8.Width * 2, - font6x8.Height * 2) - { - Text = $"X", - TextColor = Meadow.Color.White, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }); - GyroscopeX = new Box( - column2 + font6x8.Width * 2 + margin, - sensorBarX, - sensorBarInitialWidth, - sensorBarHeight) - { - ForeColor = Meadow.Color.FromHex("98A645") - }; - DataLayout.Controls.Add(GyroscopeX); - - DataLayout.Controls.Add(new Label( - column2 + smallMargin, - sensorBarY, - font6x8.Width * 2, - font6x8.Height * 2) - { - Text = $"Y", - TextColor = Meadow.Color.White, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }); - GyroscopeY = new Box( - column2 + font6x8.Width * 2 + margin, - sensorBarY, - sensorBarInitialWidth, - sensorBarHeight) - { - ForeColor = Meadow.Color.FromHex("C9DB31") - }; - DataLayout.Controls.Add(GyroscopeY); - - DataLayout.Controls.Add(new Label( - column2 + smallMargin, - sensorBarZ, - font6x8.Width * 2, - font6x8.Height * 2) - { - Text = $"Z", - TextColor = Meadow.Color.White, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }); - GyroscopeZ = new Box( - column2 + font6x8.Width * 2 + margin, - sensorBarZ, - sensorBarInitialWidth, - sensorBarHeight) - { - ForeColor = Meadow.Color.FromHex("E1EB8B") - }; - DataLayout.Controls.Add(GyroscopeZ); - #endregion - - #region CLOCK - DataLayout.Controls.Add(new Box( - clockX, - row1, - clockWidth, - rowHeight) - { - ForeColor = ForegroundColor - }); - Date = new Label( - clockX, - row1 + smallMargin, - clockWidth, - font6x8.Height) - { - Text = $"----/--/--", - TextColor = backgroundColor, - HorizontalAlignment = HorizontalAlignment.Center, - Font = font6x8 - }; - DataLayout.Controls.Add(Date); - Time = new Label( - clockX, - row1 + font6x8.Height + smallMargin * 2, - clockWidth, - font6x8.Height * 2) - { - Text = $"--:--", - TextColor = backgroundColor, - HorizontalAlignment = HorizontalAlignment.Center, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(Time); - #endregion - - #region D-PAD - Up = new Box( - 218, - 136, - dPadSize, - dPadSize) - { - ForeColor = ForegroundColor - }; - DataLayout.Controls.Add(Up); - Down = new Box( - 218, - 156, - dPadSize, - dPadSize) - { - ForeColor = ForegroundColor - }; - DataLayout.Controls.Add(Down); - Left = new Box( - 208, - 146, - dPadSize, - dPadSize) - { - ForeColor = ForegroundColor - }; - DataLayout.Controls.Add(Left); - Right = new Box( - 228, - 146, - dPadSize, - dPadSize) - { - ForeColor = ForegroundColor - }; - DataLayout.Controls.Add(Right); - - #endregion - } - - public void ShowSplashScreen() - { - DataLayout.IsVisible = false; - SplashLayout.IsVisible = true; - } - - public void ShowDataScreen() - { - SplashLayout.IsVisible = false; - DataLayout.IsVisible = true; - } - - public void UpdateStatus(string status) - { - Status.Text = status; - } - - public void UpdateWiFiStatus(bool isConnected) - { - var imageWiFi = isConnected - ? Image.LoadFromResource("WinFormsMeadow.Resources.img_wifi_connected.bmp") - : Image.LoadFromResource("WinFormsMeadow.Resources.img_wifi_connecting.bmp"); - WifiStatus.Image = imageWiFi; - } - - public void UpdateSyncStatus(bool isSyncing) - { - var imageSync = isSyncing - ? Image.LoadFromResource("WinFormsMeadow.Resources.img_refreshing.bmp") - : Image.LoadFromResource("WinFormsMeadow.Resources.img_refreshed.bmp"); - SyncStatus.Image = imageSync; - } - - protected void UpdateReadings(double temperature, double pressure, double humidity, double luminance) - { - DisplayScreen.BeginUpdate(); - - TemperatureValue.Text = $"{temperature:N1}C"; - PressureValue.Text = $"{pressure:N1}atm"; - HumidityValue.Text = $"{humidity:N1}%"; - LuminanceValue.Text = $"{luminance:N0}Lx"; - - DisplayScreen.EndUpdate(); - } - - protected void UpdateDateTime() - { - DisplayScreen.BeginUpdate(); - - var today = DateTime.Now; - Date.Text = today.ToString("yyyy/MM/dd"); - Time.Text = today.ToString("HH:mm"); - - DisplayScreen.EndUpdate(); - } - - public void UpdateDirectionalPad(int direction, bool pressed) - { - switch (direction) - { - case 0: Up.ForeColor = pressed ? accentColor : ForegroundColor; break; - case 1: Down.ForeColor = pressed ? accentColor : ForegroundColor; break; - case 2: Left.ForeColor = pressed ? accentColor : ForegroundColor; break; - case 3: Right.ForeColor = pressed ? accentColor : ForegroundColor; break; - } - } - - protected void UpdateSelectReading(int reading) - { - TemperatureBox.ForeColor = PressureBox.ForeColor = HumidityBox.ForeColor = LuminanceBox.ForeColor = backgroundColor; - TemperatureLabel.TextColor = PressureLabel.TextColor = HumidityLabel.TextColor = LuminanceLabel.TextColor = ForegroundColor; - TemperatureValue.TextColor = PressureValue.TextColor = HumidityValue.TextColor = LuminanceValue.TextColor = ForegroundColor; - - switch (reading) - { - case 0: - TemperatureBox.ForeColor = selectedColor; - TemperatureLabel.TextColor = backgroundColor; - TemperatureValue.TextColor = backgroundColor; - break; - case 1: - PressureBox.ForeColor = selectedColor; - PressureLabel.TextColor = backgroundColor; - PressureValue.TextColor = backgroundColor; - break; - case 2: - HumidityBox.ForeColor = selectedColor; - HumidityLabel.TextColor = backgroundColor; - HumidityValue.TextColor = backgroundColor; - break; - case 3: - LuminanceBox.ForeColor = selectedColor; - LuminanceLabel.TextColor = backgroundColor; - LuminanceValue.TextColor = backgroundColor; - break; - } - } - - protected void UpdateAccelerometerReading(double x, double y, double z) - { - DisplayScreen.BeginUpdate(); - AccelerometerX.Width = (int)x * 10 + 5; - AccelerometerY.Width = (int)y * 10 + 5; - AccelerometerZ.Width = (int)z * 10 + 5; - DisplayScreen.EndUpdate(); - } - - protected void UpdateGyroscopeReading(double x, double y, double z) - { - DisplayScreen.BeginUpdate(); - GyroscopeX.Width = (int)x * 10 + 5; - GyroscopeY.Width = (int)y * 10 + 5; - GyroscopeZ.Width = (int)z * 10 + 5; - DisplayScreen.EndUpdate(); - } - - public async Task Run() - { - //ShowSplashScreen(); - //Thread.Sleep(3000); - ShowDataScreen(); - - var random = new Random(); - - int x = 0; - - while (true) - { - UpdateDateTime(); - - UpdateReadings( - random.Next(25, 35), - random.Next(0, 2), - random.Next(75, 90), - random.Next(100, 4000) - ); - - UpdateDirectionalPad(random.Next(0, 5), true); - - UpdateSelectReading(random.Next(0, 4)); - - UpdateAccelerometerReading(random.Next(0, 3), random.Next(0, 3), random.Next(0, 3)); - - UpdateGyroscopeReading(random.Next(0, 3), random.Next(0, 3), random.Next(0, 3)); - - this.LineChartSeries.Points.Add(x, random.Next(2, 8)); - x++; - - await Task.Delay(1000); - } - } - } -} \ No newline at end of file diff --git a/Source/Meadow.Desktop/WinForms/Views/RotatingCube.cs b/Source/Meadow.Desktop/WinForms/Views/RotatingCube.cs deleted file mode 100644 index 7a92e8c3..00000000 --- a/Source/Meadow.Desktop/WinForms/Views/RotatingCube.cs +++ /dev/null @@ -1,137 +0,0 @@ -using Meadow; -using Meadow.Foundation.Graphics; -using Meadow.Peripherals.Displays; -using System; - -namespace WinFormsMeadow.Views -{ - public class RotatingCube - { - Color backgroundColor = Color.FromHex("91E46C"); - Color foregroundColor = Color.FromHex("000000"); - - private MicroGraphics _graphics = default!; - - //needs cleanup - quick port from c code - private double rot, rotationX, rotationY, rotationZ; - private double rotationXX, rotationYY, rotationZZ; - private double rotationXXX, rotationYYY, rotationZZZ; - - private int[,] cubeWireframe = new int[12, 3]; - private int[,] cubeVertices; - - public RotatingCube(IPixelDisplay display) - { - int cubeSize = 100; - - cubeVertices = new int[8, 3] { - { -cubeSize, -cubeSize, cubeSize}, - { cubeSize, -cubeSize, cubeSize}, - { cubeSize, cubeSize, cubeSize}, - { -cubeSize, cubeSize, cubeSize}, - { -cubeSize, -cubeSize, -cubeSize}, - { cubeSize, -cubeSize, -cubeSize}, - { cubeSize, cubeSize, -cubeSize}, - { -cubeSize, cubeSize, -cubeSize}, - }; - - _graphics = new MicroGraphics(display) - { - CurrentFont = new Font12x20(), - Stroke = 5 - }; - } - - public void Run() - { - int originX = (int)_graphics.Width / 2; - int originY = (int)_graphics.Height / 2; - - int angle = 0; - - ulong frames = 0; - var start = 0; - string frameRate = ""; - - start = Environment.TickCount; - - while (true) - { - _graphics.Clear(backgroundColor); - _graphics.DrawText(5, 5, frameRate, foregroundColor); - - angle++; - for (int i = 0; i < 8; i++) - { - rot = angle * 0.0174532; //0.0174532 = one degree - - //rotateY - rotationZ = cubeVertices[i, 2] * Math.Cos(rot) - cubeVertices[i, 0] * Math.Sin(rot); - rotationX = cubeVertices[i, 2] * Math.Sin(rot) + cubeVertices[i, 0] * Math.Cos(rot); - rotationY = cubeVertices[i, 1]; - - //rotateX - rotationYY = rotationY * Math.Cos(rot) - rotationZ * Math.Sin(rot); - rotationZZ = rotationY * Math.Sin(rot) + rotationZ * Math.Cos(rot); - rotationXX = rotationX; - - //rotateZ - rotationXXX = rotationXX * Math.Cos(rot) - rotationYY * Math.Sin(rot); - rotationYYY = rotationXX * Math.Sin(rot) + rotationYY * Math.Cos(rot); - rotationZZZ = rotationZZ; - - //orthographic projection - rotationXXX = rotationXXX + originX; - rotationYYY = rotationYYY + originY; - - //store new vertices values for wireframe drawing - cubeWireframe[i, 0] = (int)rotationXXX; - cubeWireframe[i, 1] = (int)rotationYYY; - cubeWireframe[i, 2] = (int)rotationZZZ; - - DrawVertices(); - } - - DrawWireframe(); - - _graphics.Show(); - - if (++frames % 1000 == 0) - { - var now = Environment.TickCount; - var et = (now - start) / 1000d; - - frameRate = $"{(1000 / et):0.0}fps"; - start = Environment.TickCount; - } - } - } - - void DrawVertices() - { - _graphics.DrawPixel((int)rotationXXX, (int)rotationYYY); - } - - void DrawWireframe() - { - _graphics.DrawLine(cubeWireframe[0, 0], cubeWireframe[0, 1], cubeWireframe[1, 0], cubeWireframe[1, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[1, 0], cubeWireframe[1, 1], cubeWireframe[2, 0], cubeWireframe[2, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[2, 0], cubeWireframe[2, 1], cubeWireframe[3, 0], cubeWireframe[3, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[3, 0], cubeWireframe[3, 1], cubeWireframe[0, 0], cubeWireframe[0, 1], foregroundColor); - - //cross face above - _graphics.DrawLine(cubeWireframe[1, 0], cubeWireframe[1, 1], cubeWireframe[3, 0], cubeWireframe[3, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[0, 0], cubeWireframe[0, 1], cubeWireframe[2, 0], cubeWireframe[2, 1], foregroundColor); - - _graphics.DrawLine(cubeWireframe[4, 0], cubeWireframe[4, 1], cubeWireframe[5, 0], cubeWireframe[5, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[5, 0], cubeWireframe[5, 1], cubeWireframe[6, 0], cubeWireframe[6, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[6, 0], cubeWireframe[6, 1], cubeWireframe[7, 0], cubeWireframe[7, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[7, 0], cubeWireframe[7, 1], cubeWireframe[4, 0], cubeWireframe[4, 1], foregroundColor); - - _graphics.DrawLine(cubeWireframe[0, 0], cubeWireframe[0, 1], cubeWireframe[4, 0], cubeWireframe[4, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[1, 0], cubeWireframe[1, 1], cubeWireframe[5, 0], cubeWireframe[5, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[2, 0], cubeWireframe[2, 1], cubeWireframe[6, 0], cubeWireframe[6, 1], foregroundColor); - _graphics.DrawLine(cubeWireframe[3, 0], cubeWireframe[3, 1], cubeWireframe[7, 0], cubeWireframe[7, 1], foregroundColor); - } - } -} \ No newline at end of file diff --git a/Source/Meadow.Desktop/WinForms/Views/WiFiWeather.cs b/Source/Meadow.Desktop/WinForms/Views/WiFiWeather.cs deleted file mode 100644 index 4ee2adbc..00000000 --- a/Source/Meadow.Desktop/WinForms/Views/WiFiWeather.cs +++ /dev/null @@ -1,266 +0,0 @@ -using Meadow.Foundation.Graphics; -using Meadow.Foundation.Graphics.MicroLayout; -using Meadow.Peripherals.Displays; -using System; -using System.Threading.Tasks; - -namespace WinFormsMeadow.Views -{ - public class WiFiWeather - { - Image _weatherIcon = Image.LoadFromResource("WinFormsMeadow.Resources.w_clear.bmp"); - - int x_padding = 20; - - protected DisplayScreen DisplayScreen { get; set; } - - protected Label DayOfWeek { get; set; } - - protected Label Month { get; set; } - - protected Label Year { get; set; } - - protected Label Time { get; set; } - - protected Picture Weather { get; set; } - - protected Label Temperature { get; set; } - - protected Label Humidity { get; set; } - - protected Label Pressure { get; set; } - - protected Label FeelsLike { get; set; } - - protected Label WindDirection { get; set; } - - protected Label WindSpeed { get; set; } - - Meadow.Color backgroundColor = Meadow.Color.FromHex("#F3F7FA"); - Meadow.Color foregroundColor = Meadow.Color.Black; - - Font12x20 font12X20 = new Font12x20(); - Font12x16 font12X16 = new Font12x16(); - Font8x16 font8X16 = new Font8x16(); - - public WiFiWeather(IPixelDisplay display) - { - DisplayScreen = new DisplayScreen(display) - { - BackgroundColor = backgroundColor - }; - - Weather = new Picture(x_padding, 25, 100, 100, _weatherIcon); - DisplayScreen.Controls.Add(Weather); - - DayOfWeek = new Label(DisplayScreen.Width / 2 - x_padding, 25, DisplayScreen.Width / 2, font12X20.Height) - { - Text = $"Monday,1st", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(DayOfWeek); - - Month = new Label(DisplayScreen.Width / 2 - x_padding, 50, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) - { - Text = $"Jan", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(Month); - - Year = new Label(DisplayScreen.Width / 2 - x_padding, 95, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) - { - Text = $"0000", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X16, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(Year); - - Time = new Label(0, 150, DisplayScreen.Width, font12X20.Height * 2, ScaleFactor.X2) - { - Text = $"00:00:00 AM", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Center - }; - DisplayScreen.Controls.Add(Time); - - DisplayScreen.Controls.Add(new Label(x_padding, 215, DisplayScreen.Width / 2, font12X20.Height * 2) - { - Text = $"Temperature", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }); - DisplayScreen.Controls.Add(new Label(x_padding, 304, DisplayScreen.Width / 2, font12X20.Height * 2) - { - Text = $"Humidity", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }); - DisplayScreen.Controls.Add(new Label(x_padding, 393, DisplayScreen.Width / 2, font12X20.Height * 2) - { - Text = $"Pressure", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }); - DisplayScreen.Controls.Add(new Label(DisplayScreen.Width / 2 + x_padding, 215, DisplayScreen.Width / 2 - x_padding * 2, font12X20.Height * 2) - { - Text = $"Feels like", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }); - DisplayScreen.Controls.Add(new Label(DisplayScreen.Width / 2 - x_padding, 304, DisplayScreen.Width / 2, font12X20.Height * 2) - { - Text = $"Wind Dir", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }); - DisplayScreen.Controls.Add(new Label(DisplayScreen.Width / 2 - x_padding, 393, DisplayScreen.Width / 2, font12X20.Height * 2) - { - Text = $"Wind Spd", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }); - - Temperature = new Label(x_padding, 245, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) - { - Text = $"23°C", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }; - DisplayScreen.Controls.Add(Temperature); - Humidity = new Label(x_padding, 334, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) - { - Text = $"93%", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }; - DisplayScreen.Controls.Add(Humidity); - Pressure = new Label(x_padding, 423, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) - { - Text = $"1102hPa", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font8X16, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Left - }; - DisplayScreen.Controls.Add(Pressure); - - FeelsLike = new Label(DisplayScreen.Width / 2 - x_padding, 245, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) - { - Text = $"26°C", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(FeelsLike); - WindDirection = new Label(DisplayScreen.Width / 2 - x_padding, 334, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) - { - Text = $"178°", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font12X20, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(WindDirection); - WindSpeed = new Label(DisplayScreen.Width / 2 - x_padding, 423, DisplayScreen.Width / 2, font12X20.Height * 2, ScaleFactor.X2) - { - Text = $"19m/s", - TextColor = foregroundColor, - BackColor = backgroundColor, - Font = font8X16, - VerticalAlignment = VerticalAlignment.Top, - HorizontalAlignment = HorizontalAlignment.Right - }; - DisplayScreen.Controls.Add(WindSpeed); - } - - private static string GetOrdinalSuffix(int num) - { - string number = num.ToString(); - if (number.EndsWith("1")) return "st"; - if (number.EndsWith("2")) return "nd"; - if (number.EndsWith("3")) return "rd"; - if (number.EndsWith("11")) return "th"; - if (number.EndsWith("12")) return "th"; - if (number.EndsWith("13")) return "th"; - return "th"; - } - - public void UpdateDisplay(string weatherIcon, string temperature, string humidity, string pressure, string feelsLike, string windDirection, string windSpeed) - { - _weatherIcon = Image.LoadFromResource(weatherIcon); - Weather.Image = _weatherIcon; - - Temperature.Text = temperature; - Humidity.Text = humidity; - Pressure.Text = pressure; - FeelsLike.Text = feelsLike; - WindDirection.Text = windDirection; - WindSpeed.Text = windSpeed; - } - - public async Task Run() - { - UpdateDisplay( - weatherIcon: $"WinFormsMeadow.Resources.w_drizzle.bmp", - temperature: $"23°C", - humidity: $"93%", - pressure: $"1102hPa", - feelsLike: $"26°C", - windDirection: $"178°", - windSpeed: $"19m/s"); - - while (true) - { - var today = DateTime.Now; - - DayOfWeek.Text = $"{today.DayOfWeek},{today.Day}{GetOrdinalSuffix(today.Day)}"; - Month.Text = $"{today.ToString("MMMM").Substring(0, today.ToString("MMMM").Length > 6 ? 7 : today.ToString("MMMM").Length)}"; - Year.Text = $"{today.ToString("yyyy")}"; - Time.Text = DateTime.Now.ToString("hh:mm:ss tt"); - await Task.Delay(TimeSpan.FromSeconds(1)); - } - } - } -} \ No newline at end of file diff --git a/Source/Meadow.Desktop/WinForms/Views/WifiWeatherV2.cs b/Source/Meadow.Desktop/WinForms/Views/WifiWeatherV2.cs deleted file mode 100644 index f60964ea..00000000 --- a/Source/Meadow.Desktop/WinForms/Views/WifiWeatherV2.cs +++ /dev/null @@ -1,489 +0,0 @@ -using Meadow; -using Meadow.Foundation.Graphics; -using Meadow.Foundation.Graphics.MicroLayout; -using Meadow.Peripherals.Displays; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace WinFormsMeadow.Views -{ - internal class WifiWeatherV2 - { - private Color backgroundColor = Color.FromHex("10485E"); - private Color outdoorColor = Color.FromHex("C9DB31"); - private Color ForegroundColor = Color.FromHex("EEEEEE"); - private Font8x16 font8x16 = new Font8x16(); - private Font6x8 font6x8 = new Font6x8(); - - private int margin = 5; - readonly int smallMargin = 3; - readonly int graphHeight = 105; - - readonly int measureBoxWidth = 82; - - readonly int columnWidth = 100; - - readonly int rowHeight = 30; - readonly int row1 = 135; - readonly int row2 = 170; - readonly int row3 = 205; - - Image weatherIcon = Image.LoadFromResource($"WinFormsMeadow.Resources.w_misc.bmp"); - - public LineChartSeries OutdoorSeries { get; set; } - protected DisplayScreen DisplayScreen { get; set; } - protected AbsoluteLayout SplashLayout { get; set; } - protected AbsoluteLayout DataLayout { get; set; } - protected LineChart LineChart { get; set; } - protected Picture WifiStatus { get; set; } - protected Picture SyncStatus { get; set; } - protected Picture Weather { get; set; } - protected Label Status { get; set; } - - protected Box TemperatureBox { get; set; } - protected Label TemperatureLabel { get; set; } - protected Label TemperatureValue { get; set; } - - protected Box PressureBox { get; set; } - protected Label PressureLabel { get; set; } - protected Label PressureValue { get; set; } - - protected Box HumidityBox { get; set; } - protected Label HumidityLabel { get; set; } - protected Label HumidityValue { get; set; } - - protected Label FeelsLike { get; set; } - protected Label Sunrise { get; set; } - protected Label Sunset { get; set; } - - public WifiWeatherV2(IPixelDisplay display) - { - DisplayScreen = new DisplayScreen(display) - { - BackgroundColor = backgroundColor - }; - - LoadSplashLayout(); - - DisplayScreen.Controls.Add(SplashLayout); - - LoadDataLayout(); - - DisplayScreen.Controls.Add(DataLayout); - } - - private void LoadSplashLayout() - { - SplashLayout = new AbsoluteLayout(DisplayScreen, 0, 0, DisplayScreen.Width, DisplayScreen.Height) - { - IsVisible = false - }; - - var image = Image.LoadFromResource("WinFormsMeadow.Resources.img_meadow.bmp"); - var displayImage = new Picture(0, 0, DisplayScreen.Width, DisplayScreen.Height, image) - { - BackColor = Color.FromHex("#14607F"), - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - - SplashLayout.Controls.Add(displayImage); - } - - private void LoadDataLayout() - { - DataLayout = new AbsoluteLayout(DisplayScreen, 0, 0, DisplayScreen.Width, DisplayScreen.Height) - { - BackgroundColor = backgroundColor, - IsVisible = false - }; - - Status = new Label( - margin, - margin + 2, - 152, - font8x16.Height) - { - Text = $"Project Lab v3", - TextColor = Color.White, - Font = font8x16, - VerticalAlignment = VerticalAlignment.Center, - }; - DataLayout.Controls.Add(Status); - - var wifiImage = Image.LoadFromResource("WinFormsMeadow.Resources.img_wifi_connecting.bmp"); - WifiStatus = new Picture( - DisplayScreen.Width - wifiImage.Width - margin, - margin, - wifiImage.Width, - font8x16.Height, - wifiImage) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - DataLayout.Controls.Add(WifiStatus); - - var syncImage = Image.LoadFromResource("WinFormsMeadow.Resources.img_refreshed.bmp"); - SyncStatus = new Picture( - DisplayScreen.Width - syncImage.Width - wifiImage.Width - margin * 2, - margin, - syncImage.Width, - font8x16.Height, - syncImage) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - DataLayout.Controls.Add(SyncStatus); - - LineChart = new LineChart( - margin, - 25, - DisplayScreen.Width - margin * 2, - graphHeight) - { - BackgroundColor = Color.FromHex("082936"), - AxisColor = ForegroundColor, - ShowYAxisLabels = true, - IsVisible = false, - AlwaysShowYOrigin = false, - }; - OutdoorSeries = new LineChartSeries() - { - LineColor = outdoorColor, - PointColor = outdoorColor, - LineStroke = 1, - PointSize = 2, - ShowLines = true, - ShowPoints = true, - }; - LineChart.Series.Add(OutdoorSeries); - DataLayout.Controls.Add(LineChart); - - var weatherImage = Image.LoadFromResource("WinFormsMeadow.Resources.w_misc.bmp"); - Weather = new Picture( - margin, - row1, - 100, - 100, - weatherImage) - { - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; - DataLayout.Controls.Add(Weather); - - #region TEMPERATURE - TemperatureBox = new Box( - columnWidth + margin * 2, - row1, - columnWidth, - rowHeight) - { - ForeColor = outdoorColor - }; - DataLayout.Controls.Add(TemperatureBox); - TemperatureLabel = new Label( - columnWidth + margin * 2 + smallMargin, - row1 + smallMargin, - measureBoxWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"TEMPERATURE", - TextColor = backgroundColor, - Font = font6x8 - }; - DataLayout.Controls.Add(TemperatureLabel); - TemperatureValue = new Label( - columnWidth + margin * 2 + smallMargin, - row1 + font6x8.Height + smallMargin * 2, - measureBoxWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"-.-C", - TextColor = backgroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(TemperatureValue); - #endregion - - #region PRESSURE - PressureBox = new Box( - columnWidth + margin * 2, - row2, - columnWidth, - rowHeight) - { - ForeColor = backgroundColor - }; - DataLayout.Controls.Add(PressureBox); - PressureLabel = new Label( - columnWidth + margin * 2 + smallMargin, - row2 + smallMargin, - measureBoxWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"PRESSURE", - TextColor = ForegroundColor, - Font = font6x8 - }; - DataLayout.Controls.Add(PressureLabel); - PressureValue = new Label( - columnWidth + margin * 2 + smallMargin, - row2 + font6x8.Height + smallMargin * 2, - measureBoxWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"-.-hPa", - TextColor = ForegroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(PressureValue); - #endregion - - #region HUMIDITY - HumidityBox = new Box( - columnWidth + margin * 2, - row3, - columnWidth, - rowHeight) - { - ForeColor = backgroundColor - }; - DataLayout.Controls.Add(HumidityBox); - HumidityLabel = new Label( - columnWidth + margin * 2 + smallMargin, - row3 + smallMargin, - measureBoxWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"HUMIDITY", - TextColor = ForegroundColor, - Font = font6x8 - }; - DataLayout.Controls.Add(HumidityLabel); - HumidityValue = new Label( - columnWidth + margin * 2 + smallMargin, - row3 + font6x8.Height + smallMargin * 2, - columnWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"-.-%", - TextColor = ForegroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(HumidityValue); - #endregion - - DataLayout.Controls.Add(new Label( - columnWidth * 2 + margin * 3 + smallMargin, - row1 + smallMargin, - measureBoxWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"FEELS LIKE", - TextColor = ForegroundColor, - Font = font6x8 - }); - FeelsLike = new Label( - columnWidth * 2 + margin * 3 + smallMargin, - row1 + font6x8.Height + smallMargin * 2, - columnWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"-.-C", - TextColor = ForegroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(FeelsLike); - - DataLayout.Controls.Add(new Label( - columnWidth * 2 + margin * 3 + smallMargin, - row2 + smallMargin, - measureBoxWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"SUNRISE", - TextColor = ForegroundColor, - Font = font6x8 - }); - Sunrise = new Label( - columnWidth * 2 + margin * 3 + smallMargin, - row2 + font6x8.Height + smallMargin * 2, - columnWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"--:-- --", - TextColor = ForegroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(Sunrise); - - DataLayout.Controls.Add(new Label( - columnWidth * 2 + margin * 3 + smallMargin, - row3 + smallMargin, - measureBoxWidth - smallMargin * 2, - font6x8.Height) - { - Text = $"SUNSET", - TextColor = ForegroundColor, - Font = font6x8 - }); - Sunset = new Label( - columnWidth * 2 + margin * 3 + smallMargin, - row3 + font6x8.Height + smallMargin * 2, - columnWidth - smallMargin * 2, - font6x8.Height * 2) - { - Text = $"--:-- --", - TextColor = ForegroundColor, - Font = font6x8, - ScaleFactor = ScaleFactor.X2 - }; - DataLayout.Controls.Add(Sunset); - } - - public void ShowSplashScreen() - { - DataLayout.IsVisible = false; - SplashLayout.IsVisible = true; - } - - public void ShowDataScreen() - { - SplashLayout.IsVisible = false; - DataLayout.IsVisible = true; - } - - public void UpdateStatus(string status) - { - Status.Text = status; - } - - public void UpdateWiFiStatus(bool isConnected) - { - var imageWiFi = isConnected - ? Image.LoadFromResource("WinFormsMeadow.Resources.img_wifi_connected.bmp") - : Image.LoadFromResource("WinFormsMeadow.Resources.img_wifi_connecting.bmp"); - WifiStatus.Image = imageWiFi; - } - - public void UpdateSyncStatus(bool isSyncing) - { - var imageSync = isSyncing - ? Image.LoadFromResource("WinFormsMeadow.Resources.img_refreshing.bmp") - : Image.LoadFromResource("WinFormsMeadow.Resources.img_refreshed.bmp"); - SyncStatus.Image = imageSync; - } - - private void UpdateReadingType(int type) - { - TemperatureBox.ForeColor = PressureBox.ForeColor = HumidityBox.ForeColor = backgroundColor; - TemperatureLabel.TextColor = PressureLabel.TextColor = HumidityLabel.TextColor = ForegroundColor; - TemperatureValue.TextColor = PressureValue.TextColor = HumidityValue.TextColor = ForegroundColor; - - switch (type) - { - case 0: - TemperatureBox.ForeColor = outdoorColor; - TemperatureLabel.TextColor = backgroundColor; - TemperatureValue.TextColor = backgroundColor; - break; - case 1: - PressureBox.ForeColor = outdoorColor; - PressureLabel.TextColor = backgroundColor; - PressureValue.TextColor = backgroundColor; - break; - case 2: - HumidityBox.ForeColor = outdoorColor; - HumidityLabel.TextColor = backgroundColor; - HumidityLabel.TextColor = backgroundColor; - break; - } - } - - public void UpdateReadings( - int readingType, - string icon, - double temperature, - double humidity, - double pressure, - double feelsLike, - DateTime sunrise, - DateTime sunset, - List outdoorReadings) - { - DisplayScreen.BeginUpdate(); - - UpdateReadingType(readingType); - - weatherIcon = Image.LoadFromResource(icon); - Weather.Image = weatherIcon; - - TemperatureValue.Text = $"{temperature:N1}C"; - HumidityValue.Text = $"{humidity:N1}%"; - PressureValue.Text = $"{pressure:N2}atm"; - FeelsLike.Text = $"{feelsLike:N1}C"; - Sunrise.Text = $"{sunrise:hh:mm tt}"; - Sunset.Text = $"{sunset:hh:mm tt}"; - - OutdoorSeries.Points.Clear(); - - for (var p = 0; p < outdoorReadings.Count; p++) - { - OutdoorSeries.Points.Add(p * 2, outdoorReadings[p]); - } - - DisplayScreen.EndUpdate(); - } - - public async Task Run() - { - //ShowSplashScreen(); - //Thread.Sleep(3000); - ShowDataScreen(); - - var random = new Random(); - - int x = 0; - - var outdoorList = new List - { - 25.3, - 26.1, - 25.7, - 27.9, - 26.3, - 25.6, - 26.3, - 27.2, - 27.6 - }; - - while (true) - { - UpdateStatus(DateTime.Now.ToString("hh:mm tt | dd/MM/yy")); - - UpdateReadings( - readingType: 0, - icon: "WinFormsMeadow.Resources.w_clear.bmp", - temperature: random.Next(10, 13), - humidity: random.Next(65, 75), - pressure: 1 + random.NextDouble(), - feelsLike: random.Next(22, 25), - sunrise: DateTime.Now, - sunset: DateTime.Now.AddHours(8), - outdoorReadings: outdoorList); - - await Task.Delay(1000); - } - } - } -} \ No newline at end of file diff --git a/Source/Meadow.Samples.sln b/Source/Meadow.Samples.sln index d9ef9599..574fa7e8 100644 --- a/Source/Meadow.Samples.sln +++ b/Source/Meadow.Samples.sln @@ -107,8 +107,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Touchscreen_Demo", "Meadow. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WifiWeather", "Meadow.Desktop\WifiWeather\WifiWeather.csproj", "{5D63C92F-DAE3-4942-BF2B-BCEA339E39FE}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsMeadow", "Meadow.Desktop\WinForms\WinFormsMeadow.csproj", "{D408AE37-1D94-42B3-8EDC-69357868F4C0}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdgeASketch", "Meadow F7 Feather\EdgeASketch\EdgeASketch.csproj", "{A8D467ED-C9ED-43F0-98C1-37B3999D53EE}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Frogger", "Meadow F7 Feather\Frogger\Frogger.csproj", "{20959E35-AD1E-418A-BA05-0577F63A68C6}" @@ -493,6 +491,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MeadowF7_HealthMetrics", "M EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MeadowF7_Logging", "Meadow.Cloud\MeadowF7_Logging\MeadowF7_Logging.csproj", "{97528EA2-149F-40C6-AA7D-C3E36915AB54}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HMI_Views", "Meadow.Desktop\HMI_Views\HMI_Views.csproj", "{3F93415B-AEE8-4688-9B4A-7846816640AD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -799,12 +799,6 @@ Global {5D63C92F-DAE3-4942-BF2B-BCEA339E39FE}.Release|Any CPU.Build.0 = Release|Any CPU {5D63C92F-DAE3-4942-BF2B-BCEA339E39FE}.Simulation|Any CPU.ActiveCfg = Debug|Any CPU {5D63C92F-DAE3-4942-BF2B-BCEA339E39FE}.Simulation|Any CPU.Build.0 = Debug|Any CPU - {D408AE37-1D94-42B3-8EDC-69357868F4C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D408AE37-1D94-42B3-8EDC-69357868F4C0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D408AE37-1D94-42B3-8EDC-69357868F4C0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D408AE37-1D94-42B3-8EDC-69357868F4C0}.Release|Any CPU.Build.0 = Release|Any CPU - {D408AE37-1D94-42B3-8EDC-69357868F4C0}.Simulation|Any CPU.ActiveCfg = Debug|Any CPU - {D408AE37-1D94-42B3-8EDC-69357868F4C0}.Simulation|Any CPU.Build.0 = Debug|Any CPU {A8D467ED-C9ED-43F0-98C1-37B3999D53EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A8D467ED-C9ED-43F0-98C1-37B3999D53EE}.Debug|Any CPU.Build.0 = Debug|Any CPU {A8D467ED-C9ED-43F0-98C1-37B3999D53EE}.Debug|Any CPU.Deploy.0 = Debug|Any CPU @@ -2303,6 +2297,12 @@ Global {97528EA2-149F-40C6-AA7D-C3E36915AB54}.Simulation|Any CPU.ActiveCfg = Debug|Any CPU {97528EA2-149F-40C6-AA7D-C3E36915AB54}.Simulation|Any CPU.Build.0 = Debug|Any CPU {97528EA2-149F-40C6-AA7D-C3E36915AB54}.Simulation|Any CPU.Deploy.0 = Debug|Any CPU + {3F93415B-AEE8-4688-9B4A-7846816640AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3F93415B-AEE8-4688-9B4A-7846816640AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3F93415B-AEE8-4688-9B4A-7846816640AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3F93415B-AEE8-4688-9B4A-7846816640AD}.Release|Any CPU.Build.0 = Release|Any CPU + {3F93415B-AEE8-4688-9B4A-7846816640AD}.Simulation|Any CPU.ActiveCfg = Debug|Any CPU + {3F93415B-AEE8-4688-9B4A-7846816640AD}.Simulation|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2351,7 +2351,6 @@ Global {613B9614-FC42-48E7-9A28-14E53B6CEAE4} = {A5E391D4-541D-485D-9210-4EAC4E8A2FB0} {B9BEEE15-86BB-4536-AB42-B3FA91842E40} = {A5E391D4-541D-485D-9210-4EAC4E8A2FB0} {5D63C92F-DAE3-4942-BF2B-BCEA339E39FE} = {A5E391D4-541D-485D-9210-4EAC4E8A2FB0} - {D408AE37-1D94-42B3-8EDC-69357868F4C0} = {A5E391D4-541D-485D-9210-4EAC4E8A2FB0} {A8D467ED-C9ED-43F0-98C1-37B3999D53EE} = {F2C90300-05D4-4DED-9033-3350398A69E9} {20959E35-AD1E-418A-BA05-0577F63A68C6} = {F2C90300-05D4-4DED-9033-3350398A69E9} {7D1D8323-4DB9-46F0-B07D-185DB52832EB} = {F2C90300-05D4-4DED-9033-3350398A69E9} @@ -2540,6 +2539,7 @@ Global {043EA273-EF6D-48BC-920D-D63F827B1C55} = {67E244C3-7B2D-45CE-A490-E7B1E1A6A9F9} {4786AC05-C4DD-48B8-AC09-FE95A3571068} = {0F5B8EEF-8895-42C6-9E93-A9152EDEEDDB} {97528EA2-149F-40C6-AA7D-C3E36915AB54} = {0F5B8EEF-8895-42C6-9E93-A9152EDEEDDB} + {3F93415B-AEE8-4688-9B4A-7846816640AD} = {A5E391D4-541D-485D-9210-4EAC4E8A2FB0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E3F002EA-1A25-487F-9A5D-93D1E7EC6E31}