Browse Source

Activate LiquidTWI2 device detection and space-pad LCD status line.

neildarlow 11 years ago
parent
commit
7325d7102e

+ 2
- 0
Marlin/Marlin_main.cpp View File

@@ -1627,6 +1627,8 @@ void process_commands()
1627 1627
           lcd_update();
1628 1628
         }
1629 1629
       }else{
1630
+          if (!lcd_detected())
1631
+            break;
1630 1632
         while(!lcd_clicked()){
1631 1633
           manage_heater();
1632 1634
           manage_inactivity();

+ 19
- 0
Marlin/ultralcd.cpp View File

@@ -1148,6 +1148,11 @@ void lcd_setstatus(const char* message)
1148 1148
     if (lcd_status_message_level > 0)
1149 1149
         return;
1150 1150
     strncpy(lcd_status_message, message, LCD_WIDTH);
1151
+
1152
+    size_t i = strlen(lcd_status_message);
1153
+    memset(lcd_status_message + i, ' ', LCD_WIDTH - i);
1154
+    lcd_status_message[LCD_WIDTH] = '\0';
1155
+
1151 1156
     lcdDrawUpdate = 2;
1152 1157
 }
1153 1158
 void lcd_setstatuspgm(const char* message)
@@ -1155,6 +1160,11 @@ void lcd_setstatuspgm(const char* message)
1155 1160
     if (lcd_status_message_level > 0)
1156 1161
         return;
1157 1162
     strncpy_P(lcd_status_message, message, LCD_WIDTH);
1163
+
1164
+    size_t i = strlen(lcd_status_message);
1165
+    memset(lcd_status_message + i, ' ', LCD_WIDTH - i);
1166
+    lcd_status_message[LCD_WIDTH] = '\0';
1167
+
1158 1168
     lcdDrawUpdate = 2;
1159 1169
 }
1160 1170
 void lcd_setalertstatuspgm(const char* message)
@@ -1263,6 +1273,15 @@ void lcd_buttons_update()
1263 1273
     lastEncoderBits = enc;
1264 1274
 }
1265 1275
 
1276
+bool lcd_detected(void)
1277
+{
1278
+#if (defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE)
1279
+  return lcd.LcdDetected() == 1;
1280
+#else
1281
+  return true;
1282
+#endif
1283
+}
1284
+
1266 1285
 void lcd_buzz(long duration, uint16_t freq)
1267 1286
 {
1268 1287
 #ifdef LCD_USE_I2C_BUZZER

+ 2
- 0
Marlin/ultralcd.h View File

@@ -11,6 +11,7 @@
11 11
   void lcd_setstatuspgm(const char* message);
12 12
   void lcd_setalertstatuspgm(const char* message);
13 13
   void lcd_reset_alert_level();
14
+  bool lcd_detected(void);
14 15
 
15 16
 #ifdef DOGLCD
16 17
   extern int lcd_contrast;
@@ -92,6 +93,7 @@
92 93
   FORCE_INLINE void lcd_buttons_update() {}
93 94
   FORCE_INLINE void lcd_reset_alert_level() {}
94 95
   FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
96
+  FORCE_INLINE bool lcd_detected(void) { return true; }
95 97
 
96 98
   #define LCD_MESSAGEPGM(x) 
97 99
   #define LCD_ALERTMESSAGEPGM(x) 

+ 10
- 2
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

@@ -166,13 +166,21 @@ extern volatile uint16_t buttons;  //an extended version of the last checked but
166 166
   #include <Wire.h>
167 167
   #include <LiquidTWI2.h>
168 168
   #define LCD_CLASS LiquidTWI2
169
-  LCD_CLASS lcd(LCD_I2C_ADDRESS);
169
+  #if defined(DETECT_DEVICE)
170
+     LCD_CLASS lcd(LCD_I2C_ADDRESS, 1);
171
+  #else
172
+     LCD_CLASS lcd(LCD_I2C_ADDRESS);
173
+  #endif
170 174
   
171 175
 #elif defined(LCD_I2C_TYPE_MCP23008)
172 176
   #include <Wire.h>
173 177
   #include <LiquidTWI2.h>
174 178
   #define LCD_CLASS LiquidTWI2
175
-  LCD_CLASS lcd(LCD_I2C_ADDRESS);  
179
+  #if defined(DETECT_DEVICE)
180
+     LCD_CLASS lcd(LCD_I2C_ADDRESS, 1);
181
+  #else
182
+     LCD_CLASS lcd(LCD_I2C_ADDRESS);
183
+  #endif
176 184
 
177 185
 #elif defined(LCD_I2C_TYPE_PCA8574)
178 186
     #include <LiquidCrystal_I2C.h>

Loading…
Cancel
Save