Skip to content

Commit

Permalink
Fixes not shifting after powertable has been deleted (without Cadence)
Browse files Browse the repository at this point in the history
- Fixes homing not being removed after powertable reset.
- Shifting will always abort homing, even if homing hasn't been preformed yet.
  • Loading branch information
doudar committed Dec 7, 2024
1 parent 54daaa4 commit 192e19b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

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

### Hardware

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
2 changes: 2 additions & 0 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ 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);
spinBLEServer.spinDownFlag = 0;
} else {
ss2k->lastDebounceTime = 0;
} // Probably Triggered by EMF, reset the debounce
Expand All @@ -510,6 +511,7 @@ 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);
spinBLEServer.spinDownFlag = 0;
} else {
ss2k->lastDebounceTime = 0;
} // Probably Triggered by EMF, reset the debounce
Expand Down

0 comments on commit 192e19b

Please sign in to comment.