feat-hal-2 #4
@@ -27,7 +27,9 @@ hw::Potentiometer::~Potentiometer(void)
|
||||
uint8_t hw::Potentiometer::update(void)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user