pissing about
This commit is contained in:
@@ -6,6 +6,7 @@ public class MatrixRenderer
|
|||||||
private readonly WledDdpClient _wled;
|
private readonly WledDdpClient _wled;
|
||||||
private readonly int _width = 64;
|
private readonly int _width = 64;
|
||||||
private readonly int _height = 64;
|
private readonly int _height = 64;
|
||||||
|
private readonly string _fontType = "monospace";
|
||||||
|
|
||||||
public MatrixRenderer(string wledIp)
|
public MatrixRenderer(string wledIp)
|
||||||
{
|
{
|
||||||
@@ -22,18 +23,24 @@ public class MatrixRenderer
|
|||||||
canvas.Clear(SKColors.Black);
|
canvas.Clear(SKColors.Black);
|
||||||
|
|
||||||
// --- DRAW CLOCK ---
|
// --- DRAW CLOCK ---
|
||||||
using SKPaint clockPaint = new SKPaint { Color = SKColors.Cyan, IsAntialias = false };
|
using SKPaint clockPaint = new SKPaint { Color = SKColors.Red, IsAntialias = false };
|
||||||
using SKTypeface typeface = SKTypeface.FromFamilyName("monospace");
|
using SKTypeface typeface = SKTypeface.FromFamilyName(_fontType);
|
||||||
using SKFont clockFont = new SKFont(typeface, 16);
|
using SKFont clockFont = new SKFont(typeface, 14);
|
||||||
string timeFormat = (currentTime.Second % 2 == 0) ? "HH:mm" : "HH mm";
|
//string timeFormat = (currentTime.Second % 2 == 0) ? "HH:mm" : "HH mm";
|
||||||
|
string timeFormat = "HH:mm:ss";
|
||||||
string timeString = currentTime.ToString(timeFormat);
|
string timeString = currentTime.ToString(timeFormat);
|
||||||
canvas.DrawText(timeString, 4, 16, SKTextAlign.Left, clockFont, clockPaint);
|
canvas.DrawText(timeString, 4, 16, SKTextAlign.Left, clockFont, clockPaint);
|
||||||
|
|
||||||
// --- DRAW TEMPERATURE ---
|
// --- DRAW TEMPERATURE ---
|
||||||
using SKPaint textPaint = new SKPaint { Color = SKColors.Orange, IsAntialias = false };
|
using SKPaint textPaintTemp = new SKPaint { Color = SKColors.Green, IsAntialias = false };
|
||||||
using SKFont textFont = new SKFont { Size = 16 };
|
using SKTypeface typefaceTemp = SKTypeface.FromFamilyName(_fontType);
|
||||||
canvas.DrawText($"{currentTemp:F1}c", 4, 30, SKTextAlign.Left, textFont, textPaint);
|
using SKFont textFont = new SKFont { Size = 14 };
|
||||||
canvas.DrawText($"{currentWater:F1}%", 4, 50, SKTextAlign.Left, textFont, textPaint);
|
canvas.DrawText($"{currentTemp:F1}ºc", 4, 33, SKTextAlign.Left, textFont, textPaintTemp);
|
||||||
|
//Water
|
||||||
|
using SKPaint textPaintWater = new SKPaint { Color = SKColors.Blue, IsAntialias = false };
|
||||||
|
using SKTypeface typefaceWater = SKTypeface.FromFamilyName(_fontType);
|
||||||
|
using SKFont textFontWater = new SKFont { Size = 14 };
|
||||||
|
canvas.DrawText($"{currentWater:F1}%", 4, 50, SKTextAlign.Left, textFontWater, textPaintWater);
|
||||||
|
|
||||||
// 4. Convert 32-bit RGBA to 24-bit RGB for WLED
|
// 4. Convert 32-bit RGBA to 24-bit RGB for WLED
|
||||||
byte[] rgbaBytes = bitmap.Bytes;
|
byte[] rgbaBytes = bitmap.Bytes;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
var renderer = new MatrixRenderer("192.168.0.150"); // Your WLED IP
|
var renderer = new MatrixRenderer("192.168.1.216"); // Your WLED IP
|
||||||
var ntp = new NtpService("ntp.parsons.cc");
|
var ntp = new NtpService("ntp.parsons.cc");
|
||||||
|
|
||||||
// Replace these with your actual InfluxDB v2 credentials
|
// Replace these with your actual InfluxDB v2 credentials
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -56,8 +56,14 @@ public class WledDdpClient
|
|||||||
|
|
||||||
// Copy the pixel payload into the packet
|
// Copy the pixel payload into the packet
|
||||||
Buffer.BlockCopy(rgbData, offset, packet, 10, chunkLength);
|
Buffer.BlockCopy(rgbData, offset, packet, 10, chunkLength);
|
||||||
|
try
|
||||||
|
{
|
||||||
await _udp.SendAsync(packet, packet.Length, _ip, Port);
|
await _udp.SendAsync(packet, packet.Length, _ip, Port);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine("Connection to matrix failed");
|
||||||
|
}
|
||||||
|
|
||||||
offset += chunkLength;
|
offset += chunkLength;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user