408-754-4176 | info@reachtech.com

by Reach Technology, a Novanta Company
Support > Frequently Asked Questions > We need to use some special characters (i.e. space (20 hex) through z (7A hex) including punctuation to work). How do we make them work?

We need to use some special characters (i.e. space (20 hex) through z (7A hex) including punctuation to work). How do we make them work?

Here is an example of printing the special characters “, \, and % in ‘C’ strings using our API.

void demoSpecialChars(void)
{
char buf[120];

sprintf(buf,”f 24″); // set font size 24
sendToSerialPort(buf);
sprintf(buf,”s 0 1″); // set black on white
sendToSerialPort(buf);
sprintf(buf,”z”); // clear screen
sendToSerialPort(buf);

sprintf(buf,”t \”%s\”\r”,”Backslash: \\\\“); // backslash in string
sendToSerialPort(buf);
sendToSerialPort(“t \”\n\”\r”); // newline

// backslash as character
sprintf(buf,”t \”%s%c%c\”\r”,”Backslash: “,’\\’,’\\’);
sendToSerialPort(buf);
sendToSerialPort(“t \”\n\”\r”); // newline

sprintf(buf,”t \”%s\”\r”,”Percent: %”); // Percent
sendToSerialPort(buf);
sendToSerialPort(“t \”\n\”\r”); // newline

sprintf(buf,”t \”Percent: %%\”\r”); // Percent
sendToSerialPort(buf);
sendToSerialPort(“t \”\n\”\r”); // newline

// Quote (need 2 to get one for SLCD, and one more to allow ” in string)
sprintf(buf,”t \”%s\”\r”,”Quote: \\\“”);
sendToSerialPort(buf);
sendToSerialPort(“t \”\n\”\r”); // newline

// Quote as character
sprintf(buf,”t \”%s%c%c\”\r”,”Quote: “,’\\’,’“‘);
sendToSerialPort(buf);
sendToSerialPort(“t \”\n\”\r”); // newline
}

 
See Fonts for Embedded Touch Screen Development for a comprehensive explanation of working with fonts.