Browse Source

Added I2C port expander support to HD44780

Bob Clough 11 years ago
parent
commit
2b567d1df5
2 changed files with 22 additions and 8 deletions
  1. 2
    2
      Marlin/Configuration.h
  2. 20
    6
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 2
- 2
Marlin/Configuration.h View File

@@ -354,8 +354,8 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
354 354
 //The LCD is attached via an I2C port expander.
355 355
 //#define LCD_I2C
356 356
 #ifdef LCD_I2C
357
-  // Port Expander Type - PCF8574 or MCP23008
358
-  #define LCD_I2C_TYPE PCF8574
357
+  // Port Expander Type - 0=PCF8574 or 1=MCP23008
358
+  #define LCD_I2C_TYPE 0
359 359
   // I2C Address of the port expander
360 360
   #define LCD_I2C_ADDRESS 0x20
361 361
 #endif

+ 20
- 6
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

@@ -7,11 +7,16 @@
7 7
 **/
8 8
 
9 9
 #if LANGUAGE_CHOICE == 6
10
-#include "LiquidCrystalRus.h"
11
-#define LCD_CLASS LiquidCrystalRus
10
+  #include "LiquidCrystalRus.h"
11
+  #define LCD_CLASS LiquidCrystalRus
12 12
 #else
13
-#include <LiquidCrystal.h>
14
-#define LCD_CLASS LiquidCrystal
13
+  #ifdef LCD_I2C
14
+    #include <LiquidCrystal_I2C.h>
15
+    #define LCD_CLASS LiquidCrystal_I2C
16
+  #else
17
+    #include <LiquidCrystal.h>
18
+    #define LCD_CLASS LiquidCrystal
19
+  #endif
15 20
 #endif
16 21
 
17 22
 /* Custom characters defined in the first 8 characters of the LCD */
@@ -25,7 +30,12 @@
25 30
 #define LCD_STR_CLOCK       "\x07"
26 31
 #define LCD_STR_ARROW_RIGHT "\x7E"  /* from the default character set */
27 32
 
28
-LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7);  //RS,Enable,D4,D5,D6,D7
33
+#ifdef LCD_I2C
34
+  LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT, LCD_I2C_TYPE);  //address, columns, rows, type
35
+#else
36
+  LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7);  //RS,Enable,D4,D5,D6,D7
37
+#endif
38
+
29 39
 static void lcd_implementation_init()
30 40
 {
31 41
     byte bedTemp[8] =
@@ -111,7 +121,11 @@ static void lcd_implementation_init()
111 121
         B00000,
112 122
         B00000
113 123
     }; //thanks Sonny Mounicou
114
-    lcd.begin(LCD_WIDTH, LCD_HEIGHT);
124
+    #ifdef LCD_I2C
125
+        lcd.init();
126
+    #else
127
+        lcd.begin(LCD_WIDTH, LCD_HEIGHT);
128
+    #endif
115 129
     lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
116 130
     lcd.createChar(LCD_STR_DEGREE[0], degree);
117 131
     lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);

Loading…
Cancel
Save