Go Down

Topic: Library for double height display on character LCDs (Read 6404 times) previous topic - next topic

gregington


I played with  some big font code that looks like it originated from the same code base you started with.
I did a few tweaks on some numbers, to make them look better (at least to my eyes).


Thanks Bill.

They look better to me too. I linked all the changes, especially for the 1 as it's now wider to match the other numbers. I've incorporated all of your changes to the library.

I think that your technique of keeping a thinner centre horizontal stroke can work for some of the letters too. I'll have a look at that in the next couple of days.

bperrybap

which LiquidTWI library are you guy using?
The ones I've seen are for the AdaFruit backpack that uses the MCP23008 i2c i/o expander
vs the PCF8574 expander that is used in most i2c to hd44780 backpacks out there.
The LiquidTWI libraries that I've seen
also assume a base address, which is why the address in the constructor is only the
lower 3  bits.
Code: [Select]

// now we set the GPIO expander's I/O direction to output since it's soldered to an LCD output.
Wire.beginTransmission(MCP23008_ADDRESS | _i2cAddr);


and MCP23008_ADDRESS is defined to be 0x20

While I've got an update for an i2c io class for fm's library that supports both PCF8574 and MCP23008
(It auto-detects which chip you have) it isnt yet available.

--- bill

Pedro147

#17
Oct 16, 2013, 01:43 am Last Edit: Oct 16, 2013, 01:51 am by Pedro147 Reason: 1


Code: [Select]

LiquidTWI::LiquidTWI(uint8_t i2cAddr) {
if (i2cAddr > 7) i2cAddr = 7;
_i2cAddr = i2cAddr; // transfer this function call's number into our internal class state
_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; // in case they forget to call begin() at least we have something
}


Greg, so I should only comment out the whole four code lines above should I?

Bill - I used this one Greg had a link to in his blog
https://github.com/Stephanie-Maks/Arduino-LiquidTWI






http://www.pedroduino.com

gregington

Pedro,

On Bill's prompting, I've had a closer look at the LiquidTWI library, and the original address of 0x27 should have worked. The address specified in the constructor is anded with 0x20. The code transforms any address higher than 7 to 7, which when anded with 0x20 gives you back the correct address of 0x27.

You could try using 7 as the address and let the LiquidTWI library add the base address. I suspect you'll find the same result, but it might be worth a try.

So I'm at a bit of a loss, but I'll have more thorough look when I'm back from work.


Pedro147

#19
Oct 16, 2013, 03:12 am Last Edit: Oct 16, 2013, 07:08 am by Pedro147 Reason: 1
I will try that after work Greg and let you know how I go. If not just let me know if you would like me to try any other methods etc.
Pedro

Edit - I set it at 0x07  but still no go
http://www.pedroduino.com

bperrybap

Pedro,
Which i2c expander chip is on your backpack? Does it have a MCP23008?
The reason that I ask, is that while it is used on the AdaFruit backpack,
there are very few other i2c hd44780 backpacks that use it.
The more common i2c expander chip used is the PCF8574 which will not work with
that LiquidTWI library.

--- bill

Pedro147

You are testing my failing eyesight now Bill  XD It has the PCF8574
http://www.pedroduino.com

gregington

Thanks for your efforts Pedro. Looks like it won't work for your hardware.

I'll have a look at the new LiquidCrystal library as a basis for the BigCrystal library when I get a bit more time (possibly on the weekend). That seems like it supports the widest range of hardware.

Pedro147

No worries Greg. If you want me to test any other developments just let me know
http://www.pedroduino.com

Qbert

#24
May 14, 2014, 03:48 pm Last Edit: May 14, 2014, 03:58 pm by Qbert Reason: 1
Hi, please, help!

I installed both New LiquidCrystal and BigCrystal library but font looks different from what appears in the picture of your first post! What's wrong with my font?



gregington

Hi Qbert,

Thanks for trying out BigCrystal. It's late over here and I'm about to go to bed, so I'll try to have a look tomorrow. If not, it will be a little while as my third child will be born on Friday, so I expect I'll have my hands full for a few days. I will have a look at it soon though.

gregington

Hi Qbert,

I can't reproduce your issue, but from your photo, it looks like either setting or displaying custom characters on your LCD is not working as expected. I used the following code to try to match your photo.

Code: [Select]

#include <BigCrystal.h>
#include <LiquidCrystal.h>

// Set up according to your LCD pins
LiquidCrystal lcd(22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);
BigCrystal bigCrystal(&lcd);

void setup() {
  bigCrystal.begin(20, 4);
 
  bigCrystal.printBig("ABCDE", 0, 0);
  bigCrystal.printBig("01234", 0, 2);
}

void loop() {
}


For example, if you look at the A character for example, the character in the top left should be a solid block with the top left corner taken away. This is mapped to custom character 0x00 in the code but the custom character for 0x01 is being displayed. The custom character mappings are in the BF_fontShapes[] array in BigFont.c

From your screen shot, I can observe the following mappings.











Expected CharacterDisplayed Character
0x000x01
0x010x01
0x02???
0x030x03
0x040x04
0x050x05
0x060x07
0x070x07


What is especially puzzling that the mapping for 0x02 which should be a solid block except for the top left hand corner is appearing as a character that is not mapped in the BigCrystal library. In your photo, it appears as the bottom right character of the 'B' character, a solid block with the top-right and bottom-left corners missing. I don't create this glyph anywhere.

