feat-hal-2 #4

Merged
andis merged 35 commits from feat-hal-2 into develop 2024-07-31 16:15:36 +00:00
Showing only changes of commit 57ab8bda6a - Show all commits

View File

@@ -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;
}