From cd769781a1629868c15ee7907f85a8ebe74d4ddf Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 24 Nov 2014 16:56:37 -0800 Subject: [PATCH] M0-M1 Enhancements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow M0 and M1 to include a message string. Ignore clicks on “Wait for user” so that the Info Screen stays up. --- Marlin/Marlin_main.cpp | 22 +++++++++++++++++++--- Marlin/ultralcd.cpp | 30 ++++++++++++++++++++++++++++-- Marlin/ultralcd.h | 2 ++ 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 4f691b036..d80913deb 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1841,11 +1841,26 @@ void process_commands() case 0: // M0 - Unconditional stop - Wait for user button press on LCD case 1: // M1 - Conditional stop - Wait for user button press on LCD { - LCD_MESSAGEPGM(MSG_USERWAIT); + char *src = strchr_pointer + 2; + codenum = 0; - if(code_seen('P')) codenum = code_value(); // milliseconds to wait - if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait + bool hasP = code_seen('P'); + if (hasP) codenum = code_value(); // milliseconds to wait + + bool hasS = code_seen('S'); + if (hasS) codenum = code_value() * 1000; // seconds to wait + + if (!hasP && !hasS && *src != '\0') { + while (*src == ' ') ++src; + starpos = strchr(src, '*'); + if (starpos != NULL) *(starpos) = '\0'; + lcd_setstatus(src); + } else { + LCD_MESSAGEPGM(MSG_USERWAIT); + } + + lcd_ignore_click(); st_synchronize(); previous_millis_cmd = millis(); if (codenum > 0){ @@ -1855,6 +1870,7 @@ void process_commands() manage_inactivity(); lcd_update(); } + lcd_ignore_click(false); }else{ while(!lcd_clicked()){ manage_heater(); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index fb2ddbfff..b9e9549d8 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -162,6 +162,7 @@ bool lcd_oldcardstatus; menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */ uint32_t lcd_next_update_millis; uint8_t lcd_status_update_delay; +bool ignore_click = false; uint8_t lcdDrawUpdate = 2; /* Set to none-zero when the LCD needs to draw, decreased after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial) */ //prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings. @@ -189,7 +190,8 @@ static void lcd_status_screen() lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */ } #ifdef ULTIPANEL - if (LCD_CLICKED) + + if (lcd_clicked()) { currentMenu = lcd_main_menu; encoderPosition = 0; @@ -1289,6 +1291,11 @@ void lcd_update() } } +void lcd_ignore_click(bool b) +{ + ignore_click = b; +} + void lcd_setstatus(const char* message) { if (lcd_status_message_level > 0) @@ -1418,7 +1425,26 @@ void lcd_buzz(long duration, uint16_t freq) bool lcd_clicked() { - return LCD_CLICKED; + static bool wait_for_unclick = false; + bool current_click = LCD_CLICKED; + + if (ignore_click) { + if (wait_for_unclick) { + if (!current_click) { + ignore_click = wait_for_unclick = false; + } + else { + current_click = false; + } + } + else if (current_click) { + wait_for_unclick = true; + current_click = false; + lcd_quick_feedback(); + } + } + + return current_click; } #endif//ULTIPANEL diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 9bf685805..761cd5f01 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -48,6 +48,8 @@ void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); + void lcd_ignore_click(bool b=true); + #ifdef NEWPANEL #define EN_C (1<