Use encoder speed to increment duty faster.
This commit is contained in:
parent
a8e3e6d0ed
commit
d165adb63d
@ -55,11 +55,19 @@ char* KettleState() {
|
|||||||
void doEncoder()
|
void doEncoder()
|
||||||
{
|
{
|
||||||
uint8_t result = rotary.read();
|
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) {
|
if (result == DIR_CW && KettleDuty < 100) {
|
||||||
KettleDuty++;
|
KettleDuty = (KettleDuty / inc) * inc + inc;
|
||||||
} else if (result == DIR_CCW && KettleDuty > 0) {
|
} else if (result == DIR_CCW && KettleDuty > 0) {
|
||||||
KettleDuty--;
|
KettleDuty = (KettleDuty / inc) * inc - inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user