Interpolation bug fix

This commit is contained in:
2024-04-13 12:27:29 +03:00
parent e7797e8d1c
commit 57ab8bda6a

View File

@@ -27,7 +27,9 @@ hw::Potentiometer::~Potentiometer(void)
uint8_t hw::Potentiometer::update(void) uint8_t hw::Potentiometer::update(void)
{ {
// Calculate percent // Calculate percent
this->percent = util::interpolate(this->ain_ch->last_read, this->low_deadzone, this->high_deadzone, 0, 100); if(this->ain_ch->last_read <= this->low_deadzone) this->percent = 0;
else if(this->ain_ch->last_read >= this->high_deadzone ) this->percent = 100;
else this->percent = util::interpolate(this->ain_ch->last_read, this->low_deadzone, this->high_deadzone, 0, 100);
return this->percent; return this->percent;
} }