From 291335a76502cc7b8f60f9fd54c361475278b650 Mon Sep 17 00:00:00 2001 From: ortegafernando Date: Sun, 13 Mar 2016 22:01:48 +0100 Subject: [PATCH 1/3] Update LiquidCrystal_I2C.cpp --- LiquidCrystal_I2C.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/LiquidCrystal_I2C.cpp b/LiquidCrystal_I2C.cpp index 79f4389..1ab05d0 100644 --- a/LiquidCrystal_I2C.cpp +++ b/LiquidCrystal_I2C.cpp @@ -214,6 +214,15 @@ void LiquidCrystal_I2C::createChar(uint8_t location, uint8_t charmap[]) { } } +//createChar with PROGMEM input +void LiquidCrystal_I2C::createChar(uint8_t location, const char *charmap) { + location &= 0x7; // we only have 8 locations 0-7 + command(LCD_SETCGRAMADDR | (location << 3)); + for (int i=0; i<8; i++) { + write(pgm_read_byte_near(charmap++)); + } +} + // Turn the (optional) backlight off/on void LiquidCrystal_I2C::noBacklight(void) { _backlightval=LCD_NOBACKLIGHT; From 072347ee32f92d0f53b620dbdaa880a2e403c0fd Mon Sep 17 00:00:00 2001 From: ortegafernando Date: Sun, 13 Mar 2016 22:02:46 +0100 Subject: [PATCH 2/3] Now, createChar function can use PROGMEM charmap --- LiquidCrystal_I2C.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LiquidCrystal_I2C.cpp b/LiquidCrystal_I2C.cpp index 1ab05d0..44b7b05 100644 --- a/LiquidCrystal_I2C.cpp +++ b/LiquidCrystal_I2C.cpp @@ -219,7 +219,7 @@ void LiquidCrystal_I2C::createChar(uint8_t location, const char *charmap) { location &= 0x7; // we only have 8 locations 0-7 command(LCD_SETCGRAMADDR | (location << 3)); for (int i=0; i<8; i++) { - write(pgm_read_byte_near(charmap++)); + write(pgm_read_byte_near(charmap++)); } } From 8f29f18fd3d5fe0464d14161f789b7e73639ea1f Mon Sep 17 00:00:00 2001 From: ortegafernando Date: Sun, 13 Mar 2016 22:05:16 +0100 Subject: [PATCH 3/3] Now, createChar function can use PROGMEM charmap --- LiquidCrystal_I2C.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/LiquidCrystal_I2C.h b/LiquidCrystal_I2C.h index 201be33..c033f7f 100644 --- a/LiquidCrystal_I2C.h +++ b/LiquidCrystal_I2C.h @@ -77,8 +77,11 @@ public: void autoscroll(); void noAutoscroll(); void createChar(uint8_t, uint8_t[]); + void createChar(uint8_t location, const char *charmap); + // Example: const char bell[8] PROGMEM = {B00100,B01110,B01110,B01110,B11111,B00000,B00100,B00000}; + void setCursor(uint8_t, uint8_t); -#if defined(ARDUINO) && ARDUINO >= 100 +#if defined(ARDUINO) && ARDUINO >= 100 virtual size_t write(uint8_t); #else virtual void write(uint8_t);