Skip to content

Commit

Permalink
Merge pull request #603 from doudar/remove_homing_fix
Browse files Browse the repository at this point in the history
Fixes not shifting after powertable has been deleted (without Cadence)
  • Loading branch information
doudar authored Dec 8, 2024
2 parents 54daaa4 + 499dcdd commit 1c120d4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Hardware


## [24.12.7]

### Added

### Changed
- Fixes homing not being removed after powertable reset.
- Shifting will always abort homing, even if homing hasn't been preformed yet.

### Hardware

## [24.11.25]

### Added
Expand Down
8 changes: 5 additions & 3 deletions src/ERG_Mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ void PowerTable::runERG() {
}

if (ss2k->resetPowerTableFlag) {
LittleFS.remove(POWER_TABLE_FILENAME);
powerTable->reset();
userConfig->setHMin(INT32_MIN);
userConfig->setHMax(INT32_MIN);
spinBLEServer.spinDownFlag = 0;
rtConfig->setHomed(false);
userConfig->saveToLittleFS();
}
Expand Down Expand Up @@ -873,7 +875,7 @@ bool PowerTable::_manageSaveState() {

// If both current and saved tables were created with homing, we can skip position reliability checks
bool canSkipReliabilityChecks = savedHomed && rtConfig->getHomed();

if (!canSkipReliabilityChecks) {
// Initialize a counter for reliable positions
int reliablePositions = 0;
Expand Down Expand Up @@ -914,7 +916,7 @@ bool PowerTable::_manageSaveState() {
file.read((uint8_t*)&version, sizeof(version));
file.read((uint8_t*)&savedQuality, sizeof(savedQuality));
file.read((uint8_t*)&savedHomed, sizeof(savedHomed));

float averageOffset = 0;
if (!canSkipReliabilityChecks) {
std::vector<float> offsetDifferences;
Expand Down Expand Up @@ -966,7 +968,7 @@ bool PowerTable::_manageSaveState() {
}
SS2K_LOG(POWERTABLE_LOG_TAG, "Power Table loaded with an offset of %d.", averageOffset);
}

// set the flag so it isn't loaded again this session.
this->_hasBeenLoadedThisSession = true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ void IRAM_ATTR SS2K::shiftUp() { // Handle the shift up interrupt IRAM_ATTR is
if (ss2k->deBounce()) {
if (!digitalRead(currentBoard.shiftUpPin)) { // double checking to make sure the interrupt wasn't triggered by emf
rtConfig->setShifterPosition(rtConfig->getShifterPosition() - 1 + userConfig->getShifterDir() * 2);
// Stop homing initiation
spinBLEServer.spinDownFlag = 0;
} else {
ss2k->lastDebounceTime = 0;
} // Probably Triggered by EMF, reset the debounce
Expand All @@ -510,6 +512,8 @@ void IRAM_ATTR SS2K::shiftDown() { // Handle the shift down interrupt
if (ss2k->deBounce()) {
if (!digitalRead(currentBoard.shiftDownPin)) { // double checking to make sure the interrupt wasn't triggered by emf
rtConfig->setShifterPosition(rtConfig->getShifterPosition() + 1 - userConfig->getShifterDir() * 2);
// Stop homing initiation
spinBLEServer.spinDownFlag = 0;
} else {
ss2k->lastDebounceTime = 0;
} // Probably Triggered by EMF, reset the debounce
Expand Down

0 comments on commit 1c120d4

Please sign in to comment.