mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
Fix stepper half half step mode (#1397)
* Fixed half half step mode Half step mode originally had second and third steps mixed up for output A. https://github.com/esphome/issues/issues/1655 * Updated half step mode to have no branching Code based off comments in PR: https://github.com/esphome/esphome/pull/1397#issuecomment-739413973 * removed variable declarations in the switch/case Oops. No explicit declarations. Rearranged to be tidier, same output sequence. * Fixed typo bracket Minor typo fixed - logic complete to do branchless half stepping. * Format the brackets to satisfy clang
This commit is contained in:
parent
34df25da39
commit
3c64c9b0e9
1 changed files with 2 additions and 8 deletions
|
@ -70,14 +70,8 @@ void ULN2003::write_step_(int32_t step) {
|
|||
}
|
||||
case ULN2003_STEP_MODE_HALF_STEP: {
|
||||
// A, AB, B, BC, C, CD, D, DA
|
||||
if (i == 0 || i == 2 || i == 7)
|
||||
res |= 1 << 0;
|
||||
if (i == 1 || i == 2 || i == 3)
|
||||
res |= 1 << 1;
|
||||
if (i == 3 || i == 4 || i == 5)
|
||||
res |= 1 << 2;
|
||||
if (i == 5 || i == 6 || i == 7)
|
||||
res |= 1 << 3;
|
||||
res |= 1 << (i >> 1);
|
||||
res |= 1 << (((i + 1) >> 1) & 0x3);
|
||||
break;
|
||||
}
|
||||
case ULN2003_STEP_MODE_WAVE_DRIVE: {
|
||||
|
|
Loading…
Reference in a new issue