I can think of two possibilities:

  • Your LCD has different behaviour when programming custom characters.

  • Some other part of your code is setting custom characters on your LCD. There are only 8 custom characters available on the LCD. If BigCrystal sets up its custom characters first, then some other code redefines some of those custom characters, this will produce the results you're experiencing.



Can you try the following (if you haven't already):

  • Try running the example sketch 'AllCharacters.ino'. Check to see if the characters look correct.

  • Try running my code above (with the LCD pins changed to match your hardware).

  • If you're using other libraries in your code, try commenting out everything else that uses the LCD to see if other parts of the code are redefining the custom characters.



Can you also let me know where you obtained your LCD, and if you have it, post a link to the data sheet so I can check if custom character programming is different.

Qbert


DH1MP

Hi there,

thnx alot for your hard work on developing the BigCrystal-library!
I have a 20x4 LCD blue-white from Keyestudio with a LCM1602 I2C module with an PCF8574T chip on it and got it working with the NewLiquidCrystal-Library with this slightly modified code from the example "HelloWorld_i2c":

Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>


//LiquidCrystal_I2C lcd(0x27);  // Set the LCD I2C address
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // New LiquidCrystal

// Creat a set of new characters
const uint8_t charBitmap[][8] = {
   { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
   { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
   { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
   { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
   { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
   { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
   { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
   { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
   
};

void setup()
{
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

// Switch on the backlight

lcd.backlight();
delay(500);

lcd.begin(20,4);               // initialize the lcd

for ( int i = 0; i < charBitmapSize; i++ )
{
  lcd.createChar ( i, (uint8_t *)charBitmap[i] );
}

lcd.home ();                   // go home
lcd.print("Hello, ARDUINO "); 
lcd.setCursor ( 0, 1 );        // go to the next line
lcd.print (" FORUM - fm   ");

delay ( 1000 );
lcd.noBacklight();
lcd.clear();
delay(2000);
lcd.backlight();
}

void loop()
{
   lcd.home ();
   // Do a little animation by writing to the same location
   for ( int i = 0; i < 2; i++ )
   {
      for ( int j = 0; j < 16; j++ )
      {
         lcd.print (char(random(7)));
      }
      lcd.setCursor ( 0, 1 );
   }
   delay (200);
}


There are at the end bouncing balls on the first two lines of the LCD. I hope that was intended...
I attached a screenshot of the result "NewLiquidCrystal-Example".


After modifiying your example above to match my I2C-settings to:

Code: [Select]
#include <LiquidCrystal_I2C.h>
#include <BigCrystal.h>

// Set up according to your LCD pins
//LiquidCrystal_I2C lcd(0x27);  // Set the LCD I2C address

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // New LiquidCrystal
BigCrystal bigCrystal(&lcd);

void setup() {
  bigCrystal.begin(20, 4);
 
  bigCrystal.printBig("ABCDE", 0, 0);
  bigCrystal.printBig("01234", 0, 2);
}

void loop() {
}


It seems that the custom characters are not properly loaded into the LCD-module.
Please see the attached picture "BigCrystal_Example"

I researched a lot in I-Net and forums, but can't get the solution for this.

Regards,
Markus

DH1MP

Hi there,

finally I got a workaround. After further investigation, I figured out, that I could circumvent the loading of the custom characters into the LCD-Module, which doesn't function properly in the BigCrystal.cpp, with a copy of the routine into my sketch. Therefore I used the demo-loadroutine from the "NewLiquidCrystal-Library". Despite that, I modified the charactertable for better readability and simplified loading routine  as follows:

Code: [Select]
#include <LiquidCrystal_I2C.h>
#include <BigCrystal.h>

const uint8_t charBitmap[][8] = {
//* LT[8] =
{B00111,  B01111,  B11111,  B11111,  B11111,  B11111,  B11111,  B11111},
//* UB[8] =
{B11111,  B11111,  B11111,  B00000,  B00000,  B00000,  B00000,  B00000},
//* RT[8] =
{B11100,  B11110,  B11111,  B11111,  B11111,  B11111,  B11111,  B11111},
//* LL[8] =
{B11111,  B11111,  B11111,  B11111,  B11111,  B11111,  B01111,  B00111},
//* LB[8] =
{B00000,  B00000,  B00000,  B00000,  B00000,  B11111,  B11111,  B11111},
//* LR[8] =
{B11111,  B11111,  B11111,  B11111, B11111,  B11111,  B11110,  B11100},
//* UMB[8] =
{B11111,  B11111,  B11111,  B00000,  B00000,  B00000,  B11111,  B11111},
//* LMB[8] =
{B11111,  B00000,  B00000,  B00000,  B00000,  B11111,  B11111,  B11111}
};

// Set up according to your LCD pins
//LiquidCrystal_I2C lcd(0x27);  // Set the LCD I2C address

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // New LiquidCrystal
BigCrystal bigCrystal(&lcd);

void setup() {
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

bigCrystal.begin(20, 4);

    for ( int i = 0; i < charBitmapSize; i++ ) {
lcd.createChar ( i, (uint8_t *)charBitmap[i] );
}

 
  bigCrystal.printBig("ABCDE", 0, 0);
  bigCrystal.printBig("01234", 0, 2);
}

void loop() {
}

Additionally, I commented out the call of "createCustomChars();" in:

Code: [Select]
#ifndef LiquidCrystal_h // New liquid crystal library
BigCrystal::BigCrystal(LCD *display) {
#else                   // Standard library
BigCrystal::BigCrystal(LiquidCrystal *display) {
#endif
  _display = display;
//  createCustomChars();
}


because it isn't needed anymore...

Hope, there is a better solution, but it works for me...

Regards,
Markus

Go Up