Browse Source

Converge all I2C LCD branches (PANELOLU2, VIKI & PCF8575)

This includes refactoring the buttons code to remove a large amount of
non-pin dependent duplication from pins.h.
Robert F-C 12 years ago
parent
commit
1292d735ba

+ 44
- 17
Marlin/Configuration.h View File

306
 // please keep turned on if you can.
306
 // please keep turned on if you can.
307
 //#define EEPROM_CHITCHAT
307
 //#define EEPROM_CHITCHAT
308
 
308
 
309
+// Preheat Constants
310
+#define PLA_PREHEAT_HOTEND_TEMP 180 
311
+#define PLA_PREHEAT_HPB_TEMP 70
312
+#define PLA_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
313
+
314
+#define ABS_PREHEAT_HOTEND_TEMP 240
315
+#define ABS_PREHEAT_HPB_TEMP 100
316
+#define ABS_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
317
+
309
 //LCD and SD support
318
 //LCD and SD support
310
 //#define ULTRA_LCD  //general lcd support, also 16x2
319
 //#define ULTRA_LCD  //general lcd support, also 16x2
311
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
320
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
312
 
321
 
313
 //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store.
322
 //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store.
314
-//#define ULTIPANEL  //the ultipanel as on thingiverse
323
+#define ULTIPANEL  //the ultipanel as on thingiverse
315
 
324
 
316
 // The RepRapDiscount Smart Controller (white PCB)
325
 // The RepRapDiscount Smart Controller (white PCB)
317
 // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
326
 // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
327
  #define NEWPANEL
336
  #define NEWPANEL
328
 #endif 
337
 #endif 
329
 
338
 
330
-// Preheat Constants
331
-#define PLA_PREHEAT_HOTEND_TEMP 180 
332
-#define PLA_PREHEAT_HPB_TEMP 70
333
-#define PLA_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
339
+// I2C PANELS
334
 
340
 
335
-#define ABS_PREHEAT_HOTEND_TEMP 240
336
-#define ABS_PREHEAT_HPB_TEMP 100
337
-#define ABS_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
341
+#define LCD_I2C_SAINSMART_YWROBOT
342
+#ifdef LCD_I2C_SAINSMART_YWROBOT
343
+  // This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home )
344
+  // Make sure it is placed in the Arduino libraries directory.
345
+  #define LCD_I2C_TYPE_PCF8575
346
+  #define ULTIPANEL
347
+  #define NEWPANEL
348
+  #define LCD_I2C_ADDRESS 0x27   // I2C Address of the port expander
349
+#endif
338
 
350
 
351
+// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
352
+//#define LCD_I2C_PANELOLU2
353
+#ifdef LCD_I2C_PANELOLU2
354
+  // This uses the LiquidTWI2 library ( https://github.com/lincomatic/LiquidTWI2 ).
355
+  // Make sure it is placed in the Arduino libraries directory.
356
+  #define LCD_I2C_TYPE_MCP23017
357
+  #define ULTIPANEL
358
+  #define NEWPANEL
359
+  #define LCD_I2C_ADDRESS 0x20
360
+  #define LCD_HAS_I2C_BUZZ //comment out to disable buzzer on LCD
361
+  #define LCD_HAS_STATUS_INDICATORS  
362
+#endif
363
+
364
+// VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
365
+//#define LCD_I2C_VIKI
366
+#ifdef LCD_I2C_VIKI
367
+  // This uses the LiquidTWI2 library (https://github.com/lincomatic/LiquidTWI2).
368
+  // Make sure it is placed in the Arduino libraries directory.
369
+  #define LCD_I2C_TYPE_MCP23017
370
+  #define ULTIPANEL
371
+  #define NEWPANEL
372
+  #define LCD_I2C_ADDRESS 0x20
373
+  #define LCD_HAS_STATUS_INDICATORS  
374
+#endif
339
 
375
 
340
 #ifdef ULTIPANEL
376
 #ifdef ULTIPANEL
341
 //  #define NEWPANEL  //enable this if you have a click-encoder panel
377
 //  #define NEWPANEL  //enable this if you have a click-encoder panel
351
   #endif
387
   #endif
352
 #endif
388
 #endif
353
 
389
 
354
-//The LCD is attached via an I2C port expander.
355
-//#define LCD_I2C
356
-#ifdef LCD_I2C
357
-  // Port Expander Type - 0=PCF8574 sainsmart/ywrobot
358
-  #define LCD_I2C_TYPE 0
359
-  // I2C Address of the port expander
360
-  #define LCD_I2C_ADDRESS 0x27
361
-#endif
362
-
363
 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
390
 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
364
 //#define FAST_PWM_FAN
