Merge pull request #1155 from thinkyhead/lcd_wait_better

M0-M1 Enhancements
This commit is contained in:
nothinman 2014-11-28 11:01:24 +00:00
commit 5a8b3a84ae
3 changed files with 59 additions and 9 deletions

View file

@ -1413,7 +1413,6 @@ void process_commands()
plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data)
#endif //ENABLE_AUTO_BED_LEVELING #endif //ENABLE_AUTO_BED_LEVELING
saved_feedrate = feedrate; saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply; saved_feedmultiply = feedmultiply;
feedmultiply = 100; feedmultiply = 100;
@ -1863,11 +1862,29 @@ void process_commands()
case 0: // M0 - Unconditional stop - Wait for user button press on LCD case 0: // M0 - Unconditional stop - Wait for user button press on LCD
case 1: // M1 - Conditional 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
codenum = 0;
bool hasP = false, hasS = false;
if (code_seen('P')) {
codenum = code_value(); // milliseconds to wait
hasP = codenum > 0;
}
if (code_seen('S')) {
codenum = code_value() * 1000; // seconds to wait
hasS = codenum > 0;
}
if (!hasP && !hasS && *src != '\0') {
starpos = strchr(src, '*');
if (starpos != NULL) *(starpos) = '\0';
while (*src == ' ') ++src;
lcd_setstatus(src);
} else {
LCD_MESSAGEPGM(MSG_USERWAIT);
}
lcd_ignore_click();
st_synchronize(); st_synchronize();
previous_millis_cmd = millis(); previous_millis_cmd = millis();
if (codenum > 0){ if (codenum > 0){
@ -1877,6 +1894,7 @@ void process_commands()
manage_inactivity(); manage_inactivity();
lcd_update(); lcd_update();
} }
lcd_ignore_click(false);
}else{ }else{
while(!lcd_clicked()){ while(!lcd_clicked()){
manage_heater(); manage_heater();
@ -1884,7 +1902,10 @@ void process_commands()
lcd_update(); lcd_update();
} }
} }
if (IS_SD_PRINTING)
LCD_MESSAGEPGM(MSG_RESUMING); LCD_MESSAGEPGM(MSG_RESUMING);
else
LCD_MESSAGEPGM(WELCOME_MSG);
} }
break; break;
#endif #endif

View file

@ -162,6 +162,8 @@ bool lcd_oldcardstatus;
menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */ menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */
uint32_t lcd_next_update_millis; uint32_t lcd_next_update_millis;
uint8_t lcd_status_update_delay; uint8_t lcd_status_update_delay;
bool ignore_click = false;
bool wait_for_unclick;
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) */ 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. //prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
@ -189,7 +191,26 @@ 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 */ 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 #ifdef ULTIPANEL
if (LCD_CLICKED)
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) {
lcd_quick_feedback();
wait_for_unclick = true;
current_click = false;
}
}
if (current_click)
{ {
currentMenu = lcd_main_menu; currentMenu = lcd_main_menu;
encoderPosition = 0; encoderPosition = 0;
@ -1315,6 +1336,12 @@ void lcd_update()
} }
} }
void lcd_ignore_click(bool b)
{
ignore_click = b;
wait_for_unclick = false;
}
void lcd_setstatus(const char* message) void lcd_setstatus(const char* message)
{ {
if (lcd_status_message_level > 0) if (lcd_status_message_level > 0)

View file

@ -48,6 +48,8 @@
void lcd_buzz(long duration,uint16_t freq); void lcd_buzz(long duration,uint16_t freq);
bool lcd_clicked(); bool lcd_clicked();
void lcd_ignore_click(bool b=true);
#ifdef NEWPANEL #ifdef NEWPANEL
#define EN_C (1<<BLEN_C) #define EN_C (1<<BLEN_C)
#define EN_B (1<<BLEN_B) #define EN_B (1<<BLEN_B)