Skip to content

Commit a48325a

Browse files
authored
Merge pull request #589 from doudar/home-safety
Added a couple safety features to homing
2 parents a358091 + fcf94eb commit a48325a

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

.github/workflows/update-changelog.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ jobs:
1414
pull-requests: write
1515

1616
steps:
17-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
2020
ref: ${{ github.event.pull_request.head.ref }}
2121

2222
- name: Set up Python
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@v5
2424
with:
2525
python-version: '3.x'
2626

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Added
11-
- Knob homing if calibrate trainer is selected in an app.
1211

1312
### Changed
1413

1514
### Hardware
1615

16+
## [24.11.5]
17+
18+
### Added
19+
- Knob homing if calibrate trainer is selected in an app.
20+
21+
### Changed
22+
- Added backing off of the stop before we test to prevent runaway grinding during homing.
23+
- User can abort homing by pressing shifter.
24+
25+
### Hardware
26+
1727
## [24.10.30]
1828

1929
### Added

src/Main.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,18 +570,27 @@ void SS2K::goHome(bool bothDirections) {
570570
vTaskDelay(50 / portTICK_PERIOD_MS);
571571
driver.ihold((uint8_t)(1));
572572
vTaskDelay(50 / portTICK_PERIOD_MS);
573-
this->updateStepperSpeed(1500);
574-
bool stalled = false;
575573
int threshold = 0;
576-
vTaskDelay(1000 / portTICK_PERIOD_MS);
574+
bool stalled = false;
577575
if (bothDirections) {
576+
// Back off limit in case we are alread here.
577+
stepper->move(-userConfig->getShiftStep());
578+
while (stepper->isRunning()) {
579+
vTaskDelay(50 / portTICK_PERIOD_MS);
580+
}
581+
this->updateStepperSpeed(1500);
582+
vTaskDelay(500 / portTICK_PERIOD_MS);
578583
stepper->runForward();
579584
vTaskDelay(250 / portTICK_PERIOD_MS); // wait until stable
580585
threshold = driver.SG_RESULT(); // take reading
581586
Serial.printf("%d ", driver.SG_RESULT());
582587
vTaskDelay(250 / portTICK_PERIOD_MS);
583588
while (!stalled) {
584-
// stalled = (threshold < 200); // Were we already at the stop?
589+
if (abs(rtConfig->getShifterPosition() - ss2k->lastShifterPosition)) { // let the user abort with the shift button.
590+
userConfig->setHMin(INT32_MIN);
591+
userConfig->setHMax(INT32_MIN);
592+
return;
593+
}
585594
stalled = (driver.SG_RESULT() < threshold - 100);
586595
}
587596
stalled = false;
@@ -591,13 +600,25 @@ void SS2K::goHome(bool bothDirections) {
591600
rtConfig->setMaxStep(stepper->getCurrentPosition() - 200);
592601
SS2K_LOG(MAIN_LOG_TAG, "Max Position found: %d.", rtConfig->getMaxStep());
593602
stepper->enableOutputs();
603+
} else { // Back off limit in case we are alread here.
604+
stepper->move(userConfig->getShiftStep());
605+
while (stepper->isRunning()) {
606+
vTaskDelay(50 / portTICK_PERIOD_MS);
607+
}
608+
this->updateStepperSpeed(1500);
609+
vTaskDelay(500 / portTICK_PERIOD_MS);
594610
}
595611
stepper->runBackward();
596612
vTaskDelay(250 / portTICK_PERIOD_MS);
597613
threshold = driver.SG_RESULT();
598614
Serial.printf("%d ", driver.SG_RESULT());
599615
vTaskDelay(250 / portTICK_PERIOD_MS);
600616
while (!stalled) {
617+
if (abs(rtConfig->getShifterPosition() - ss2k->lastShifterPosition)) { // let the user abort with the shift button.
618+
userConfig->setHMin(INT32_MIN);
619+
userConfig->setHMax(INT32_MIN);
620+
return;
621+
}
601622
stalled = (driver.SG_RESULT() < threshold - 75);
602623
}
603624
stepper->forceStop();

0 commit comments

Comments
 (0)