fix: Clip input num to 0-100 range
This commit is contained in:
parent
fc68881e58
commit
211f6e0fbb
|
@ -182,12 +182,17 @@ 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 (");
|
||||
// Bounds checking:
|
||||
if (num < 0) {
|
||||
Serial.print("[MEGA] Input less than 0 (");
|
||||
Serial.print(num);
|
||||
Serial.println("), setting to 0.");
|
||||
num = 0;
|
||||
} else if (num > 100) {
|
||||
Serial.print("[MEGA] Input greater than 100 (");
|
||||
Serial.print(num);
|
||||
Serial.println("), setting to 100.");
|
||||
num = 100;
|
||||
}
|
||||
|
||||
long mappedValue;
|
||||
|
|
Loading…
Reference in New Issue
Block a user