diff --git a/MatrixRenderer.cs b/MatrixRenderer.cs index 20d2f00..5c098ee 100644 --- a/MatrixRenderer.cs +++ b/MatrixRenderer.cs @@ -6,6 +6,7 @@ public class MatrixRenderer private readonly WledDdpClient _wled; private readonly int _width = 64; private readonly int _height = 64; + private readonly string _fontType = "monospace"; public MatrixRenderer(string wledIp) { @@ -22,18 +23,24 @@ public class MatrixRenderer canvas.Clear(SKColors.Black); // --- DRAW CLOCK --- - using SKPaint clockPaint = new SKPaint { Color = SKColors.Cyan, IsAntialias = false }; - using SKTypeface typeface = SKTypeface.FromFamilyName("monospace"); - using SKFont clockFont = new SKFont(typeface, 16); - string timeFormat = (currentTime.Second % 2 == 0) ? "HH:mm" : "HH mm"; + using SKPaint clockPaint = new SKPaint { Color = SKColors.Red, IsAntialias = false }; + using SKTypeface typeface = SKTypeface.FromFamilyName(_fontType); + using SKFont clockFont = new SKFont(typeface, 14); + //string timeFormat = (currentTime.Second % 2 == 0) ? "HH:mm" : "HH mm"; + string timeFormat = "HH:mm:ss"; string timeString = currentTime.ToString(timeFormat); canvas.DrawText(timeString, 4, 16, SKTextAlign.Left, clockFont, clockPaint); // --- DRAW TEMPERATURE --- - using SKPaint textPaint = new SKPaint { Color = SKColors.Orange, IsAntialias = false }; - using SKFont textFont = new SKFont { Size = 16 }; - canvas.DrawText($"{currentTemp:F1}c", 4, 30, SKTextAlign.Left, textFont, textPaint); - canvas.DrawText($"{currentWater:F1}%", 4, 50, SKTextAlign.Left, textFont, textPaint); + using SKPaint textPaintTemp = new SKPaint { Color = SKColors.Green, IsAntialias = false }; + using SKTypeface typefaceTemp = SKTypeface.FromFamilyName(_fontType); + using SKFont textFont = new SKFont { Size = 14 }; + 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 byte[] rgbaBytes = bitmap.Bytes; diff --git a/Program.cs b/Program.cs index b7154df..84a8a34 100644 --- a/Program.cs +++ b/Program.cs @@ -2,7 +2,7 @@ using System.Diagnostics; 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"); // Replace these with your actual InfluxDB v2 credentials diff --git a/WLED_DDP_Client.csproj b/WLED_DDP_Client.csproj index fe0bf5c..4fe5cef 100644 --- a/WLED_DDP_Client.csproj +++ b/WLED_DDP_Client.csproj @@ -2,7 +2,7 @@ Exe - net10.0 + net9.0 enable enable diff --git a/WledDdpClient.cs b/WledDdpClient.cs index 03d8b25..18eb7a4 100644 --- a/WledDdpClient.cs +++ b/WledDdpClient.cs @@ -56,8 +56,14 @@ public class WledDdpClient // Copy the pixel payload into the packet Buffer.BlockCopy(rgbData, offset, packet, 10, chunkLength); - - await _udp.SendAsync(packet, packet.Length, _ip, Port); + try + { + await _udp.SendAsync(packet, packet.Length, _ip, Port); + } + catch + { + Console.WriteLine("Connection to matrix failed"); + } offset += chunkLength; }