diff --git a/analog_system_monitor_arduino/analog_system_monitor_arduino.ino b/analog_system_monitor_arduino/analog_system_monitor_arduino.ino index 507af32..4ecaca5 100644 --- a/analog_system_monitor_arduino/analog_system_monitor_arduino.ino +++ b/analog_system_monitor_arduino/analog_system_monitor_arduino.ino @@ -1,6 +1,15 @@ #include #include +// ------------------------------- +// Firmware version +// ------------------------------- +const char* FIRMWARE_VERSION = "V1.0"; + +// ------------------------------- +// PWM setup +// ------------------------------- + const uint8_t NUM_CHANNELS = 8; uint8_t pwmPins[NUM_CHANNELS] = {14, 15, 26, 27, 8, 7, 6, 5}; @@ -28,7 +37,6 @@ float calibratedPoints[NUM_CHANNELS][5] = { // ------------------------------- float currentDuty[NUM_CHANNELS] = {0.0f}; - RP2040_PWM* pwm[NUM_CHANNELS]; // ------------------------------- @@ -37,7 +45,6 @@ RP2040_PWM* pwm[NUM_CHANNELS]; unsigned long lastSerialTime = 0; const unsigned long watchdogTimeout = 5000; // 5 seconds -const float fadeStep = 0.001f; // 0.001% per ms unsigned long lastFadeTime = 0; // ------------------------------- @@ -87,6 +94,15 @@ void loop() { while (Serial.available()) { String s = Serial.readStringUntil('\n'); s.trim(); + + // --- Device identification command --- + if (s.equalsIgnoreCase("PING")) { + Serial.print("Analog_System_Monitor_"); + Serial.println(FIRMWARE_VERSION); + lastSerialTime = millis(); + continue; + } + int eq = s.indexOf('='); if (eq > 0) { int ch = s.substring(0, eq).toInt(); @@ -106,8 +122,7 @@ void loop() { // -------- Watchdog fade-to-zero (time-based exponential) -------- if (millis() - lastSerialTime > watchdogTimeout) { - // Apply fade only every X ms - const unsigned long fadeInterval = 1; // adjust for slower/faster decay + const unsigned long fadeInterval = 1; if (millis() - lastFadeTime >= fadeInterval) { lastFadeTime = millis(); @@ -116,7 +131,7 @@ void loop() { if (currentDuty[ch] > 0.0f) { - const float fadeFactor = 0.999f; // exponential decay per interval + const float fadeFactor = 0.999f; currentDuty[ch] *= fadeFactor; if (currentDuty[ch] < 0.01f)