Add msg on stop, start-target, Optimize logging
This commit is contained in:
parent
c1a12d93f0
commit
070fd7069d
@ -89,19 +89,25 @@ void changeState (systemState_t stateNew) {
|
||||
//===== handle Stop Condition =====
|
||||
//function that checks whether start button is released or target is reached (used in multiple states)
|
||||
//returns true when stopped, false when no action
|
||||
bool handleStopCondition(){
|
||||
bool handleStopCondition(handledDisplay * displayTop, handledDisplay * displayBot){
|
||||
//--- stop conditions ---
|
||||
//stop conditions that are checked in any mode
|
||||
//target reached
|
||||
if (lengthRemaining <= 0 ) {
|
||||
changeState(TARGET_REACHED);
|
||||
vfd_setState(false);
|
||||
displayTop->blink(1, 0, 1500, " S0LL ");
|
||||
displayBot->blink(1, 0, 1500, "ERREICHT");
|
||||
buzzer.beep(2, 100, 100);
|
||||
return true;
|
||||
}
|
||||
//start button released
|
||||
else if (SW_START.state == false) {
|
||||
changeState(COUNTING);
|
||||
vfd_setState(false);
|
||||
displayTop->blink(2, 900, 1000, "- STOP -");
|
||||
displayBot->blink(2, 900, 1000, " TASTER ");
|
||||
buzzer.beep(3, 200, 100);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -237,7 +243,7 @@ void task_control(void *pvParameter)
|
||||
}
|
||||
if (SW_SET.fallingEdge) {
|
||||
buzzer.beep(2, 70, 50);
|
||||
displayBot.blink(3, 100, 100, "S0LL ");
|
||||
displayBot.blink(2, 100, 100, "S0LL ");
|
||||
}
|
||||
|
||||
|
||||
@ -251,12 +257,12 @@ void task_control(void *pvParameter)
|
||||
else if (SW_PRESET2.risingEdge) {
|
||||
lengthTarget = 5000;
|
||||
buzzer.beep(lengthTarget/1000, 25, 30);
|
||||
displayBot.blink(3, 100, 100, "S0LL ");
|
||||
displayBot.blink(2, 100, 100, "S0LL ");
|
||||
}
|
||||
else if (SW_PRESET3.risingEdge) {
|
||||
lengthTarget = 10000;
|
||||
buzzer.beep(lengthTarget/1000, 25, 30);
|
||||
displayBot.blink(3, 100, 100, "S0LL ");
|
||||
displayBot.blink(2, 100, 100, "S0LL ");
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,6 +278,7 @@ void task_control(void *pvParameter)
|
||||
switch (controlState) {
|
||||
case COUNTING: //no motor action
|
||||
vfd_setState(false);
|
||||
//TODO check stop condition before starting - prevents motor from starting 2 cycles when
|
||||
//--- start winding to length ---
|
||||
if (SW_START.risingEdge) {
|
||||
changeState(WINDING_START);
|
||||
@ -289,14 +296,14 @@ void task_control(void *pvParameter)
|
||||
if (esp_log_timestamp() - timestamp_motorStarted > 2000) {
|
||||
changeState(WINDING);
|
||||
}
|
||||
handleStopCondition(); //stops if button released or target reached
|
||||
handleStopCondition(&displayTop, &displayBot); //stops if button released or target reached
|
||||
//TODO: cancel when there was no cable movement during start time?
|
||||
break;
|
||||
|
||||
case WINDING: //wind fast, slow down when close
|
||||
//set vfd speed depending on remaining distance
|
||||
setDynSpeedLvl(); //slow down when close to target
|
||||
handleStopCondition(); //stops if button released or target reached
|
||||
handleStopCondition(&displayTop, &displayBot); //stops if button released or target reached
|
||||
//TODO: cancel when there is no cable movement anymore e.g. empty / timeout?
|
||||
break;
|
||||
|
||||
@ -306,6 +313,12 @@ void task_control(void *pvParameter)
|
||||
if ( lengthRemaining > 0 ) {
|
||||
changeState(COUNTING);
|
||||
}
|
||||
//show msg when trying to start, but target is reached
|
||||
if (SW_START.risingEdge){
|
||||
buzzer.beep(3, 40, 30);
|
||||
displayTop.blink(2, 600, 800, " S0LL ");
|
||||
displayBot.blink(2, 600, 800, "ERREICHT");
|
||||
}
|
||||
break;
|
||||
|
||||
case MANUAL: //manually control motor via preset buttons + poti
|
||||
|
@ -90,6 +90,7 @@ void handledDisplay::showString(const char * buf, uint8_t pos_f){
|
||||
//exit blinking mode
|
||||
if (mode == displayMode::BLINK_STRINGS){
|
||||
mode = displayMode::NORMAL;
|
||||
ESP_LOGI(TAG, "pos:%i - disable blink strings mode -> normal mode str='%s'", posStart, strOn);
|
||||
}
|
||||
handle(); //draws the text depending on mode
|
||||
}
|
||||
@ -112,7 +113,7 @@ void handledDisplay::blinkStrings(const char * strOn_f, const char * strOff_f, u
|
||||
//if changed to blink mode just now:
|
||||
if (mode != displayMode::BLINK_STRINGS) {
|
||||
//switch mode
|
||||
ESP_LOGI(TAG, "pos:%i changing to blink mode", posStart);
|
||||
ESP_LOGI(TAG, "pos:%i - toggle blink strings mode on/off=%d/%d stings='%s'/'%s'", posStart, msOn, msOff, strOn, strOff);
|
||||
mode = displayMode::BLINK_STRINGS;
|
||||
//start with on state
|
||||
state = true;
|
||||
@ -129,18 +130,21 @@ void handledDisplay::blinkStrings(const char * strOn_f, const char * strOff_f, u
|
||||
//-------------------------------
|
||||
//function triggers certain count and interval of off durations
|
||||
void handledDisplay::blink(uint8_t count_f, uint32_t msOn_f, uint32_t msOff_f, const char * strOff_f) {
|
||||
//set to blink mode
|
||||
mode = displayMode::BLINK;
|
||||
//copy parameters
|
||||
//copy/update parameters
|
||||
count = count_f;
|
||||
msOn = msOn_f;
|
||||
msOff = msOff_f;
|
||||
strcpy(strOff, strOff_f);
|
||||
//FIXME this strings length must be dynamic depending on display size (posEnd - posStart) -> otherwise overwrites next segments if other display size or start pos
|
||||
ESP_LOGI(TAG, "start blinking: count=%i on/off=%d/%d", count, msOn, msOff);
|
||||
//start with off state
|
||||
state = false;
|
||||
timestampOff = esp_log_timestamp();
|
||||
//if changed to blink mode just now:
|
||||
if (mode != displayMode::BLINK) {
|
||||
//set to blink mode
|
||||
mode = displayMode::BLINK;
|
||||
ESP_LOGI(TAG, "pos:%i - start blinking: count=%i on/off=%d/%d sting='%s'",posStart, count, msOn, msOff, strOff);
|
||||
//start with off state
|
||||
state = false;
|
||||
timestampOff = esp_log_timestamp();
|
||||
}
|
||||
//run handle function for display update
|
||||
handle();
|
||||
}
|
||||
@ -186,7 +190,7 @@ void handledDisplay::handle() {
|
||||
if (mode == displayMode::BLINK){
|
||||
if (count == 0) {
|
||||
mode = displayMode::NORMAL;
|
||||
ESP_LOGI(TAG, "finished blinking -> normal mode");
|
||||
ESP_LOGI(TAG, "pos:%i - finished blinking -> normal mode", posStart);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user