From 67710df9f3ac7921502f0444f4cc5621fbd645ce Mon Sep 17 00:00:00 2001 From: MendelMax Date: Tue, 26 Feb 2013 22:22:12 +0000 Subject: [PATCH] Made i2c mode wok with the hardware I am able to test (ywrobot / sainsmart i2c LCD 2004) Removed incorrect LiquidCrystal_I2C Library --- .../Arduino_0.xx/libraries/LiquidCrystal_I2C | 1 - .../Arduino_1.x.x/libraries/LiquidCrystal_I2C | 1 - Marlin/Configuration.h | 4 ++-- .../ultralcd_implementation_hitachi_HD44780.h | 24 +++++++++++++++---- 4 files changed, 22 insertions(+), 8 deletions(-) delete mode 160000 ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C delete mode 160000 ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C diff --git a/ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C b/ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C deleted file mode 160000 index bfb71c875..000000000 --- a/ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bfb71c87594ab904db9e41d9f57c6e2df89dc632 diff --git a/ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C b/ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C deleted file mode 160000 index bfb71c875..000000000 --- a/ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bfb71c87594ab904db9e41d9f57c6e2df89dc632 diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index bd0ac931f..d47b24cc4 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -354,10 +354,10 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th //The LCD is attached via an I2C port expander. //#define LCD_I2C #ifdef LCD_I2C - // Port Expander Type - 0=PCF8574 or 1=MCP23008 + // Port Expander Type - 0=PCF8574 sainsmart/ywrobot #define LCD_I2C_TYPE 0 // I2C Address of the port expander - #define LCD_I2C_ADDRESS 0x20 + #define LCD_I2C_ADDRESS 0x27 #endif // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index aa94b93ec..81195d21e 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -11,7 +11,19 @@ #define LCD_CLASS LiquidCrystalRus #else #ifdef LCD_I2C + #if LCD_I2C_TYPE = 0 + #define LCD_I2C_PIN_BL 3 + #define LCD_I2C_PIN_EN 2 + #define LCD_I2C_PIN_RW 1 + #define LCD_I2C_PIN_RS 0 + #define LCD_I2C_PIN_D4 4 + #define LCD_I2C_PIN_D5 5 + #define LCD_I2C_PIN_D6 6 + #define LCD_I2C_PIN_D7 7 + #endif + #include + #include #include #define LCD_CLASS LiquidCrystal_I2C #else @@ -32,7 +44,7 @@ #define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */ #ifdef LCD_I2C - LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT, LCD_I2C_TYPE); //address, columns, rows, type + LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); #else 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 #endif @@ -122,11 +134,15 @@ static void lcd_implementation_init() B00000, B00000 }; //thanks Sonny Mounicou + #ifdef LCD_I2C - lcd.init(); - #else - lcd.begin(LCD_WIDTH, LCD_HEIGHT); + #ifdef LCD_I2C_PIN_BL + lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); + lcd.setBacklight(HIGH); + #endif #endif + + lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp); lcd.createChar(LCD_STR_DEGREE[0], degree); lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);