mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
refactor: share the shade step maths in ShadeMotion.cpp
processFrame worked out a StepUp/StepDown target with the same formula in
eight places, each with its own divide-by-zero guard. 4dd4a98 fixed one
that guarded on downTime but divided by upTime. stepPosition() takes the
travel time once, for both the guard and the maths, so they can't drift
apart again, and it is now covered by native tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ea520731a9
commit
bea2f78cb6
4 changed files with 64 additions and 16 deletions
|
|
@ -15,6 +15,11 @@ float travelPosition(float startPos, int8_t dir, uint32_t elapsedMs, int32_t tra
|
|||
int8_t displayPosition(float pos, bool flip);
|
||||
// Where a shade (or its tilt) moving in dir ends up when nothing stops it.
|
||||
float limitTarget(int8_t dir);
|
||||
// Where a step command moves a shade (or its tilt) from pos, in out. dir > 0
|
||||
// steps toward 100 and dir < 0 toward 0. A step is stepSize * frameStepSize
|
||||
// ms of the travelMs a full travel takes in that direction. False when
|
||||
// travelMs or stepSize is 0, so the step is ignored.
|
||||
bool stepPosition(float pos, int8_t dir, uint32_t travelMs, uint16_t stepSize, uint8_t frameStepSize, float &out);
|
||||
|
||||
// What a held shade does on this pass of checkMovement().
|
||||
enum class TxHoldCheck {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue