Fix MASSAGE-mode messing up acceleration config
- do not update nvs with low accel when changing to massage - store and restore previous value when changing from/to massage mode
This commit is contained in:
@@ -620,17 +620,19 @@ uint32_t controlledMotor::getFadeDefault(fadeType_t fadeType){
|
||||
//function for editing or enabling the fading/ramp of the motor control
|
||||
|
||||
//set/update fading duration/amount
|
||||
void controlledMotor::setFade(fadeType_t fadeType, uint32_t msFadeNew){
|
||||
void controlledMotor::setFade(fadeType_t fadeType, uint32_t msFadeNew, bool writeToNvs){
|
||||
//TODO: mutex for msFade variable also used in handle function
|
||||
switch(fadeType){
|
||||
case fadeType_t::ACCEL:
|
||||
ESP_LOGW(TAG, "[%s] changed fade-up time from %d to %d", config.name, config.msFadeAccel, msFadeNew);
|
||||
writeAccelDuration(msFadeNew);
|
||||
if (writeToNvs)
|
||||
writeAccelDuration(msFadeNew);
|
||||
break;
|
||||
case fadeType_t::DECEL:
|
||||
ESP_LOGW(TAG, "[%s] changed fade-down time from %d to %d",config.name, config.msFadeDecel, msFadeNew);
|
||||
// write new value to nvs and update the variable
|
||||
writeDecelDuration(msFadeNew);
|
||||
if (writeToNvs)
|
||||
writeDecelDuration(msFadeNew);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class controlledMotor {
|
||||
uint32_t getFade(fadeType_t fadeType); //get currently set acceleration or deceleration fading time
|
||||
uint32_t getFadeDefault(fadeType_t fadeType); //get acceleration or deceleration fading time from config
|
||||
void setFade(fadeType_t fadeType, bool enabled); //enable/disable acceleration or deceleration fading
|
||||
void setFade(fadeType_t fadeType, uint32_t msFadeNew); //set acceleration or deceleration fade time
|
||||
void setFade(fadeType_t fadeType, uint32_t msFadeNew, bool writeToNvs = true); //set acceleration or deceleration fade time and write it to nvs by default
|
||||
bool toggleFade(fadeType_t fadeType); //toggle acceleration or deceleration on/off
|
||||
|
||||
float getCurrentA() {return cSensor.read();}; //read current-sensor of this motor (Ampere)
|
||||
|
||||
Reference in New Issue
Block a user