Browse Source

Generalize menu_block_entering_on_serious_errors for menu lockout

Call this variable menu_block_mask instead. We don't need to know the
exact reason of why we're locking the menu.

We will be able to reuse this to prevent menu entry during more
activities in a cleaner way than testing for each condition as it's
currently done for both menu entry and longpress.
Yuri D'Elia 1 year ago
parent
commit
374b829fb6
5 changed files with 18 additions and 19 deletions
  1. 3 0
      Firmware/Marlin_main.cpp
  2. 1 1
      Firmware/menu.cpp
  3. 11 14
      Firmware/menu.h
  4. 1 2
      Firmware/temperature.cpp
  5. 2 2
      Firmware/ultralcd.cpp

+ 3 - 0
Firmware/Marlin_main.cpp

@@ -9990,6 +9990,9 @@ void ThermalStop(bool allow_pause)
         } else {
             // We got a hard thermal error and/or there is no print going on. Just stop.
             lcd_print_stop();
+
+            // Also prevent further menu entry
+            menu_set_block(MENU_BLOCK_THERMAL_ERROR);
         }
 
         // Report the status on the serial, switch to a busy state

+ 1 - 1
Firmware/menu.cpp

@@ -24,7 +24,7 @@ uint8_t menu_data[MENU_DATA_SIZE];
 #endif
 
 uint8_t menu_depth = 0;
-uint8_t menu_block_entering_on_serious_errors = SERIOUS_ERR_NONE;
+uint8_t menu_block_mask = MENU_BLOCK_NONE;
 uint8_t menu_line = 0;
 uint8_t menu_item = 0;
 uint8_t menu_row = 0;

+ 11 - 14
Firmware/menu.h

@@ -29,26 +29,23 @@ extern uint8_t menu_data[MENU_DATA_SIZE];
 
 extern uint8_t menu_depth;
 
-//! definition of serious errors possibly blocking the main menu
+//! definition of reasons blocking the main menu
 //! Use them as bit mask, so that the code may set various errors at the same time
 enum ESeriousErrors {
-	SERIOUS_ERR_NONE            = 0,
-	SERIOUS_ERR_MINTEMP_HEATER  = 0x01,
-	SERIOUS_ERR_MINTEMP_BED     = 0x02
+	MENU_BLOCK_NONE             = 0,
+	MENU_BLOCK_THERMAL_ERROR    = 0x01,
 }; // and possibly others in the future.
 
-//! this is a flag for disabling entering the main menu. If this is set
-//! to anything != 0, the only the main status screen will be shown on the
-//! LCD and the user will be prevented from entering the menu.
-//! Now used only to block doing anything with the printer when there is
-//! the infamous MINTEMP error (SERIOUS_ERR_MINTEMP).
-extern uint8_t menu_block_entering_on_serious_errors;
+//! this is a flag for disabling entering the main menu and longpress. If this is set to anything !=
+//! 0, the only the main status screen will be shown on the LCD and the user will be prevented from
+//! entering the menu.
+extern uint8_t menu_block_mask;
 
-//! a pair of macros for manipulating the serious errors
+//! a pair of macros for manipulating menu entry
 //! a c++ class would have been better
-#define menu_set_serious_error(x) menu_block_entering_on_serious_errors |= x;
-#define menu_unset_serious_error(x) menu_block_entering_on_serious_errors &= ~x;
-#define menu_is_serious_error(x) (menu_block_entering_on_serious_errors & x) != 0
+#define menu_set_block(x) menu_block_mask |= x;
+#define menu_unset_block(x) menu_block_mask &= ~x;
+#define menu_is_blocked(x) (menu_block_mask & x) != 0
 
 extern uint8_t menu_line;
 extern uint8_t menu_item;

+ 1 - 2
Firmware/temperature.cpp

@@ -1700,7 +1700,6 @@ void handle_temp_error()
         switch((TempErrorSource)temp_error_state.source) {
         case TempErrorSource::hotend:
             if(temp_error_state.assert) {
-                menu_set_serious_error(SERIOUS_ERR_MINTEMP_HEATER);
                 min_temp_error(temp_error_state.index);
             } else {
                 // no recovery, just force the user to restart the printer
@@ -1714,7 +1713,6 @@ void handle_temp_error()
             break;
         case TempErrorSource::bed:
             if(temp_error_state.assert) {
-                menu_set_serious_error(SERIOUS_ERR_MINTEMP_BED);
                 bed_min_temp_error();
             } else {
                 // no recovery, just force the user to restart the printer
@@ -1772,6 +1770,7 @@ void handle_temp_error()
         } else {
             temp_error_state.v = 0;
             WRITE(BEEPER, LOW);
+            menu_unset_block(MENU_BLOCK_THERMAL_ERROR);
             SERIAL_ECHOLNPGM("TM: error cleared");
         }
         break;

+ 2 - 2
Firmware/ultralcd.cpp

@@ -863,7 +863,7 @@ void lcd_status_screen()                          // NOT static due to using ins
 	}
 
 	if (current_click
-		&& ( menu_block_entering_on_serious_errors == SERIOUS_ERR_NONE ) // or a serious error blocks entering the menu
+		&& ( menu_block_mask == MENU_BLOCK_NONE ) // or a serious error blocks entering the menu
 	)
 	{
 		menu_depth = 0; //redundant, as already done in lcd_return_to_status(), just to be sure
@@ -8076,7 +8076,7 @@ uint8_t get_message_level()
 void menu_lcd_longpress_func(void)
 {
 	backlight_wake();
-    if (homing_flag || mesh_bed_leveling_flag || menu_menu == lcd_babystep_z || menu_menu == lcd_move_z || menu_block_entering_on_serious_errors != SERIOUS_ERR_NONE)
+    if (homing_flag || mesh_bed_leveling_flag || menu_menu == lcd_babystep_z || menu_menu == lcd_move_z || menu_block_mask != MENU_BLOCK_NONE)
     {
         // disable longpress during re-entry, while homing, calibration or if a serious error
         lcd_quick_feedback();