Clamp rotary_encoder restored value to min and max (#3184)

This commit is contained in:
Jesse Hills 2022-02-10 11:12:05 +13:00 committed by GitHub
parent 335512e232
commit ad6c5ff11d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -138,6 +138,8 @@ void RotaryEncoderSensor::setup() {
initial_value = 0;
break;
}
initial_value = clamp(initial_value, this->store_.min_value, this->store_.max_value);
this->store_.counter = initial_value;
this->store_.last_read = initial_value;