First functioning draft
This commit is contained in:
34
Program.cs
34
Program.cs
@@ -1,13 +1,35 @@
|
||||
var renderer = new MatrixRenderer("192.168.0.150"); // Replace with WLED IP
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
var renderer = new MatrixRenderer("192.168.0.150"); // Your WLED IP
|
||||
|
||||
// Replace these with your actual InfluxDB v2 credentials
|
||||
// If Influx is on the same Pi, you can use the Pi's local IP and port 8086
|
||||
var influx = new InfluxDataService(
|
||||
url: "http://192.168.0.76:8086",
|
||||
token: ":",
|
||||
org: "-",
|
||||
bucket: "sensor_data"
|
||||
);
|
||||
|
||||
Console.WriteLine("Starting DDP stream with live InfluxDB data...");
|
||||
|
||||
float currentTemp = 1f;
|
||||
Stopwatch dbTimer = Stopwatch.StartNew();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// TODO: Query InfluxDB for your BME680 data here
|
||||
float bme680Temp = 22.5f;
|
||||
// Only query the database every 5 seconds (5000 ms)
|
||||
if (dbTimer.ElapsedMilliseconds > 5000 || currentTemp == 0f)
|
||||
{
|
||||
currentTemp = await influx.GetLatestTemperatureAsync();
|
||||
Console.WriteLine($"Fetched new temp: {currentTemp}c");
|
||||
dbTimer.Restart();
|
||||
}
|
||||
|
||||
await renderer.DrawAndSendFrameAsync(bme680Temp);
|
||||
// Keep pushing frames to WLED at 30 FPS
|
||||
await renderer.DrawAndSendFrameAsync(currentTemp);
|
||||
|
||||
// Update screen at 30 FPS for smooth transitions,
|
||||
// or every 5 seconds if just showing static data.
|
||||
await Task.Delay(1000 / 30);
|
||||
}
|
||||
Reference in New Issue
Block a user