Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a final test to check if ERG mode has commanded a move in the proper direction. #577

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Continue updating power metrics to other clients if one client disconnects.
- Freed 19k of ram by consolidating tasks and using timers instead of delays.
- Updated baud rate to 115200 to ensure compatibility with other ESP32 variants.
- Added a final test to check if ERG mode has commanded a move in the proper direction.

### Hardware

Expand Down
21 changes: 15 additions & 6 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,17 @@ void SS2K::moveStepper() {
ss2k->stepperIsRunning = stepper->isRunning();
ss2k->currentPosition = stepper->getCurrentPosition();
if (!ss2k->externalControl) {
if ((rtConfig->getFTMSMode() == FitnessMachineControlPointProcedure::SetTargetPower) ||
(rtConfig->getFTMSMode() == FitnessMachineControlPointProcedure::SetTargetResistanceLevel)) {
if ((rtConfig->getFTMSMode() == FitnessMachineControlPointProcedure::SetTargetPower)) {
// don't drive lower out of bounds. This is a final test that should never happen.
if ((stepper->getCurrentPosition() > rtConfig->getTargetIncline()) && (rtConfig->watts.getValue() < rtConfig->watts.getTarget())) {
rtConfig->setTargetIncline(stepper->getCurrentPosition() + 1);
}
// don't drive higher out of bounds. This is a final test that should never happen.
if ((stepper->getCurrentPosition() < rtConfig->getTargetIncline()) && (rtConfig->watts.getValue() > rtConfig->watts.getTarget())) {
rtConfig->setTargetIncline(stepper->getCurrentPosition() - 1);
}
ss2k->targetPosition = rtConfig->getTargetIncline();
} else if (rtConfig->getFTMSMode() == FitnessMachineControlPointProcedure::SetTargetResistanceLevel) {
ss2k->targetPosition = rtConfig->getTargetIncline();
} else {
// Simulation Mode
Expand Down Expand Up @@ -423,16 +432,16 @@ void SS2K::moveStepper() {
stepper->moveTo(ss2k->targetPosition);
}
}

} else {
} else { // Normal move code for non-Peloton
if ((ss2k->targetPosition >= rtConfig->getMinStep()) && (ss2k->targetPosition <= rtConfig->getMaxStep())) {
stepper->moveTo(ss2k->targetPosition);
} else if (ss2k->targetPosition <= rtConfig->getMinStep()) { // Limit Stepper to Min Position
stepper->moveTo(rtConfig->getMinStep());
stepper->moveTo(rtConfig->getMinStep() + 1);
} else { // Limit Stepper to Max Position
stepper->moveTo(rtConfig->getMaxStep());
stepper->moveTo(rtConfig->getMaxStep() - 1);
}
}
//Sync external object
rtConfig->setCurrentIncline((float)stepper->getCurrentPosition());

if (connectedClientCount() > 0) {
Expand Down
Loading