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
         }
1896
         }
1897
         lcd_ignore_click(false);
1897
         lcd_ignore_click(false);
1898
       }else{
1898
       }else{
1899
+          if (!lcd_detected())
1900
+            break;
1899
         while(!lcd_clicked()){
1901
         while(!lcd_clicked()){
1900
           manage_heater();
1902
           manage_heater();
1901
           manage_inactivity();
1903
           manage_inactivity();

+ 10
- 2
Marlin/cardreader.cpp View File

141
   if(root.isOpen())
141
   if(root.isOpen())
142
     root.close();
142
     root.close();
143
 #ifdef SDSLOW
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
 #else
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
 #endif
155
 #endif
148
   {
156
   {
149
     //if (!card.init(SPI_HALF_SPEED,SDSS))
157
     //if (!card.init(SPI_HALF_SPEED,SDSS))

+ 3
- 3
Marlin/pins.h View File

779
         #define BTN_EN1 47  //reverse if the encoder turns the wrong way.
779
         #define BTN_EN1 47  //reverse if the encoder turns the wrong way.
780
         #define BTN_EN2 43
780
         #define BTN_EN2 43
781
         #define BTN_ENC 32
781
         #define BTN_ENC 32
782
-        #define SDSS 53
782
+        #define LCD_SDSS 53
783
         #define SDCARDDETECT -1
783
         #define SDCARDDETECT -1
784
         #define KILL_PIN 41
784
         #define KILL_PIN 41
785
       #elif defined(LCD_I2C_VIKI)
785
       #elif defined(LCD_I2C_VIKI)
786
         #define BTN_EN1 22  //reverse if the encoder turns the wrong way.
786
         #define BTN_EN1 22  //reverse if the encoder turns the wrong way.
787
         #define BTN_EN2 7
787
         #define BTN_EN2 7
788
         #define BTN_ENC -1
788
         #define BTN_ENC -1
789
-        #define SDSS 53
789
+        #define LCD_SDSS 53
790
         #define SDCARDDETECT 49
790
         #define SDCARDDETECT 49
791
       #else
791
       #else
792
         //arduino pin which triggers an piezzo beeper
792
         //arduino pin which triggers an piezzo beeper
1304
      #ifdef LCD_I2C_PANELOLU2
1304
      #ifdef LCD_I2C_PANELOLU2
1305
        #ifdef MELZI
1305
        #ifdef MELZI
1306
          #define BTN_ENC 29 //the click switch
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
        #else
1308
        #else
1309
          #define BTN_ENC 30 //the click switch
1309
          #define BTN_ENC 30 //the click switch
1310
        #endif
1310
        #endif

+ 20
- 1
Marlin/ultralcd.cpp View File

1262
     lcd_buttons_update();
1262
     lcd_buttons_update();
1263
 
1263
 
1264
     #if (SDCARDDETECT > 0)
1264
     #if (SDCARDDETECT > 0)
1265
-    if((IS_SD_INSERTED != lcd_oldcardstatus))
1265
+    if((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected()))
1266
     {
1266
     {
1267
         lcdDrawUpdate = 2;
1267
         lcdDrawUpdate = 2;
1268
         lcd_oldcardstatus = IS_SD_INSERTED;
1268
         lcd_oldcardstatus = IS_SD_INSERTED;
1365
     if (lcd_status_message_level > 0)
1365
     if (lcd_status_message_level > 0)
1366
         return;
1366
         return;
1367
     strncpy(lcd_status_message, message, LCD_WIDTH);
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
     lcdDrawUpdate = 2;
1373
     lcdDrawUpdate = 2;
1369
 #ifdef FILAMENT_LCD_DISPLAY
1374
 #ifdef FILAMENT_LCD_DISPLAY
1370
         message_millis=millis();  //get status message to show up for a while
1375
         message_millis=millis();  //get status message to show up for a while
1375
     if (lcd_status_message_level > 0)
1380
     if (lcd_status_message_level > 0)
1376
         return;
1381
         return;
1377
     strncpy_P(lcd_status_message, message, LCD_WIDTH);
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
     lcdDrawUpdate = 2;
1388
     lcdDrawUpdate = 2;
1379
 #ifdef FILAMENT_LCD_DISPLAY
1389
 #ifdef FILAMENT_LCD_DISPLAY
1380
         message_millis=millis();  //get status message to show up for a while
1390
         message_millis=millis();  //get status message to show up for a while
1486
     lastEncoderBits = enc;
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
 void lcd_buzz(long duration, uint16_t freq)
1508
 void lcd_buzz(long duration, uint16_t freq)
1490
 {
1509
 {
1491
 #ifdef LCD_USE_I2C_BUZZER
1510
 #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;
100
   FORCE_INLINE void lcd_buttons_update() {}
101
   FORCE_INLINE void lcd_buttons_update() {}
101
   FORCE_INLINE void lcd_reset_alert_level() {}
102
   FORCE_INLINE void lcd_reset_alert_level() {}
102
   FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
103
   FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
104
+  FORCE_INLINE bool lcd_detected(void) { return true; }
103
 
105
 
104
   #define LCD_MESSAGEPGM(x) 
106
   #define LCD_MESSAGEPGM(x) 
105
   #define LCD_ALERTMESSAGEPGM(x) 
107
   #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