diff --git a/analog_system_monitor_arduino/analog_system_monitor_arduino.ino b/analog_system_monitor_arduino/analog_system_monitor_arduino.ino index 79a2bbd..6dc8971 100644 --- a/analog_system_monitor_arduino/analog_system_monitor_arduino.ino +++ b/analog_system_monitor_arduino/analog_system_monitor_arduino.ino @@ -34,6 +34,31 @@ uint8_t pwmPins[NUM_CHANNELS] = { const uint32_t pwmFrequency = 25000; // 25 kHz const uint8_t pwmResolution = 10; // 10-bit resolution (0–1023) +// ------------------------------- +// Channel labels for debugging +// ------------------------------- +const char* channelLabels[NUM_CHANNELS] = { + "CPU Load", + "CPU Temp", + "RAM Usage", + "GPU Load", + "GPU Temp", + "VRAM Usage", + "Reserved 6", + "Reserved 7" +}; + +const char* channelUnits[NUM_CHANNELS] = { + "%", // CPU Load + "°C", // CPU Temp + "%", // RAM Usage + "%", // GPU Load + "°C", // GPU Temp + "%", // VRAM Usage + "", // Reserved + "" // Reserved +}; + // ------------------------------- // Calibration tables // ------------------------------- @@ -50,7 +75,6 @@ float calibratedPoints[NUM_CHANNELS][5] = { {0.0f, 26.0f, 50.0f, 76.0f, 99.0f} }; - // ------------------------------- // Duty tracking + Slew system // ------------------------------- @@ -99,26 +123,22 @@ void setup() { Serial.print("Firmware: "); Serial.println(FIRMWARE_VERSION); - // LEDC PWM init (ESP32 Core 3.x API) + // LEDC PWM init for (int ch = 0; ch < NUM_CHANNELS; ch++) { bool ok = ledcAttach(pwmPins[ch], pwmFrequency, pwmResolution); if (!ok) { Serial.print("LEDC attach failed on pin "); Serial.println(pwmPins[ch]); } - ledcWrite(pwmPins[ch], 0); // duty = 0% + ledcWrite(pwmPins[ch], 0); } - // ------------------------------- - // WiFi Manager (Captive Portal) - // ------------------------------- + // WiFi Manager WiFiManager wm; - wm.setHostname("AnalogMonitor"); - wm.setTimeout(180); // 3 minutes before giving up + wm.setTimeout(180); Serial.println("Starting WiFiManager..."); - bool res = wm.autoConnect("AnalogMonitor-Setup"); if (!res) { @@ -131,7 +151,6 @@ void setup() { Serial.print("IP: "); Serial.println(WiFi.localIP()); - // UDP init udp.begin(listenPort); Serial.print("Listening on UDP port "); Serial.println(listenPort); @@ -169,22 +188,28 @@ void loop() { slewStartDuty[ch] = currentDuty[ch]; } slewStartTime = millis(); - lastPacketTime = millis(); - // Debug output + // -------- Improved Debug Output -------- Serial.println("Received UDP packet:"); for (int i = 0; i < NUM_CHANNELS; i++) { Serial.print(" CH"); Serial.print(i); - Serial.print(": "); - Serial.println(values[i]); + Serial.print(" ("); + Serial.print(channelLabels[i]); + Serial.print("): "); + Serial.print(values[i], 2); + if (channelUnits[i][0] != '\0') { + Serial.print(" "); + Serial.print(channelUnits[i]); + } + Serial.println(); } Serial.println(); } } - // -------- Slew-rate limiting (only when NOT in watchdog mode) -------- + // -------- Slew-rate limiting -------- if (millis() - lastPacketTime <= watchdogTimeout) { unsigned long now = millis(); @@ -202,7 +227,7 @@ void loop() { } } - // -------- Watchdog fade-to-zero (UDP-based) -------- + // -------- Watchdog fade-to-zero -------- if (millis() - lastPacketTime > watchdogTimeout) { const unsigned long fadeInterval = 1;