Pages: [1]   Go Down
Author Topic: Any Idea how to add custom characters (LCD lib) to a string?  (Read 514 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 157
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I specified a custom character as described on http://arduino.cc/en/Reference/LiquidCrystalCreateChar

If I like to mix "normal" character output with custom characters I use this workaround atm:

Code:
lcd.print("this before ");
lcd.write(3);
lcd.print(" this after the custom char");

I have to break the statement in three (or more) parts to add custom characters.

Is there any way to inculde this character in a single string, something like:

char myStringA[ ] = "this before [hmm, what to put here?? for the custom char] this after the custom char";
or
String myStringB = String("this before ") + [hmm, what here?, the custom char] + String(" this after the custom char");
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 625
Posts: 34106
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Use the backslash directive:-
\xhh    Character with hexadecimal value hh

More at:-
http://en.wikipedia.org/wiki/C_syntax#Backslash_escapes
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 157
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, this works!! Thanks a lot, it makes my sketch much easier!
Logged

Pages: [1]   Go Up
Jump to: