Just got a cheap I2C 1602 LCD from Ebay.
Not too much trouble to get it going.
Used the I2C scanner sketch to check for the correct I2C address (confirmed 0x27)
Deleted the LiquidCrystal lib and replaced it with LiquidCrystal_V1.2.1.
Then finally had to include the pin definitions.
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin,BACKLIGHT_PIN,POSITIVE);
That did it.
Now playing around and having 2 questions related to defining custom characters.
Question #1:
Is it normal that during loading of the custom characters into the GCRAM of the display, these custom characters are kind of randomly thrown on the screen ?
I am specifically talking about the loading of the custom characters. (not displaying/using them, which works fine)
Question #2:
I have several different custom character sets that I need at different stages of my program.
I would like to use a function to upload the custom characters to the display and use a pointer to the particular array holding the characters for that set.
What is the proper syntax to use a 2 dimensional array in a function.
My custom character sets:
const uint8_t charBitmapRandom[][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 }
};
const uint8_t charBitmapBattery[][8] = {
{ 31, 0, 0, 0, 0, 0, 0, 31 }, // 0 + top and bottom stripe
{ 31, 16, 16, 16, 16, 16, 16, 31 }, // 1 + top and bottom stripe
{ 31, 24, 24, 24, 24, 24, 24, 31 }, // 2 + top and bottom stripe
{ 31, 28, 28, 28, 28, 28, 28, 31 }, // 3 + top and bottom stripe
{ 31, 30, 30, 30, 30, 30, 30, 31 }, // 4 + top and bottom stripe
// 5 = all dots on = char[255]
{ 1, 3, 3, 3, 3, 3, 3, 1 }, // Battery bottom
{ 16, 24, 30, 26, 26, 30, 24, 16 }, // Battery top
};
const uint8_t charBitmapBatteryLargeOutline[][8] = {
{ 31, 31, 0, 0, 0, 0, 0, 0 }, // 0 + top stripe
{ 0, 0, 0, 0, 0, 0, 31, 31 }, // 0 + bottom stripe
{ 1, 3, 3, 3, 3, 3, 3, 3 }, // Battery bottom upper
{ 3, 3, 3, 3, 3, 3, 3, 1 }, // Battery bottom lower
{ 16, 24, 24, 24, 30, 31, 27, 27 }, // Battery top upper
{ 27, 27, 31, 30, 24, 24, 24, 16 }, // Battery top lower
};
const uint8_t charBitmapBatteryLarge[][8] = {
{ 31, 16, 16, 16, 16, 16, 16, 16 }, // 1 + top stripe
{ 31, 24, 24, 24, 24, 24, 24, 24 }, // 2 + top stripe
{ 31, 28, 28, 28, 28, 28, 28, 28 }, // 3 + top stripe
{ 31, 30, 30, 30, 30, 30, 30, 30 }, // 4 + top stripe
{ 16, 16, 16, 16, 16, 16, 16, 31 }, // 1 + bottom stripe
{ 24, 24, 24, 24, 24, 24, 24, 31 }, // 2 + bottom stripe
{ 28, 28, 28, 28, 28, 28, 28, 31 }, // 3 + bottom stripe
{ 30, 30, 30, 30, 30, 30, 30, 31 }, // 4 + bottom stripe
// 5 = all dots on = char[255]
};
my function:
void LoadCustomCharacterSet(uint8_t charBitmap[][8]) {
int charBitmapSize = (sizeof(charBitmap) / sizeof (charBitmap[0]));
for ( int i = 0; i < charBitmapSize; i++ )
{
lcd.createChar ( i, (uint8_t *)charBitmap[i] );
}
}
calling the function:
LoadCustomCharacterSet(charBitmapRandom);
If I use this function I get error message:
LCD_I2C_test_all_reduced:117: error: invalid conversion from ‘const uint8_t ()[8]’ to ‘uint8_t ()[8]’
Using this code in the loop, without going through the function, works fine.
Sorry, I am not good at pointers, references, casts, etc..
Thanks in advance for any help