Use encoder speed to increment duty faster.

This commit is contained in:
Chris Giacofei 2022-01-14 13:45:24 -05:00
parent a8e3e6d0ed
commit d165adb63d

View File

@ -55,11 +55,19 @@ char* KettleState() {
void doEncoder()
{
uint8_t result = rotary.read();
uint8_t inc;
if (result) {
uint8_t speed = rotary.speed();
speed >= 10 ? inc = 5 : inc = 1;
}
if (result == DIR_CW && KettleDuty < 100) {
KettleDuty++;
KettleDuty = (KettleDuty / inc) * inc + inc;
} else if (result == DIR_CCW && KettleDuty > 0) {
KettleDuty--;
KettleDuty = (KettleDuty / inc) * inc - inc;
}
}