From 032df0b2c6dde69303f60ee05681e046b1a4aab3 Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Thu, 3 May 2012 14:28:17 +0200 Subject: [PATCH] Moved LCD initialization out of constructor Since the class "MainMenu" was used within a static variable the initialization of the object (constructor call) was done before Arduino library startup. It always caused a crash when using AVRStudio with JTAG debugger (caused from calling the LCD initialization / the lot of I/O work / the stack used during this calls). By moving the LCD_INIT out of the constructor and using an explicit call inside of Arduino setup() implementation immediately fixed all problems and the JTAG debugger runs fine. --- Marlin/Marlin.pde | 2 ++ Marlin/ultralcd.h | 3 ++- Marlin/ultralcd.pde | 7 +++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 2facb9429c..c9cff67de0 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -300,6 +300,8 @@ void setup() st_init(); // Initialize stepper; wd_init(); setup_photpin(); + + LCD_INIT; } diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 253149cbba..39d262222e 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -134,11 +134,12 @@ char *ftostr3(const float &x); - + #define LCD_INIT lcd_init(); #define LCD_MESSAGE(x) lcd_status(x); #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x)); #define LCD_STATUS lcd_status() #else //no lcd + #define LCD_INIT #define LCD_STATUS #define LCD_MESSAGE(x) #define LCD_MESSAGEPGM(x) diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde index a10fbb3421..9124022944 100644 --- a/Marlin/ultralcd.pde +++ b/Marlin/ultralcd.pde @@ -99,6 +99,9 @@ FORCE_INLINE void clear() void lcd_init() { //beep(); + #ifdef ULTIPANEL + buttons_init(); + #endif byte Degree[8] = { @@ -306,10 +309,6 @@ MainMenu::MainMenu() displayStartingRow=0; activeline=0; force_lcd_update=true; - #ifdef ULTIPANEL - buttons_init(); - #endif - lcd_init(); linechanging=false; tune=false; }