From fc68881e58ab95e12ec5df0188b58e916d661c08 Mon Sep 17 00:00:00 2001 From: "Tanner Collin (aider)" Date: Sat, 21 Jun 2025 14:14:30 -0600 Subject: [PATCH] feat: Set control command input to 0 if out of bounds --- firmware/firmware.ino | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 3e9503c..c8db7cf 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -182,6 +182,14 @@ void onMqttMessage(int messageSize) { } void processControlCommand(int64_t num) { + // Bounds checking: if num is outside 0-100, treat as 0. + if (num < 0 || num > 100) { + Serial.print("[MEGA] Input out of bounds ("); + Serial.print(num); + Serial.println("), setting to 0."); + num = 0; + } + long mappedValue; if (num == 0) { mappedValue = 0; // Special case: 0 maps to 0