Browse Source

Added I2C port expander support to HD44780

Bob Clough 12 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
 //The LCD is attached via an I2C port expander.
354
 //The LCD is attached via an I2C port expander.
355
 //#define LCD_I2C
355
 //#define LCD_I2C
356
 #ifdef LCD_I2C
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
   // I2C Address of the port expander
359
   // I2C Address of the port expander
360
   #define LCD_I2C_ADDRESS 0x20
360
   #define LCD_I2C_ADDRESS 0x20
361
 #endif
361
 #endif

+ 20
- 6
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

7
 **/
7
 **/
8
 
8
 
9
 #if LANGUAGE_CHOICE == 6
9
 #if LANGUAGE_CHOICE == 6
10
-#include "LiquidCrystalRus.h"
11
-#define LCD_CLASS LiquidCrystalRus
10
+  #include "LiquidCrystalRus.h"
11
+  #define LCD_CLASS LiquidCrystalRus
12
 #else
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
 #endif
20
 #endif
16
 
21
 
17
 /* Custom characters defined in the first 8 characters of the LCD */
22
 /* Custom characters defined in the first 8 characters of the LCD */
25
 #define LCD_STR_CLOCK       "\x07"
30
 #define LCD_STR_CLOCK       "\x07"
26
 #define LCD_STR_ARROW_RIGHT "\x7E"  /* from the default character set */
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
 static void lcd_implementation_init()
39
 static void lcd_implementation_init()
30
 {
40
 {
31
     byte bedTemp[8] =
41
     byte bedTemp[8] =
111
         B00000,
121
         B00000,
112
         B00000
122
         B00000
113
     }; //thanks Sonny Mounicou
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
     lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
129
     lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
116
     lcd.createChar(LCD_STR_DEGREE[0], degree);
130
     lcd.createChar(LCD_STR_DEGREE[0], degree);
117
     lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
131
     lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);

Loading…
Cancel
Save