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
           lcd_update();
1627
           lcd_update();
1628
         }
1628
         }
1629
       }else{
1629
       }else{
1630
+          if (!lcd_detected())
1631
+            break;
1630
         while(!lcd_clicked()){
1632
         while(!lcd_clicked()){
1631
           manage_heater();
1633
           manage_heater();
1632
           manage_inactivity();
1634
           manage_inactivity();

+ 19
- 0
Marlin/ultralcd.cpp View File

1148
     if (lcd_status_message_level > 0)
1148
     if (lcd_status_message_level > 0)
1149
         return;
1149
         return;
1150
     strncpy(lcd_status_message, message, LCD_WIDTH);
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
     lcdDrawUpdate = 2;
1156
     lcdDrawUpdate = 2;
1152
 }
1157
 }
1153
 void lcd_setstatuspgm(const char* message)
1158
 void lcd_setstatuspgm(const char* message)
1155
     if (lcd_status_message_level > 0)
1160
     if (lcd_status_message_level > 0)
1156
         return;
1161
         return;
1157
     strncpy_P(lcd_status_message, message, LCD_WIDTH);
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
     lcdDrawUpdate = 2;
1168
     lcdDrawUpdate = 2;
1159
 }
1169
 }
1160
 void lcd_setalertstatuspgm(const char* message)
1170
 void lcd_setalertstatuspgm(const char* message)
1263
     lastEncoderBits = enc;
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
 void lcd_buzz(long duration, uint16_t freq)
1285
 void lcd_buzz(long duration, uint16_t freq)
1267
 {
1286
 {
1268
 #ifdef LCD_USE_I2C_BUZZER
1287
 #ifdef LCD_USE_I2C_BUZZER

+ 2
- 0
Marlin/ultralcd.h View File

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

+ 10
- 2
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

166
   #include <Wire.h>
166
   #include <Wire.h>
167
   #include <LiquidTWI2.h>
167
   #include <LiquidTWI2.h>
168
   #define LCD_CLASS LiquidTWI2
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
 #elif defined(LCD_I2C_TYPE_MCP23008)
175
 #elif defined(LCD_I2C_TYPE_MCP23008)
172
   #include <Wire.h>
176
   #include <Wire.h>
173
   #include <LiquidTWI2.h>
177
   #include <LiquidTWI2.h>
174
   #define LCD_CLASS LiquidTWI2
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
 #elif defined(LCD_I2C_TYPE_PCA8574)
185
 #elif defined(LCD_I2C_TYPE_PCA8574)
178
     #include <LiquidCrystal_I2C.h>
186
     #include <LiquidCrystal_I2C.h>

Loading…
Cancel
Save