Add functional menu items (accel/decel), Add menu-timeout

menu.cpp:
    - add item center-Joystick (functional)
    - add item accel-Limit (functional)
    - add item decel-Limit (functional)
    - fix display freeze on timeout
    - add menu timeout
    - switch to previous mode on exit instead of always idle

motorctl.cpp:
    - add getFade method, to get currently configured values
    - add log output on fade change
This commit is contained in:
jonny_jr9
2024-02-14 23:51:21 +01:00
parent 4f8c421168
commit fe0e0093d0
4 changed files with 165 additions and 41 deletions

View File

@@ -277,6 +277,24 @@ motorCommand_t controlledMotor::getStatus(){
//===============================
//=========== getFade ===========
//===============================
//return currently configured accel / decel time
uint32_t controlledMotor::getFade(fadeType_t fadeType){
switch(fadeType){
case fadeType_t::ACCEL:
return msFadeAccel;
break;
case fadeType_t::DECEL:
return msFadeDecel;
break;
}
return 0;
}
//===============================
//=========== setFade ===========
//===============================
@@ -287,9 +305,11 @@ void controlledMotor::setFade(fadeType_t fadeType, uint32_t msFadeNew){
//TODO: mutex for msFade variable also used in handle function
switch(fadeType){
case fadeType_t::ACCEL:
ESP_LOGW(TAG, "changed fade-up time from %d to %d", msFadeAccel, msFadeNew);
msFadeAccel = msFadeNew;
break;
case fadeType_t::DECEL:
ESP_LOGW(TAG, "changed fade-down time from %d to %d", msFadeDecel, msFadeNew);
msFadeDecel = msFadeNew;
break;
}

View File

@@ -33,6 +33,7 @@ class controlledMotor {
void setTarget(motorstate_t state_f, float duty_f = 0); //adds target command to queue for handle function
motorCommand_t getStatus(); //get current status of the motor (returns struct with state and duty)
uint32_t getFade(fadeType_t fadeType); //get currently set acceleration or deceleration fading time
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
bool toggleFade(fadeType_t fadeType); //toggle acceleration or deceleration on/off
@@ -55,6 +56,7 @@ class controlledMotor {
motorSetCommandFunc_t motorSetCommand;
//--- variables ---
//TODO add name for logging?
//struct for storing control specific parameters
motorctl_config_t config;
motorstate_t state = motorstate_t::IDLE;