Browse Source

Do not kill printer if External SPI flash W25X20CL is not responding.

Remove internationalization macro for this message. It has no sense to be translated as internationalization in most cases doesn't work if it is not responding.
Show this message instead of splash screen if the error is encountered.
There is no additional delay or wait for click, as such functions doesn't work in setup function.
Marek Bel 5 years ago
parent
commit
75fac9dab2
3 changed files with 34 additions and 23 deletions
  1. 28 13
      Firmware/Marlin_main.cpp
  2. 4 10
      Firmware/lcd.h
  3. 2 0
      Firmware/optiboot_w25x20cl.cpp

+ 28 - 13
Firmware/Marlin_main.cpp

@@ -977,6 +977,12 @@ void list_sec_lang_from_external_flash()
 #endif //(LANG_MODE != 0)
 
 
+static void w25x20cl_err_msg()
+{
+    lcd_puts_P(_n(ESC_2J ESC_H(0,0) "External SPI flash" ESC_H(0,1) "W25X20CL is not res-"
+            ESC_H(0,2) "ponding. Language" ESC_H(0,3) "switch unavailable."));
+}
+
 // "Setup" function is called by the Arduino framework on startup.
 // Before startup, the Timers-functions (PWM)/Analog RW and HardwareSerial provided by the Arduino-code 
 // are initialized by the main() routine provided by the Arduino framework.
@@ -993,21 +999,25 @@ void setup()
 	spi_init();
 
 	lcd_splash();
-     Sound_Init();                                // also guarantee "SET_OUTPUT(BEEPER)"
+    Sound_Init();                                // also guarantee "SET_OUTPUT(BEEPER)"
 
 #ifdef W25X20CL
-	if (!w25x20cl_init())
-		kill(_i("External SPI flash W25X20CL not responding."));
-	// Enter an STK500 compatible Optiboot boot loader waiting for flashing the languages to an external flash memory.
-	optiboot_w25x20cl_enter();
-#endif
-
+    bool w25x20cl_success = w25x20cl_init();
+	if (w25x20cl_success)
+	{
+	    optiboot_w25x20cl_enter();
 #if (LANG_MODE != 0) //secondary language support
-#ifdef W25X20CL
-	if (w25x20cl_init())
-		update_sec_lang_from_external_flash();
-#endif //W25X20CL
+        update_sec_lang_from_external_flash();
 #endif //(LANG_MODE != 0)
+	}
+	else
+	{
+	    w25x20cl_err_msg();
+	}
+#else
+	const bool w25x20cl_success = true;
+#endif //W25X20CL
+
 
 	setup_killpin();
 	setup_powerhold();
@@ -1213,12 +1223,17 @@ void setup()
 
 	tp_init();    // Initialize temperature loop
 
-	lcd_splash(); // we need to do this again, because tp_init() kills lcd
+	if (w25x20cl_success) lcd_splash(); // we need to do this again, because tp_init() kills lcd
+	else
+	{
+	    w25x20cl_err_msg();
+	    printf_P(_n("W25X20CL not responding.\n"));
+	}
 
 	plan_init();  // Initialize planner;
 
 	factory_reset();
-     lcd_encoder_diff=0;
+    lcd_encoder_diff=0;
 
 #ifdef TMC2130
 	uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);

+ 4 - 10
Firmware/lcd.h

@@ -64,23 +64,17 @@ extern void lcd_print(long, int = 10);
 extern void lcd_print(unsigned long, int = 10);
 extern void lcd_print(double, int = 2);
 
+//! @brief Clear screen
 #define ESC_2J     "\x1b[2J"
 #define ESC_25h    "\x1b[?25h"
 #define ESC_25l    "\x1b[?25l"
+//! @brief Set cursor to
+//! @param c column
+//! @param r row
 #define ESC_H(c,r) "\x1b["#r";"#c"H"
 
 
 
-
-
-
-
-
-
-
-
-
-
 #define LCD_UPDATE_INTERVAL    100
 #define LCD_TIMEOUT_TO_STATUS 30000ul //!< Generic timeout to status screen in ms, when no user action.
 #define LCD_TIMEOUT_TO_STATUS_BABYSTEP_Z 90000ul //!< Specific timeout for lcd_babystep_z screen in ms.

+ 2 - 0
Firmware/optiboot_w25x20cl.cpp

@@ -1,3 +1,4 @@
+//! @file
 // Based on the OptiBoot project
 // https://github.com/Optiboot/optiboot
 // Licence GLP 2 or later.
@@ -97,6 +98,7 @@ static const char entry_magic_cfm    [] PROGMEM = "w25x20cl_cfm\n";
 struct block_t;
 extern struct block_t *block_buffer;
 
+//! @brief Enter an STK500 compatible Optiboot boot loader waiting for flashing the languages to an external flash memory.
 void optiboot_w25x20cl_enter()
 {
   if (boot_app_flags & BOOT_APP_FLG_USER0) return;