Skip to content

Commit

Permalink
Merge pull request #264 from doudar/Power-Correction-Factor-Fix
Browse files Browse the repository at this point in the history
PCF min .5 max 2.5 and added check within limits.
  • Loading branch information
doudar authored Dec 2, 2021
2 parents 7beb44b + a459f94 commit 17355c4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Firmware update will now download only spiffs files if missing without updating the firmware.
- New UDP logger by @MarkusSchneider .
- Added custom IC4 build and mount by @eMadman .

### BugFixes
- Power Correction factor now minimum .5 maximum 2.5 and added checks to stay within limits.
- 404 now redirects to index file handler.
- settings_processor now checks shiftsteps to determine if it's on the main settings page.
- settings_processor now checks shiftsteps field to determine if it's on the main settings page.


## [1.11.24]

### Added
- New UDP logger by @MarkusSchneider .
- Added custom IC4 build and mount by @eMadman .
- Moved FTMS callback decoding outside of the callback.
- Revamped the way notify buffer works as it was causing a memory leak.
- BLE Custom Characteristic motor driver calls now apply settings received.
Expand Down
2 changes: 1 addition & 1 deletion data/bluetoothscanner.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h2>
<input type='button'
onclick="clickStep(document.getElementById('powerCorrectionFactor'), this.value)" value="-">
<input style="width:50%; position: relative; top: 5px; left: 0px;" type="range" id="powerCorrectionFactor"
name="powerCorrectionFactor" value="1.00" min="0.5" max="2.0" step="0.01" class="slider1"
name="powerCorrectionFactor" value="1.00" min="0.5" max="2.5" step="0.01" class="slider1"
onchange="updateSlider(this.value, document.getElementById('powerCorrectionFactorValue'))" />
<input type='button'
onclick="clickStep(document.getElementById('powerCorrectionFactor'), this.value)" value="+">
Expand Down
6 changes: 6 additions & 0 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
// to make that commitment yet.
#define INCLINE_MULTIPLIER 3.0

// Minumum value for power correction factor user setting
#define MIN_PCF .5

// Maximum value for power correction factor user setting
#define MAX_PCF 2.5

// Default Stepper Power.
// Stepper peak current in ma. This is hardware restricted to a maximum of 2000ma on the TMC2225. RMS current is less.

Expand Down
2 changes: 1 addition & 1 deletion src/HTTP_Server_Basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void settingsProcessor() {
}
if (!server.arg("powerCorrectionFactor").isEmpty()) {
float powerCorrectionFactor = server.arg("powerCorrectionFactor").toFloat();
if (powerCorrectionFactor >= 0 && powerCorrectionFactor <= 2) {
if (powerCorrectionFactor >= MIN_PCF && powerCorrectionFactor <= MAX_PCF) {
userConfig.setPowerCorrectionFactor(powerCorrectionFactor);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/SmartSpin_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ void userParameters::loadFromSPIFFS() {
setStepperPower(doc["stepperPower"]);
setStealthChop(doc["stealthchop"]);
setInclineMultiplier(doc["inclineMultiplier"]);
setPowerCorrectionFactor(doc["powerCorrectionFactor"]);
if (doc["powerCorrectionFactor"]) {
setPowerCorrectionFactor(doc["powerCorrectionFactor"]);
if ((getPowerCorrectionFactor() < MIN_PCF) || (getPowerCorrectionFactor() > MAX_PCF)) {
setPowerCorrectionFactor(1);
}
}
setSimulateHr(false); // Set these false because previous config versions may return true and these values are no longer saved.
setSimulateWatts(false);
setSimulateCad(false);
Expand Down
2 changes: 1 addition & 1 deletion src/UdpLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ void UdpLogger::log_internal(const char *format, va_list args) {
this->udp.write((uint8_t *)buffer, strlen(buffer));
this->udp.endPacket();
} else {
ESP_LOGE(UDP_LOGGER_TAG, "UPD not logging. No WIFI connection.");
//ESP_LOGE(UDP_LOGGER_TAG, "UPD not logging. No WIFI connection.");
}
}

0 comments on commit 17355c4

Please sign in to comment.