Browse Source

Merge pull request #819 from neildarlow/Marlin_v1

Activate LiquidTWI2 device detection and space-pad LCD status line.
Bo Herrmannsen 10 years ago
parent
commit
31ca3de72f

+ 2
- 0
Marlin/Marlin_main.cpp View File

@@ -1896,6 +1896,8 @@ void process_commands()
1896 1896
         }
1897 1897
         lcd_ignore_click(false);
1898 1898
       }else{
1899
+          if (!lcd_detected())
1900
+            break;
1899 1901
         while(!lcd_clicked()){
1900 1902
           manage_heater();
1901 1903
           manage_inactivity();

+ 10
- 2
Marlin/cardreader.cpp View File

@@ -141,9 +141,17 @@ void CardReader::initsd()
141 141
   if(root.isOpen())
142 142
     root.close();
143 143
 #ifdef SDSLOW
144
-  if (!card.init(SPI_HALF_SPEED,SDSS))
144
+  if (!card.init(SPI_HALF_SPEED,SDSS)
145
+  #if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
146
+    && !card.init(SPI_HALF_SPEED,LCD_SDSS)
147
+  #endif
148
+    )
145 149
 #else
146
-  if (!card.init(SPI_FULL_SPEED,SDSS))
150
+  if (!card.init(SPI_FULL_SPEED,SDSS)
151
+  #if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
152
+    && !card.init(SPI_FULL_SPEED,LCD_SDSS)
153
+  #endif
154
+    )
147 155
 #endif
148 156
   {
149 157
     //if (!card.init(SPI_HALF_SPEED,SDSS))

+ 3
- 3
Marlin/pins.h View File

@@ -779,14 +779,14 @@
779 779
         #define BTN_EN1 47  //reverse if the encoder turns the wrong way.
780 780
         #define BTN_EN2 43
781 781
         #define BTN_ENC 32
782
-        #define SDSS 53
782
+        #define LCD_SDSS 53
783 783
         #define SDCARDDETECT -1
784 784
         #define KILL_PIN 41
785 785
       #elif defined(LCD_I2C_VIKI)
786 786
         #define BTN_EN1 22  //reverse if the encoder turns the wrong way.
787 787
         #define BTN_EN2 7
788 788
         #define BTN_ENC -1
789
-        #define SDSS 53
789
+        #define LCD_SDSS 53
790 790
         #define SDCARDDETECT 49
791 791
       #else
792 792
         //arduino pin which triggers an piezzo beeper
@@ -1304,7 +1304,7 @@
1304 1304
      #ifdef LCD_I2C_PANELOLU2
1305 1305
        #ifdef MELZI
1306 1306
          #define BTN_ENC 29 //the click switch
1307
-         #define SDSS 30 //to use the SD card reader on the Panelolu2 rather than the melzi board
1307
+         #define LCD_SDSS 30 //to use the SD card reader on the Panelolu2 rather than the melzi board
1308 1308
        #else
1309 1309
          #define BTN_ENC 30 //the click switch
1310 1310
        #endif

+ 20
- 1
Marlin/ultralcd.cpp View File

@@ -1262,7 +1262,7 @@ void lcd_update()
1262 1262
     lcd_buttons_update();
1263 1263
 
1264 1264
     #if (SDCARDDETECT > 0)
1265
-    if((IS_SD_INSERTED != lcd_oldcardstatus))
1265
+    if((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected()))
1266 1266
     {
1267 1267
         lcdDrawUpdate = 2;
1268 1268
         lcd_oldcardstatus = IS_SD_INSERTED;
@@ -1365,6 +1365,11 @@ void lcd_setstatus(const char* message)
1365 1365
     if (lcd_status_message_level > 0)
1366 1366
         return;
1367 1367
     strncpy(lcd_status_message, message, LCD_WIDTH);
1368
+
1369
+    size_t i = strlen(lcd_status_message);
1370
+    memset(lcd_status_message + i, ' ', LCD_WIDTH - i);
1371
+    lcd_status_message[LCD_WIDTH] = '\0';
1372
+
1368 1373
     lcdDrawUpdate = 2;
1369 1374
 #ifdef FILAMENT_LCD_DISPLAY
1370 1375
         message_millis=millis();  //get status message to show up for a while
@@ -1375,6 +1380,11 @@ void lcd_setstatuspgm(const char* message)
1375 1380
     if (lcd_status_message_level > 0)
1376 1381
         return;
1377 1382
     strncpy_P(lcd_status_message, message, LCD_WIDTH);
1383
+
1384
+    size_t i = strlen(lcd_status_message);
1385
+    memset(lcd_status_message + i, ' ', LCD_WIDTH - i);
1386
+    lcd_status_message[LCD_WIDTH] = '\0';
1387
+
1378 1388
     lcdDrawUpdate = 2;
1379 1389
 #ifdef FILAMENT_LCD_DISPLAY
1380 1390
         message_millis=millis();  //get status message to show up for a while
@@ -1486,6 +1496,15 @@ void lcd_buttons_update()
1486 1496
     lastEncoderBits = enc;
1487 1497
 }
1488 1498
 
1499
+bool lcd_detected(void)
1500
+{
1501
+#if (defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE)
1502
+  return lcd.LcdDetected() == 1;
1503
+#else
1504
+  return true;
1505
+#endif
1506
+}
1507
+
1489 1508
 void lcd_buzz(long duration, uint16_t freq)
1490 1509
 {
1491 1510
 #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;
@@ -100,6 +101,7 @@
100 101
   FORCE_INLINE void lcd_buttons_update() {}
101 102
   FORCE_INLINE void lcd_reset_alert_level() {}
102 103
   FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
104
+  FORCE_INLINE bool lcd_detected(void) { return true; }
103 105
 
104 106
   #define LCD_MESSAGEPGM(x) 
105 107
   #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