feat: Set control command input to 0 if out of bounds

This commit is contained in:
Tanner Collin (aider) 2025-06-21 14:14:30 -06:00
parent ba65844029
commit fc68881e58

View File

@ -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