2

I have a teensy4.1, with a 16 by 2 LCD screen, and an I2C LCD interface. I was trying to write a bunch of custom characters to an LCD screen, to flip some text.

my issue is that it works fine, but on only up to 8 custom characters. any more than that produces odd results. with a loop of 16, the first 8 characters are printed. should more than 8 characters be defined, only the last assigned are in use.

I commented out all but the first 8 custom characters, and iterates through them in a loop of 16 iterations. this loops over the start. -- I guess that works as I would expect. If I define more than 8 custom Characters, only the last 8 assigned will output.

Here is a picture of that in action: customChar limits to 8

here is my code:

#include <Adafruit_LiquidCrystal.h>
Adafruit_LiquidCrystal lcd(0);

//upside down char glyphs... default characters are 7x5 1 px w/space on the bottom
//these glyphs are 7x5 with space on the top 
byte uA[8] = {  B00000,  B10001,  B10001,  B10001,  B11111,  B10001,  B10001,  B01110};
byte uB[8] = {  B00000,  B01111,  B10001,  B10001,  B01111,  B10001,  B10001,  B01111};
byte uC[8] = {  B00000,  B01110,  B10001,  B00001,  B00001,  B00001,  B10001,  B01110};
byte uD[8] = {  B00000,  B00111,  B01001,  B10001,  B10001,  B10001,  B01001,  B00111};
byte uE[8] = {  B00000,  B11111,  B00001,  B00001,  B01111,  B00001,  B00001,  B11111};
byte uF[8] = {  B00000,  B00001,  B00001,  B00001,  B01111,  B00001,  B00001,  B11111};
byte uG[8] = {  B00000,  B11110,  B10001,  B10001,  B11101,  B00001,  B10001,  B01110};
byte uH[8] = {  B00000,  B10001,  B10001,  B10001,  B11111,  B10001,  B10001,  B10001};
byte uI[8] = {  B00000,  B01110,  B00100,  B00100,  B00100,  B00100,  B00100,  B01110};
byte uJ[8] = {  B00000,  B00110,  B01001,  B01000,  B01000,  B01000,  B01000,  B11100};
byte uK[8] = {  B00000,  B10001,  B01001,  B00101,  B00011,  B00101,  B01001,  B10001};
byte uL[8] = {  B00000,  B01111,  B00001,  B00001,  B00001,  B00001,  B00001,  B00001};
byte uM[8] = {  B00000,  B10001,  B10001,  B10001,  B10101,  B10101,  B11011,  B10001};
byte uN[8] = {  B00000,  B10001,  B10001,  B11001,  B10101,  B10011,  B10001,  B10001};
byte uO[8] = {  B00000,  B01110,  B10001,  B10001,  B10001,  B10001,  B10001,  B01110};
byte uP[8] = {  B00000,  B00001,  B00001,  B00001,  B01111,  B10001,  B10001,  B01111};
byte uQ[8] = {  B00000,  B10110,  B01001,  B10101,  B10001,  B10001,  B10001,  B01110};
byte uR[8] = {  B00000,  B10001,  B01001,  B00101,  B01111,  B10001,  B10001,  B01111};
byte uS[8] = {  B00000,  B01111,  B10000,  B10000,  B01110,  B00001,  B00001,  B11110};
byte uT[8] = {  B00000,  B00100,  B00100,  B00100,  B00100,  B00100,  B00100,  B11111};
byte uU[8] = {  B00000,  B01110,  B10001,  B10001,  B10001,  B10001,  B10001,  B10001};
byte uV[8] = {  B00000,  B00100,  B01010,  B10001,  B10001,  B10001,  B10001,  B10001};
byte uW[8] = {  B00000,  B01010,  B10101,  B10101,  B10101,  B10001,  B10001,  B10001};
byte uX[8] = {  B00000,  B10001,  B10001,  B01010,  B00100,  B01010,  B10001,  B10001};
byte uY[8] = {  B00000,  B00100,  B00100,  B00100,  B01010,  B10001,  B10001,  B10001};
byte uZ[8] = {  B00000,  B11111,  B00001,  B00010,  B00100,  B01000,  B10000,  B11111};
//pockets
byte cornerA[]={B11111,B10000,B10000,B10000,B10000,B10000,B10000,B10000};//top left
byte cornerB[]={B10000,B10000,B10000,B10000,B10000,B10000,B10000,B11111};//btm left
byte cornerC[]={B11111,B00001,B00001,B00001,B00001,B00001,B00001,B00001};//top right
byte cornerD[]={B00001,B00001,B00001,B00001,B00001,B00001,B00001,B11111};//btm right
void flip(char *text);
void setup() {
  Serial.begin(9600);
  lcd.begin(16,2); // 
  //flipped characters
lcd.createChar(0,uA);
lcd.createChar(1,uB);
lcd.createChar(2,uC);
lcd.createChar(3,uD);
lcd.createChar(4,uE);
lcd.createChar(5,uF);
lcd.createChar(6,uG);
lcd.createChar(7,uH);
lcd.createChar(8,uI);
lcd.createChar(9,uJ);
lcd.createChar(10,uK);
lcd.createChar(11,uL);
lcd.createChar(12,uM);
lcd.createChar(13,uN);
lcd.createChar(14,uO);
lcd.createChar(15,uP);
/*lcd.createChar(16,uQ);
lcd.createChar(17,uR);
lcd.createChar(18,uS);
lcd.createChar(19,uT);
lcd.createChar(20,uU);
lcd.createChar(21,uV);
lcd.createChar(22,uW);
lcd.createChar(23,uX);
lcd.createChar(24,uY);
lcd.createChar(25,uZ);
lcd.createChar(26,cornerA);
lcd.createChar(27,cornerB);
lcd.createChar(28,cornerC);
lcd.createChar(29,cornerD);
*/
  //ascii coversion prolly like n+66
  //setCursor be like: (column, row) 16 cols, 2 rows, both start at 0
lcd.setCursor(0,0);
  
  for (int i=0; i<16;i++){
  lcd.write(i); //prints ABCDEFGHABCDEFGH
  lcd.setCursor(i+1,0);
  delay (500);
  }
  lcd.setCursor(0,1);
  lcd.print("LIMIT 8 CHARS?");
}

void loop() {}

I would like to make more than 8 customChars, am I approaching this correctly? is there a limit somewhere I can change?

2
  • Note that some letters need not be flipped: HINOSXZ. For others, you could use lookalikes: MW, Pd, bp, dq... Apr 24 at 18:27
  • @EdgarBonet: And (depending on the character set in the particular device used) there may be other usable characters too. Most HD44780 displays have some katakana characters, so eg E may also be usable.
    – psmears
    Apr 25 at 10:54

1 Answer 1

6

These displays only allow up to 8 custom defined characters. The hardware just only has the character RAM for at most 8 characters. They will be mapped to char codes 0 to 7 and 8 to 15. The character code 8 always prints the same character as code 0, 9 as 1 and so on.

So no, there is no way to use more than 8 custom characters at once. Of course, you can change the characters dynamically, so that a certain location of the screen always shows a changing custom character icon.

2
  • 1
    Bloody hell, its in the datasheet. I tried modding the library first, and that did not work. cdn-shop.adafruit.com/datasheets/HD44780.pdf
    – j0h
    Apr 24 at 17:59
  • Yea, you can modify the library, but you can't modify the hardware...
    – PMF
    Apr 24 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.