Hi all,
first of all special thanks to Bill Perry for his hd44780 library.
I am working on a big project using 16x2 LCD displays with I2C backpacks and I was challenged with getting different backpacks. Sometimes they come with a PCF8574T, sometimes with PCF8574AT -> so by default their I2C addresses are either 0x27 or 0x3F.
As I have already produced quite some devices I am running into the issue to keep track with the used backpacks, when I want to update the firmware and I have to deal with 2 different versions. I want to avoid this to keep the update service as simple as possible.
Bill's library helped me to overcome the issue to care about the I2C addressing as it checks this automatically. So far so good.
But now I am confronted with a new challenge -> creating custom characters which I use to display the currently selected operation mode to the user.
In the "old" sketch I used F.Malpartida's LCD library and the creation of custom characters was no problem. I used the "byte" method to create the special characters with the help of an online character tool.
With Bill's library the display either stays blank or shows strange custom characters - depending on how I set the sketch up. Looking at examples I tried several approaches (e.g. converted the bytes to hex values) but could not succeed.
Attached pls find a little sketch, just focussing on the custom character creation and display.
The screen stays blank as soon the lcd.createChar lines are active, so there seems to be the issue.
Can somebody of the audience give me the right kick please.
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip
// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;
// custom characters for different modes
// little "1":
uint8_t btn1[8] = {0x02, 0x06, 0x02, 0x02, 0x07, 0x00, 0x00, 0x00};
// little "3":
uint8_t btn3[8] = {0x07, 0x01, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00};
void setup() {
// SetUp of LCD
lcd.begin(LCD_COLS, LCD_ROWS);
// create 2 custom characters
lcd.createChar(0, btn1);
lcd.createChar(1, btn3);
lcd.home();
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("Little ONE ");
lcd.setCursor(15, 0);
lcd.write((uint8_t)(0));
delay(1000);
lcd.setCursor(0, 0);
lcd.print("Little THREE ");
lcd.setCursor(15, 0);
lcd.write((uint8_t)(1));
delay(1000);
}