Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram #50

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Source/Meadow.Desktop/HMI_Views/MeadowApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ public override Task Initialize()
//var views = new CultivarView(Device.Display);
//var views = new ProjectLabDemoView(Device.Display);
//var views = new AtmosphericHMI(Device.Display);
var views = new WifiWeatherV2(Device.Display);
//var views = new WifiWeatherV2(Device.Display);
var views = new HistogramView(Device.Display);

_ = Task.Run(() =>
{
Thread.Sleep(2000);
views.Run();
_ = views.Run();
});

return Task.CompletedTask;
Expand Down
2 changes: 1 addition & 1 deletion Source/Meadow.Desktop/HMI_Views/Views/CultivarView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace HMI_Views.Views;

public class CultivarView
{
DisplayScreen screen;
private DisplayScreen screen;

private readonly Image imgWifi = Image.LoadFromResource("HMI_Views.Resources.img-wifi.bmp");
private readonly Image imgSync = Image.LoadFromResource("HMI_Views.Resources.img-sync.bmp");
Expand Down
68 changes: 68 additions & 0 deletions Source/Meadow.Desktop/HMI_Views/Views/HistogramView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Meadow;
using Meadow.Foundation.Graphics.MicroLayout;
using Meadow.Peripherals.Displays;
using System;
using System.Threading.Tasks;

namespace HMI_Views.Views;

public class HistogramView
{
private DisplayScreen screen;
private HistogramChart spectraChart1;

Check failure on line 12 in Source/Meadow.Desktop/HMI_Views/Views/HistogramView.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'HistogramChart' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 12 in Source/Meadow.Desktop/HMI_Views/Views/HistogramView.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'HistogramChart' could not be found (are you missing a using directive or an assembly reference?)
private HistogramChart spectraChart2;

Check failure on line 13 in Source/Meadow.Desktop/HMI_Views/Views/HistogramView.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'HistogramChart' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 13 in Source/Meadow.Desktop/HMI_Views/Views/HistogramView.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'HistogramChart' could not be found (are you missing a using directive or an assembly reference?)

public HistogramView(IPixelDisplay _display)
{
screen = new DisplayScreen(_display);

spectraChart1 = new HistogramChart(10, 0, screen.Width - 20, screen.Height / 2);
spectraChart1.Series.Add(new HistogramChartSeries { ForeColor = Color.Red });

spectraChart2 = new HistogramChart(10, screen.Height / 2, screen.Width - 20, screen.Height / 2);
spectraChart2.Series.Add(new HistogramChartSeries { ForeColor = Color.Green });

screen.Controls.Add(spectraChart1, spectraChart2);
}

public async Task Run()
{
var count = 30;

while (true)
{
screen.BeginUpdate();

var s1 = new (int X, int Y)[count];
s1[0].X = 1;
s1[0].Y = 0;
for (var i = 1; i < s1.Length - 1; i++)
{
s1[i].X = Random.Shared.Next(1, 50000);
s1[i].Y = Random.Shared.Next(1, 300);
}
s1[s1.Length - 1].X = 50000;
s1[s1.Length - 1].Y = 0;

spectraChart1.Series[0].DataElements = s1;

var s2 = new (int X, int Y)[count];
s2[0].X = 100;
s2[0].Y = 0;
for (var i = 1; i < s2.Length - 1; i++)
{
s2[i].X = Random.Shared.Next(100, 50000);
s2[i].Y = Random.Shared.Next(1, 300);
}
s2[s2.Length - 1].X = 50000;
s2[s2.Length - 1].Y = 0;

spectraChart2.Series[0].DataElements = s2;

screen.EndUpdate();

await Task.Delay(500);
}
}

}
Loading