Hello!
I have been having issues writing strings from PROGMEM to a character LCD directly using the F() macro.
There are two issues I am having escaping characters:
-
On this lcd, you can program your own characters (up to 8 ). These characters are stored as characters 0 through 8, represented by hex 0x00 - 0x08. To print these characters, you just escape those hex codes in a string (eg. “Hi!\x00”). The problem I’m having here is that escaping \x00 (null) in a PROGMEM string acts as a terminator, ending the printed string prematurely!
–Edit: Solved, just use the duplicate characters stored on the LCD memory, 0x08-0x15! (still declare them as 0 through 8) -
Using an escaped character as the first character of a string (null or otherwise) results in some weirdness, including lost characters and left-shifting(see image, tried to print the string shown in code)
#include <LiquidCrystal.h>
#include <avr/pgmspace.h>
const byte chars[8][8]={
{
0b00000,
0b00100,
0b00110,
0b11111,
0b00110,
0b00100,
0b00000,
0b00000
},
{
0b00000,
0b00100,
0b01100,
0b11111,
0b01100,
0b00100,
0b00000,
0b00000
}
};
LiquidCrystal lcd(16,17,23,25,27,29);
long lastUpdate=0;
void setup(){
lcd.begin(20,4);
lcd.createChar(2,chars[0]);
lcd.createChar(1,chars[1]);
lcd.clear();
}
void loop(){
if(millis()-lastUpdate<500)return;
lastUpdate=millis();
lcd.setCursor(0,0);
lcd.print(F("\x01Back \x02Speed \x02Pattern \x02Setup "));
}
This code works, however, if you replace the first “\x01” with a space or other character…