Add autoCut-cancel with any button; Fix display init
- Pending auto cut (countdown) can be canceled using any button on the panel - Reset button does not reset the length when countdown cancledo - Fix bug where display did not initialize correctly after start some times -> simply init again after welcome msg - reduce countdown time by 500ms
This commit is contained in:
parent
4cb6b41a6b
commit
d473bf6b8c
@ -54,7 +54,7 @@ int lengthBeeped = 0; //only beep once per meter during encoder test
|
||||
//automatic cut
|
||||
int cut_msRemaining = 0;
|
||||
uint32_t timestamp_cut_lastBeep = 0;
|
||||
uint32_t autoCut_delayMs = 3000; //TODO add this to config
|
||||
uint32_t autoCut_delayMs = 2500; //TODO add this to config
|
||||
bool autoCutEnabled = false; //store state of toggle switch (no hotswitch)
|
||||
|
||||
|
||||
@ -190,12 +190,15 @@ void task_control(void *pvParameter)
|
||||
//---------------------------
|
||||
//--- RESET switch ---
|
||||
if (SW_RESET.risingEdge) {
|
||||
rotary_encoder_reset(&encoder);
|
||||
lengthNow = 0;
|
||||
buzzer.beep(1, 700, 100);
|
||||
displayTop.blink(2, 100, 100, "1ST ");
|
||||
//TODO: stop cutter with reset switch?
|
||||
//cutter_stop();
|
||||
//dont reset when press used for stopping pending auto-cut
|
||||
if (controlState != systemState_t::AUTO_CUT_WAITING) {
|
||||
rotary_encoder_reset(&encoder);
|
||||
lengthNow = 0;
|
||||
buzzer.beep(1, 700, 100);
|
||||
displayTop.blink(2, 100, 100, "1ST ");
|
||||
//TODO: stop cutter with reset switch?
|
||||
//cutter_stop();
|
||||
}
|
||||
}
|
||||
|
||||
//--- CUT switch ---
|
||||
@ -206,6 +209,9 @@ void task_control(void *pvParameter)
|
||||
cutter_stop();
|
||||
buzzer.beep(1, 600, 0);
|
||||
}
|
||||
else if (controlState == systemState_t::AUTO_CUT_WAITING) {
|
||||
//do nothing when press used for stopping pending auto-cut
|
||||
}
|
||||
//start cutter when motor not active
|
||||
else if (controlState != systemState_t::WINDING_START //TODO use vfd state here?
|
||||
&& controlState != systemState_t::WINDING) {
|
||||
@ -363,8 +369,13 @@ void task_control(void *pvParameter)
|
||||
//handle delayed start of cut
|
||||
cut_msRemaining = autoCut_delayMs - (esp_log_timestamp() - timestamp_changedState);
|
||||
//- countdown stop conditions -
|
||||
if (!autoCutEnabled || !SW_AUTO_CUT.state || SW_RESET.state || SW_CUT.state) { //TODO: also stop when target not reached anymore?
|
||||
//stop with any button
|
||||
if (!autoCutEnabled
|
||||
|| SW_RESET.state || SW_CUT.state
|
||||
|| SW_SET.state || SW_PRESET1.state
|
||||
|| SW_PRESET2.state || SW_PRESET3.state) {//TODO: also stop when target not reached anymore?
|
||||
changeState(systemState_t::COUNTING);
|
||||
buzzer.beep(5, 100, 50);
|
||||
}
|
||||
//- trigger cut if delay passed -
|
||||
else if (cut_msRemaining <= 0) {
|
||||
|
@ -34,7 +34,7 @@ max7219_t display_init(){
|
||||
ESP_ERROR_CHECK(max7219_init_desc(&dev, HOST, MAX7219_MAX_CLOCK_SPEED_HZ, DISPLAY_PIN_NUM_CS));
|
||||
ESP_ERROR_CHECK(max7219_init(&dev));
|
||||
//0...15
|
||||
ESP_ERROR_CHECK(max7219_set_brightness(&dev, 8));
|
||||
ESP_ERROR_CHECK(max7219_set_brightness(&dev, 8)); //TODO add this to config
|
||||
return dev;
|
||||
//display = dev;
|
||||
ESP_LOGI(TAG, "initializing display - done");
|
||||
@ -50,7 +50,7 @@ void display_ShowWelcomeMsg(max7219_t dev){
|
||||
//show name and date
|
||||
ESP_LOGI(TAG, "showing startup message...");
|
||||
max7219_clear(&dev);
|
||||
max7219_draw_text_7seg(&dev, 0, "CUTTER 20.08.2022");
|
||||
max7219_draw_text_7seg(&dev, 0, "CUTTER 29.09.2022");
|
||||
// 1234567812 34 5678
|
||||
vTaskDelay(pdMS_TO_TICKS(700));
|
||||
//scroll "hello" over 2 displays
|
||||
@ -60,6 +60,11 @@ void display_ShowWelcomeMsg(max7219_t dev){
|
||||
max7219_draw_text_7seg(&dev, 0, hello + (22 - offset) );
|
||||
vTaskDelay(pdMS_TO_TICKS(50));
|
||||
}
|
||||
|
||||
//noticed rare bug that one display does not initialize / is not configured correctly after start
|
||||
//initialize display again after the welcome message in case it did not work the first time
|
||||
ESP_ERROR_CHECK(max7219_init(&dev));
|
||||
ESP_ERROR_CHECK(max7219_set_brightness(&dev, 8)); //TODO add this to config
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user