391
 //#define FAST_PWM_FAN
365
 
392
 

+ 15
- 1
Marlin/Marlin.pde View File

36
 #ifdef ULTRA_LCD
36
 #ifdef ULTRA_LCD
37
   #ifdef LCD_I2C
37
   #ifdef LCD_I2C
38
     #include <Wire.h>
38
     #include <Wire.h>
39
-    #include <LiquidCrystal_I2C.h>
39
+    #if defined(LCD_I2C_TYPE_PCF8575)
40
+      #include <LiquidCrystal_I2C.h>
41
+    #elif defined(LCD_I2C_TYPE_MCP23017)
42
+      #ifdef PANELOLU2
43
+        #undef PANELOLU2
44
+        #include <LiquidTWI2.h>
45
+        #ifndef PANELOLU2
46
+          #error You must uncomment #define PANELOLU2 in LiquidTWI2.h for LiquidTWI2.cpp to compile correctly
47
+        #endif
48
+      #else
49
+        #include <LiquidTWI2.h>
50
+      #endif
51
+    #else
52
+      #error Unknown I2C LCD type    
53
+    #endif
40
   #else
54
   #else
41
     #include <LiquidCrystal.h>
55
     #include <LiquidCrystal.h>
42
   #endif
56
   #endif

+ 11
- 11
Marlin/Marlin_main.cpp View File

124
 // M500 - stores paramters in EEPROM
124
 // M500 - stores paramters in EEPROM
125
 // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
125
 // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
126
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
126
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
127
-// M503 - print the current settings (from memory not from eeprom)
127
+// M503 - print the current settings (from memory not from eeprom)
128
 // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
128
 // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
129
 // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
129
 // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
130
 // M907 - Set digital trimpot motor current using axis codes.
130
 // M907 - Set digital trimpot motor current using axis codes.
853
       previous_millis_cmd = millis();
853
       previous_millis_cmd = millis();
