Преглед изворни кода

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 пре 11 година
родитељ
комит
1292d735ba
7 измењених фајлова са 765 додато и 674 уклоњено
  1. 44
    17
      Marlin/Configuration.h
  2. 15
    1
      Marlin/Marlin.pde
  3. 11
    11
      Marlin/Marlin_main.cpp
  4. 6
    99
      Marlin/pins.h
  5. 9
    0
      Marlin/ultralcd.cpp
  6. 1
    20
      Marlin/ultralcd.h
  7. 679
    526
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 44
- 17
Marlin/Configuration.h Прегледај датотеку

@@ -306,12 +306,21 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
306 306
 // please keep turned on if you can.
307 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 318
 //LCD and SD support
310 319
 //#define ULTRA_LCD  //general lcd support, also 16x2
311 320
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
312 321
 
313 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 325
 // The RepRapDiscount Smart Controller (white PCB)
317 326
 // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
@@ -327,15 +336,42 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
327 336
  #define NEWPANEL
328 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 376
 #ifdef ULTIPANEL
341 377
 //  #define NEWPANEL  //enable this if you have a click-encoder panel
@@ -351,15 +387,6 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
351 387
   #endif
352 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 390
 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
364 391
 //#define FAST_PWM_FAN
365 392
 

+ 15
- 1
Marlin/Marlin.pde Прегледај датотеку

@@ -36,7 +36,21 @@
36 36
 #ifdef ULTRA_LCD
37 37
   #ifdef LCD_I2C
38 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 54
   #else
41 55
     #include <LiquidCrystal.h>
42 56
   #endif

+ 11
- 11
Marlin/Marlin_main.cpp Прегледај датотеку

@@ -124,7 +124,7 @@
124 124
 // M500 - stores paramters in EEPROM
125 125
 // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
126 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 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 129
 // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
130 130
 // M907 - Set digital trimpot motor current using axis codes.
@@ -853,13 +853,13 @@ void process_commands()
853 853
       previous_millis_cmd = millis();
854 854
       if (codenum > 0){
855 855
         codenum += millis();  // keep track of when we started waiting
856
-        while(millis()  < codenum && !LCD_CLICKED){
856
+        while(millis()  < codenum && !lcd_clicked()){
857 857
           manage_heater();
858 858
           manage_inactivity();
859 859
           lcd_update();
860 860
         }
861 861
       }else{
862
-        while(!LCD_CLICKED){
862
+        while(!lcd_clicked()){
863 863
           manage_heater();
864 864
           manage_inactivity();
865 865
           lcd_update();
@@ -1499,13 +1499,13 @@ void process_commands()
1499 1499
     {
1500 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 1509
     #endif
1510 1510
     #ifdef FILAMENTCHANGEENABLE
1511 1511
     case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
@@ -1592,7 +1592,7 @@ void process_commands()
1592 1592
         delay(100);
1593 1593
         LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
1594 1594
         uint8_t cnt=0;
1595
-        while(!LCD_CLICKED){
1595
+        while(!lcd_clicked()){
1596 1596
           cnt++;
1597 1597
           manage_heater();
1598 1598
           manage_inactivity();

+ 6
- 99
Marlin/pins.h Прегледај датотеку

@@ -290,15 +290,6 @@
290 290
     #define BTN_EN1 11
291 291
     #define BTN_EN2 10
292 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 293
 #endif
303 294
 
304 295
 /****************************************************************************************
@@ -384,16 +375,6 @@
384 375
 #ifdef ULTRA_LCD
385 376
 
386 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 378
     #define LCD_PINS_RS 16 
398 379
     #define LCD_PINS_ENABLE 17
399 380
     #define LCD_PINS_D4 23
@@ -427,7 +408,7 @@
427 408
 
428 409
   #else //old style panel with shift register
429 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 413
     //buttons are attached to a shift register
433 414
 	// Not wired this yet
@@ -442,25 +423,6 @@
442 423
     #define LCD_PINS_D5 25 
443 424
     #define LCD_PINS_D6 27
444 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 426
   #endif 
465 427
 #endif //ULTRA_LCD
466 428
 
@@ -735,23 +697,12 @@
735 697
      #define LCD_PINS_D7        27
736 698
      
737 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 702
      #define BTN_ENC 16  //the switch
741 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 706
    #endif //Newpanel
756 707
  #endif //Ultipanel
757 708
  
@@ -834,17 +785,8 @@
834 785
     #define BTN_EN2 42
835 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 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 790
   #else //old style panel with shift register
849 791
     //arduino pin witch triggers an piezzo beeper
850 792
     #define BEEPER 18
@@ -861,33 +803,8 @@
861 803
     #define LCD_PINS_D5 21 
862 804
     #define LCD_PINS_D6 20
863 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 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 808
   #endif 
892 809
 #endif //ULTRA_LCD
893 810
 
@@ -1455,17 +1372,7 @@
1455 1372
     #define BTN_EN2 64
1456 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 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 1376
 #endif
1470 1377
 #endif //ULTRA_LCD
1471 1378
 

+ 9
- 0
Marlin/ultralcd.cpp Прегледај датотеку

@@ -714,6 +714,10 @@ void lcd_update()
714 714
     
715 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 721
     #if (SDCARDDETECT > -1)
718 722
     if((IS_SD_INSERTED != lcd_oldcardstatus))
719 723
     {
@@ -858,6 +862,11 @@ void lcd_buttons_update()
858 862
 }
859 863
 #endif//ULTIPANEL
860 864
 
865
+bool lcd_clicked() 
866
+{ 
867
+  return LCD_CLICKED;
868
+}
869
+
861 870
 /********************************/
862 871
 /** Float conversion utilities **/
863 872
 /********************************/

+ 1
- 20
Marlin/ultralcd.h Прегледај датотеку

@@ -20,7 +20,6 @@
20 20
 
21 21
   #ifdef ULTIPANEL
22 22
   void lcd_buttons_update();
23
-  extern volatile uint8_t buttons;  //the last checked buttons in a bit array.
24 23
   #else
25 24
   FORCE_INLINE void lcd_buttons_update() {}
26 25
   #endif
@@ -33,25 +32,7 @@
33 32
   extern int absPreheatHPBTemp;
34 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 37
 #else //no lcd
57 38
   FORCE_INLINE void lcd_update() {}

+ 679
- 526
Marlin/ultralcd_implementation_hitachi_HD44780.h
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


Loading…
Откажи
Сачувај