Interpolation bug fix
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user