feat: Set control command input to 0 if out of bounds
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user