854
       if (codenum > 0){
854
       if (codenum > 0){
855
         codenum += millis();  // keep track of when we started waiting
855
         codenum += millis();  // keep track of when we started waiting
856
-        while(millis()  < codenum && !LCD_CLICKED){
856
+        while(millis()  < codenum && !lcd_clicked()){
857
           manage_heater();
857
           manage_heater();
858
           manage_inactivity();
858
           manage_inactivity();
859
           lcd_update();
859
           lcd_update();
860
         }
860
         }
861
       }else{
861
       }else{
862
-        while(!LCD_CLICKED){
862
+        while(!lcd_clicked()){
863
           manage_heater();
863
           manage_heater();
864
           manage_inactivity();
864
           manage_inactivity();
865
           lcd_update();
865
           lcd_update();
1499
     {
1499
     {
1500
         Config_PrintSettings();
1500
         Config_PrintSettings();
1501
     }
1501
     }
1502
-    break;
1503
-    #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
1504
-    case 540:
1505
-    {
1506
-        if(code_seen('S')) abort_on_endstop_hit = code_value() > 0;
1507
-    }
1508
-    break;
1502
+    break;
1503
+    #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
1504
+    case 540:
1505
+    {
1506
+        if(code_seen('S')) abort_on_endstop_hit = code_value() > 0;
1507
+    }
1508
+    break;
1509
     #endif
1509
     #endif
1510
     #ifdef FILAMENTCHANGEENABLE
1510
     #ifdef FILAMENTCHANGEENABLE
1511
     case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
1511
     case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
1592
         delay(100);
1592
         delay(100);
1593
         LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
1593
         LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
1594
         uint8_t cnt=0;
1594
         uint8_t cnt=0;
1595
-        while(!LCD_CLICKED){
1595
+        while(!lcd_clicked()){
1596
           cnt++;
1596
           cnt++;
1597
           manage_heater();
1597
           manage_heater();
1598
           manage_inactivity();
1598
           manage_inactivity();

+ 6
- 99
Marlin/pins.h View File

290
     #define BTN_EN1 11
290
     #define BTN_EN1 11
291
     #define BTN_EN2 10
291
     #define BTN_EN2 10
292
     #define BTN_ENC 12  //the click
292
     #define BTN_ENC 12  //the click
293
-    
294
-    #define BLEN_C 2
295
-    #define BLEN_B 1
296
-    #define BLEN_A 0
297
-
298
-    #define encrot0 0
299
-    #define encrot1 2
300
-    #define encrot2 3
301
-    #define encrot3 1
302
 #endif
293
 #endif
303
 
294
 
304
 /****************************************************************************************
295
 /****************************************************************************************
384
 #ifdef ULTRA_LCD
375
 #ifdef ULTRA_LCD
385
 
376
 
386
   #ifdef NEWPANEL
377
   #ifdef NEWPANEL
387
-     //encoder rotation values
388
-    #define encrot0 0
389
-    #define encrot1 2
390
-    #define encrot2 3
391
-    #define encrot3 1
392
-
393
-    #define BLEN_A 0
394
-    #define BLEN_B 1
395
-    #define BLEN_C 2
396
-
397
     #define LCD_PINS_RS 16 
378
     #define LCD_PINS_RS 16 
398
     #define LCD_PINS_ENABLE 17
379
     #define LCD_PINS_ENABLE 17
399
     #define LCD_PINS_D4 23
380
     #define LCD_PINS_D4 23
427
 
408
 
428
   #else //old style panel with shift register
409
   #else //old style panel with shift register
429
     //arduino pin witch triggers an piezzo beeper
410
     //arduino pin witch triggers an piezzo beeper
430
-    #define BEEPER 33		No Beeper added
411
+    #define BEEPER 33		// No Beeper added 
431
 
412
 
432
     //buttons are attached to a shift register
413
     //buttons are attached to a shift register
433
 	// Not wired this yet
414
 	// Not wired this yet
442
     #define LCD_PINS_D5 25 
423
     #define LCD_PINS_D5 25 
443
     #define LCD_PINS_D6 27
424
     #define LCD_PINS_D6 27
444
     #define LCD_PINS_D7 29
425
     #define LCD_PINS_D7 29
445
-    
446
-    //encoder rotation values
447
-    #define encrot0 0
448
-    #define encrot1 2
449
-    #define encrot2 3
450
-    #define encrot3 1
451
-
452
-    
453
-    //bits in the shift register that carry the buttons for:
454
-    // left up center down right red
455
-    #define BL_LE 7
456
-    #define BL_UP 6
457
-    #define BL_MI 5
458
-    #define BL_DW 4
459
-    #define BL_RI 3
460
-    #define BL_ST 2
461
-
462
-    #define BLEN_B 1
463
-    #define BLEN_A 0
464
   #endif 
426
   #endif 
465
 #endif //ULTRA_LCD
427
 #endif //ULTRA_LCD
466
 
428
 
735
      #define LCD_PINS_D7        27
697
      #define LCD_PINS_D7        27
736
      
698
      
737
      //The encoder and click button
699
      //The encoder and click button
738
-     #define BTN_EN1 11  //must be a hardware interrupt pin
739
-     #define BTN_EN2 10 //must be hardware interrupt pin
700
+     #define BTN_EN1 11  
701
+     #define BTN_EN2 10 
740
      #define BTN_ENC 16  //the switch
702
      #define BTN_ENC 16  //the switch
741
      //not connected to a pin
703
      //not connected to a pin
742
-     #define SDCARDDETECT -1
743
-     
744
-     //from the same bit in the RAMPS Newpanel define
745
-     //encoder rotation values
746
-     #define encrot0 0
747
-     #define encrot1 2
748
-     #define encrot2 3
749
-     #define encrot3 1
750
-     
751
-     #define BLEN_C 2
752
-     #define BLEN_B 1
753
-     #define BLEN_A 0
754
-     
704
+     #define SDCARDDETECT -1    
705
+    
755
    #endif //Newpanel
706
    #endif //Newpanel
756
  #endif //Ultipanel
707
  #endif //Ultipanel
757
  
708
  
834
     #define BTN_EN2 42
785
     #define BTN_EN2 42
835
     #define BTN_ENC 19  //the click
786
     #define BTN_ENC 19  //the click
836
     
787
     
837
-    #define BLEN_C 2
838
-    #define BLEN_B 1
839
-    #define BLEN_A 0
840
-    
841
     #define SDCARDDETECT 38
788
     #define SDCARDDETECT 38
842
     
789
     
843
-      //encoder rotation values
844
-    #define encrot0 0
845
-    #define encrot1 2
846
-    #define encrot2 3
847
-    #define encrot3 1
848
   #else //old style panel with shift register
790
   #else //old style panel with shift register
849
     //arduino pin witch triggers an piezzo beeper
791
     //arduino pin witch triggers an piezzo beeper
850
     #define BEEPER 18
792
     #define BEEPER 18
861
     #define LCD_PINS_D5 21 
803
     #define LCD_PINS_D5 21 
862
     #define LCD_PINS_D6 20
804
     #define LCD_PINS_D6 20
863
     #define LCD_PINS_D7 19
805
     #define LCD_PINS_D7 19
864
-    
865
-    //encoder rotation values
866
-    #ifndef ULTIMAKERCONTROLLER
867
-     #define encrot0 0
868
-     #define encrot1 2
869
-     #define encrot2 3
870
-     #define encrot3 1
871
-    #else
872
-     #define encrot0 0
873
-     #define encrot1 1
874
-     #define encrot2 3
875
-     #define encrot3 2
876
-
877
-    #endif
878
-
806
+  
879
     #define SDCARDDETECT -1
807
     #define SDCARDDETECT -1
880
-    //bits in the shift register that carry the buttons for:
881
-    // left up center down right red
882
-    #define BL_LE 7
883
-    #define BL_UP 6
884
-    #define BL_MI 5
885
-    #define BL_DW 4
886
-    #define BL_RI 3
887
-    #define BL_ST 2
888
-
889
-    #define BLEN_B 1
890
-    #define BLEN_A 0
891
   #endif 
808
   #endif 
892
 #endif //ULTRA_LCD
809
 #endif //ULTRA_LCD
893
 
810
 
1455
     #define BTN_EN2 64
1372
     #define BTN_EN2 64
1456
     #define BTN_ENC 43  //the click
1373
     #define BTN_ENC 43  //the click
1457
     
1374
     
1458
-    #define BLEN_C 2
1459
-    #define BLEN_B 1
1460
-    #define BLEN_A 0
1461
-    
1462
     #define SDCARDDETECT -1		// Ramps does not use this port
1375
     #define SDCARDDETECT -1		// Ramps does not use this port
1463
-    
1464
-      //encoder rotation values
1465
-    #define encrot0 0
1466
-    #define encrot1 2
1467
-    #define encrot2 3
1468
-    #define encrot3 1
1469
 #endif
1376
 #endif
1470
 #endif //ULTRA_LCD
1377
 #endif //ULTRA_LCD
1471
 
1378
 

+ 9
- 0
Marlin/ultralcd.cpp View File

714
     
714
     
715
     lcd_buttons_update();
715
     lcd_buttons_update();
716
     
716
     
717
+    #ifdef LCD_HAS_EXTRA_BUTTONS
718
+    buttons |= lcd_read_extra_buttons(); // buttons which take too long to read in interrupt context
719
+    #endif
720
+    
717
     #if (SDCARDDETECT > -1)
721
     #if (SDCARDDETECT > -1)
718
     if((IS_SD_INSERTED != lcd_oldcardstatus))
722
     if((IS_SD_INSERTED != lcd_oldcardstatus))
719
     {
723
     {
858
 }
862
 }
859
 #endif//ULTIPANEL
863
 #endif//ULTIPANEL
860
 
864
 
865
+bool lcd_clicked() 
866
+{ 
867
+  return LCD_CLICKED;
868
+}
869
+
861
 /********************************/
870
 /********************************/
862
 /** Float conversion utilities **/
871
 /** Float conversion utilities **/
863
 /********************************/
872
 /********************************/

+ 1
- 20
Marlin/ultralcd.h View File

20
 
20
 
21
   #ifdef ULTIPANEL
21
   #ifdef ULTIPANEL
22
   void lcd_buttons_update();
22
   void lcd_buttons_update();
23
-  extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
24
   #else
23
   #else
25
   FORCE_INLINE void lcd_buttons_update() {}
24
   FORCE_INLINE void lcd_buttons_update() {}
26
   #endif
25
   #endif
33
   extern int absPreheatHPBTemp;
32
   extern int absPreheatHPBTemp;
34
   extern int absPreheatFanSpeed;
33
   extern int absPreheatFanSpeed;
35
     
34
     
36
-  #ifdef NEWPANEL
37
-    #define EN_C (1<<BLEN_C)
38
-    #define EN_B (1<<BLEN_B)
39
-    #define EN_A (1<<BLEN_A)
40
-
41
-    #define LCD_CLICKED (buttons&EN_C)
42
-  #else
43
-    //atomatic, do not change
44
-    #define B_LE (1<<BL_LE)
45
-    #define B_UP (1<<BL_UP)
46
-    #define B_MI (1<<BL_MI)
47
-    #define B_DW (1<<BL_DW)
48
-    #define B_RI (1<<BL_RI)
49
-    #define B_ST (1<<BL_ST)
50
-    #define EN_B (1<<BLEN_B)
51
-    #define EN_A (1<<BLEN_A)
52
-    
53
-    #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
54
-  #endif//NEWPANEL
35
+  bool lcd_clicked();
55
 
36
 
56
 #else //no lcd
37
 #else //no lcd
57
   FORCE_INLINE void lcd_update() {}
38
   FORCE_INLINE void lcd_update() {}

+ 679
- 526
Marlin/ultralcd_implementation_hitachi_HD44780.h
File diff suppressed because it is too large
View File


Loading…
Cancel
Save