Skip to content

Commit

Permalink
Merge pull request johnrickman#8 from ortegafernando/master
Browse files Browse the repository at this point in the history
Now, createChar function can use PROGMEM charmap
  • Loading branch information
marcoschwartz committed Mar 20, 2016
2 parents 9a4e33e + 8f29f18 commit 4bb48bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions LiquidCrystal_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion LiquidCrystal_I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ class LiquidCrystal_I2C : public Print {
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);
Expand Down

0 comments on commit 4bb48bd

Please sign in to comment.