<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Displaying text on LCD in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523136#M5772</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Pacman on Sun Oct 27 07:13:54 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Alex.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You have an error in the line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;if (letterArray&lt;I&gt; &amp;lt;&amp;lt; bitCounter != 0)&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe you meant something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;if (letterArray&lt;I&gt; &amp;amp; (1 &amp;lt;&amp;lt; bitCounter))&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...Apart from that... setPixel is slow, you might want to find a faster way one day.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But for now, let's see if we can simplify and optimize the code slightly:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#define CHR_SIZE (16 * 16 / 8)

/* Your letterArray appears to be 8-bit, but we'll use 16-bit pointers instead */
const uint16_t*s;/* 'source' - this is where we read from */
const uint16_t*e;/* 'end' marker */
uint16_tbits;/* but we can do things faster using 16 bits */
uint16_ti;

s = (uint16_t *) &amp;amp;letterArray[(c - 32) * CHR_SIZE];/* point s to the beginning of the array */
e = &amp;amp;s[16];/* point e to the end #!# */
while(s &amp;lt; e)/* while we haven't reached the end */
{
bits = *s++;/* read the bits */
i = 16;/* using our 16 bits, draw a line of 16 pixels */
while(i--)
{
color = (bits &amp;amp; 0x8000) ? black : white;/* pick a color */
setPixel(x++, y, color);/* set pixel and advance x */
bits = bits &amp;lt;&amp;lt; 1;/* shift out the bit we've just read */
}
x -= 16;/* go back to original x-position */
y++;/* next line */
}
y -= 16;/* restore y position */
x += 16;/* advance x position, ready for next character */
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(update: bug fixed in the line marked with #!#, now subtracting 32 from c. Comments also lining up)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I do here, is that I use a pointer instead of an array. I read it into a register once, then keep using the register (which is technically either same speed or faster than keeping reading from memory; general rule, works for all CPUs).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I try to do as little as possible in the loop. Remember: CPUs like doing as little work as they can. &lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We don't need a counter for 's'. As the pointer is advanced anyway, we can just use this for comparing against an end-marker. The result is the same, but we'll save a few clock cycles incrementing a counter in parallel with updating the pointer, plus we'll save a register as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 18:02:09 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T18:02:09Z</dc:date>
    <item>
      <title>Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523131#M5767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by amlwwalker on Sat Oct 26 10:42:30 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to get a font to display on my LCD.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I understand how it works in principle.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You get a font, then run it through an application to convert it to an array, for instance this is the letter A:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;0x04, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
0x04, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
0x0A, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # #&amp;nbsp;&amp;nbsp;&amp;nbsp; 
0x0A, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # #&amp;nbsp;&amp;nbsp;&amp;nbsp; 
0x11, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; 
0x11, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; 
0x20, 0x80, //&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp; 
0x3F, 0x80, //&amp;nbsp;&amp;nbsp; #######&amp;nbsp; 
0x40, 0x40, //&amp;nbsp; #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # 
0x40, 0x40, //&amp;nbsp; #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # 
0x80, 0x20, // #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
0x80, 0x20, // #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
0x00, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
0x00, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
0x00, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
0x00, 0x00, //&amp;nbsp; &lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;its 11 pixels wide and 32 long.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to display it on my LCD which I can already display bitmaps on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So my approach was&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;while(i &amp;lt; arrayLength) {
while (bitCounter &amp;lt; 8) {
if (letterArray&lt;I&gt; &amp;lt;&amp;lt; bitCounter != 0) {
setPixel(x, y, black);
else
setPixel(x,y, white);
bitCounter++;
x++;
if (x &amp;lt; 15) {
x = 0;
y++;
}
bitCounter = 0;
i++
}
}&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However I just get a load of black pixels not resembling the letter A.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone done this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Its also really slow to load.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I dont want to use a whole library for it, its quite a small thing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tahnks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Alex&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523131#M5767</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523132#M5768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Pacman on Sat Oct 26 18:37:30 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: amlwwalker&lt;/STRONG&gt;&lt;BR /&gt;Its also really slow to load.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't go into details in my first reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What you need to do, is to get rid of setPixel.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These are the basics for drawing in any kind of screen-buffer, big or small; it's always the same. You can optimize and get faster results, depending on how you do things, but that might make this example over-complicated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Outside all loops, you should get the address of the screen's top/right corner.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let's call the screen's top/right corner address 'screenBase'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this code, I assume that the size of a pixel (color depth) is 16 bits. It may be 8-bit, which is also easy, it may be 24-bit, which is a little more messy, unless it uses all 32 bits. If it's some other depth, such as 3, 5 or 13, it could be necessary to do some bit-shifting instead.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If on the other hand, the bit-depth is divisible by 8, it should be fairly straight-forward to make a real fast routine for outputting the graphics. I'll assume it's 16 bits per pixel in this example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The tricky part is to figure out what the screen address is. Try looking at the source-code for setPixel, if you have it. It might be the same address that the lpc177x_8x_lcd driver is using, though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Take a look at lpc177x_8x.c (especially LCD_SetImage, LCD_PutPixel and LCD_SetBaseAddress)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LCD_SetImage tells you something about the width,height, screen address, bit size, etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;linesize should be the size of a line in pixels (eg. same as lcd_hsize from LCD_SetImage).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;#define CHR_WIDTH 16
#define CHR_HEIGHT 16
#define CHR_SIZE ((CHR_WIDTH * CHR_HEIGHT + 7) &amp;gt;&amp;gt; 3)

uint16_t *screenBase;
uint16_t *d;
uint32_t skip;
uint32_t linesize;
const uint16_t pe;

screenBase = ????;/* try and find this in the setPixel code */
linesize = ????;/* perhaps 1024 * ((BIT_DEPTH + 7) &amp;gt;&amp;gt; 3) */

d = screenBase + y * linesize * CHR_HEIGHT + x * CHR_WIDTH;
/* have a look at LCD_GetWordOffset and LCD_GetBitOffset; you should be able to find the screen address and the pixel address then. */
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead of updating x and y in the loop, you now only update 'd'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
skip = linesize * CHR_HEIGHT - CHR_WIDTH;
while(s &amp;lt; e)
{
bits = *s++;
pe = &amp;amp;d[16];
while(d &amp;lt; pe)
{
*d++ = (bits &amp;amp; 0x8000) ? black : white;
}
d += skip;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Remember to check boundaries before you start, so you don't write to any addresses outside the screen area, and also consider checking for left and right side.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why is setPixel so slow ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-It has to figure out where the screen is every time, check X and Y against the screen boundaries, convert the X and Y positions into an offset and add the offset to the base address, then it has to figure out the pixel size (8, 16, 24 or any other strange depth), before it actually writes the pixel.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523132#M5768</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523133#M5769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Pacman on Sat Oct 26 18:46:07 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;...And it's possible that the 'A' will be displayed upside down.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If that's the case, you'll need either to read the array from the bottom (eg. while(s &amp;lt; e) { bits = *--e; ... }) or write it from bottom to top (subtracting skip instead of adding it; remember to add linesize * CHR_HEIGHT before the loop then).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try and see which way is the fastest.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523133#M5769</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523134#M5770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by amlwwalker on Sun Oct 27 01:29:05 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Wow Pacman, thanks for your advice, this is great.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried your first suggestion and I cant get anything to appear, so I thought I would get &lt;/SPAN&gt;&lt;I&gt;something&lt;/I&gt;&lt;SPAN&gt; working and then perhaps you could advise me on making it more efficient as your code is clearly a little cleverer than mine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't yet looked at making "draw pixel" more efficient yet, although I want to get onto that as I can just see a line being drawn across the screen. Its quite fast at drawing bmp images out of an array though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, to shed some more light:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My font array looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;
const uint16_t newFont[] =
{
// @0 'A' (7 pixels wide)
0x10, //&amp;nbsp;&amp;nbsp;&amp;nbsp; #
0x10, //&amp;nbsp;&amp;nbsp;&amp;nbsp; #
0x28, //&amp;nbsp;&amp;nbsp; # #
0x28, //&amp;nbsp;&amp;nbsp; # #
0x44, //&amp;nbsp; #&amp;nbsp;&amp;nbsp; #
0x44, //&amp;nbsp; #&amp;nbsp;&amp;nbsp; #
0x7C, //&amp;nbsp; #####
0x82, // #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
0x82, // #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
0x00, //
0x00, //

// @11 'B' (5 pixels wide)
0xF0, // ####
0x88, // #&amp;nbsp;&amp;nbsp; #
0x88, // #&amp;nbsp;&amp;nbsp; #
0x88, // #&amp;nbsp;&amp;nbsp; #
0xF0, // ####
0x88, // #&amp;nbsp;&amp;nbsp; #
0x88, // #&amp;nbsp;&amp;nbsp; #
0x88, // #&amp;nbsp;&amp;nbsp; #
0xF0, // ####
0x00, //
0x00, //
//etc etc for rest of alphabet
};
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I then have an array that holds the position of the start of each letter and the width in pixels for each letter - to get spacing right, although for now I am just using an arbitrary 10 pixels until I get it right:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;
const uint16_t descriptors[][2] =
{
{7, 0}, // A
{5, 11}, // B
{6, 22}, // C
//etc etc for the rest of the alphabet
};
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;Then the code I have managed to get working (almost....) is this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;
void color_lcd_print_char(char text, int color, unsigned char x, unsigned char y)
{

if((text &amp;gt; 31)&amp;amp;&amp;amp;(text &amp;lt; 127))
{
unsigned char current_x = x;
unsigned char current_y = y;
char current_byte;
char i, pos;
uint16_t startAt = descriptors[text - 65][1];
uint16_t endAt = descriptors[text - 64][1];
for(i = 0; i &amp;lt; endAt; i++)
{
current_byte = newFont[startAt + i];
for(pos = 0; pos &amp;lt; 8; pos++)
{
if(((current_byte&amp;gt;&amp;gt;pos) &amp;amp; 0x01)==0x01)
{
GLCD_SetPixel_16bpp(current_x,current_y, Black);
}
current_x++;
}
current_x=x;
current_y++;
}
}
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Its sort of an amagamation of what you were doing and some first principles. As you can see there's no clever pointer stuff going on...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I try yours I get nothing on the screen. When I use mine I get the letters, but they are mirrored also it seems to plot them in a grid, and then goes a bit nuts at the end...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In fact I also wrote this function for strings:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;
void color_lcd_print_string(char * text, char length, int color, unsigned char x, unsigned char y)
{
char i = 0;
while((text&lt;I&gt; != '\0')&amp;amp;&amp;amp;(i&amp;lt;length))
{
color_lcd_print_char(text&lt;I&gt;, color, x+i*10, y);
i++;
}
}
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;so if I pass that a string:&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;
color_lcd_print_string("ABCabc", 6, Black, 10, 10);
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; I get the picture attached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Side question, I am not sure I am storing the arrays in flash, I think they are possibly being stored in ram. On an 8 bit AVR I could use the Progmem keyword to store them in flash, is there an equivelent on ARM?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With regards to setPixel function, this is what its currently doing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;
__inline void GLCD_SetPixel_16bpp(uint16_t Xpos, uint16_t Ypos, uint16_t color) {
volatile uint16_t *pLCDbuf = (uint16_t *) LCD_VRAM_BASE_ADDR; /* LCD buffer start address */

pLCDbuf[Ypos * GLCD_X_SIZE + Xpos] = color;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523134#M5770</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523135#M5771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by amlwwalker on Sun Oct 27 02:29:51 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;So I've got my version working now, its not as elegant as yours but it now looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
void color_lcd_print_char(char text, int color, unsigned char x, unsigned char y)
{

if((text &amp;gt; 31)&amp;amp;&amp;amp;(text &amp;lt; 127))
{
unsigned char current_x = x;
unsigned char current_y = y;
char current_byte;
char i, pos;
uint16_t startAt = descriptors[text - 63][1];
uint16_t endAt = descriptors[text - 62][1];

char string[256];
&amp;nbsp; sprintf(string, "text: %c, text: %d, startAt: %d, endAt: %d\n", text, text, startAt, endAt);
&amp;nbsp; UARTPuts_(LPC_UART0, string);
while (startAt &amp;lt; endAt)
{
current_byte = newFont[startAt];
pos = 8;
while (pos--)
{
if(((current_byte&amp;gt;&amp;gt;pos) &amp;amp; 0x01)==0x01)
{
GLCD_SetPixel_16bpp(current_x,current_y, Black);
}
current_x++;
}
current_x=x;
current_y++;
startAt++;
}
}
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523135#M5771</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523136#M5772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Pacman on Sun Oct 27 07:13:54 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Alex.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You have an error in the line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;if (letterArray&lt;I&gt; &amp;lt;&amp;lt; bitCounter != 0)&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe you meant something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;if (letterArray&lt;I&gt; &amp;amp; (1 &amp;lt;&amp;lt; bitCounter))&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...Apart from that... setPixel is slow, you might want to find a faster way one day.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But for now, let's see if we can simplify and optimize the code slightly:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#define CHR_SIZE (16 * 16 / 8)

/* Your letterArray appears to be 8-bit, but we'll use 16-bit pointers instead */
const uint16_t*s;/* 'source' - this is where we read from */
const uint16_t*e;/* 'end' marker */
uint16_tbits;/* but we can do things faster using 16 bits */
uint16_ti;

s = (uint16_t *) &amp;amp;letterArray[(c - 32) * CHR_SIZE];/* point s to the beginning of the array */
e = &amp;amp;s[16];/* point e to the end #!# */
while(s &amp;lt; e)/* while we haven't reached the end */
{
bits = *s++;/* read the bits */
i = 16;/* using our 16 bits, draw a line of 16 pixels */
while(i--)
{
color = (bits &amp;amp; 0x8000) ? black : white;/* pick a color */
setPixel(x++, y, color);/* set pixel and advance x */
bits = bits &amp;lt;&amp;lt; 1;/* shift out the bit we've just read */
}
x -= 16;/* go back to original x-position */
y++;/* next line */
}
y -= 16;/* restore y position */
x += 16;/* advance x position, ready for next character */
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(update: bug fixed in the line marked with #!#, now subtracting 32 from c. Comments also lining up)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I do here, is that I use a pointer instead of an array. I read it into a register once, then keep using the register (which is technically either same speed or faster than keeping reading from memory; general rule, works for all CPUs).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I try to do as little as possible in the loop. Remember: CPUs like doing as little work as they can. &lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We don't need a counter for 's'. As the pointer is advanced anyway, we can just use this for comparing against an end-marker. The result is the same, but we'll save a few clock cycles incrementing a counter in parallel with updating the pointer, plus we'll save a register as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523136#M5772</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523137#M5773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Pacman on Sun Oct 27 07:14:46 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;(I updated the first reply I wrote; fixed a bug and now I subtract 32 from c, to make it start at the &amp;lt;space&amp;gt; character).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523137#M5773</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523138#M5774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by amlwwalker on Sun Oct 27 08:10:30 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Pacman, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for getting back to me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I made your mask changes, however now it doesnt display the text!&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
mask = (1 &amp;lt;&amp;lt; 8);
while(mask)
{
if((current_byte &amp;amp; mask) != 0x00)
{
GLCD_SetPixel_16bpp(current_x, current_y, Black);
}
mask = mask &amp;gt;&amp;gt; 1;
current_x++;
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;I can see why however that should be more efficient. BTW I added int he != 0x00 on top of your suggestion as I thought that was what I was checking for, as yours is doing a "is true check" and that didnt work either.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Its almost bug free apart from that (i.e before I made the mask change), however for some reason I get some characters just not working&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to get bigger fonts working which use more than 8bits, but also 'W' in this font uses more than 16 bits:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
// @264 'W' (11 pixels wide)
0x00, 0x00, //
0x80, 0x20, // #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
0x80, 0x20, // #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
0x44, 0x40, //&amp;nbsp; #&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; #
0x44, 0x40, //&amp;nbsp; #&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; #
0x44, 0x40, //&amp;nbsp; #&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; #
0x2A, 0x80, //&amp;nbsp;&amp;nbsp; # # # #
0x2A, 0x80, //&amp;nbsp;&amp;nbsp; # # # #
0x11, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; #
0x11, 0x00, //&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; #
0x00, 0x00, //
0x00, 0x00, //
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;So I cant use uint8_t however I have swapped everything for a uint16_t so for this font I am wasting a bit yeah, but if I use bigger ones then I should be able to use the same function - is the only change so I can display this 'W' to make pos = 16 rather than 8, or mask &amp;gt;&amp;gt; 16.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I seem to have to keep text as a char, I cant change it for a uint16_t even though it is that really?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523138#M5774</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523139#M5775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MarcVonWindscooting on Sun Oct 27 12:56:21 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I did some display output recently. By I use those simple EA-DOG-modules (128x64px, 400uA power consumption).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do everything in the most &lt;/SPAN&gt;&lt;STRONG&gt;in&lt;/STRONG&gt;&lt;SPAN&gt;efficent way by starting with a frame buffer structure and pixel read/write operations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The frame buffer is simply a char array, but I defined bit-offsets for x and y. That way I can lay out the bits as rows or columns of pixels. This helps adapting the frame buffer to real devices.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on the frame buffer structure and read/write pixel I defined bitblt to copy one rectangular area to somewhere else (probably even a different frame buffer, with different pixel/memory mapping). Once I had bitblt, I defined fonts with that. And a font is nothing but a big (e.g. 256*width of character) image containing all characters plus a function that maps from character value (0..255) to the characters image position (and width) in the big image. That even allows variable width of the chars.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;One thing I should point out: everything works with signed integer 32bit coordinates and positioning outside a frame-buffers range is doesn't generate an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I did recently was wasting even more CPU power, by NOT using the display chips scrolling capabilities. I use a memory image (frame buffer) and provide a very fast SPI frame update. The SPI transfer is done mostly by hardware, so that doesn't cost too much. I have to confess, I was tempted by the idea of using 64bit shifts for scrolling the frame buffer up by n pixels, but that is the only optimization that does not perform pixel read/write 0:)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The cool news is: even on a LPC2136 at 12MHz such an approach is still feasible and frame rates of about 5Hz possible (besides running I2C LM73, PCA9555 (8buttons, 8LEDs), 2 digital potentiometers, 4 GPIO buttons, generating beeps). I want to add a 3-Phase PWM motor control, that already ran with the I2C-part and the digital potentiometers at 48MHz up to 60kHz sampling rate/PWM frequency.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I focussed on ease of programming and code size, not speed. And no regret so far.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(if you care, my GPL3 project 'mxli' (www.windscooting.com/softy/mxli.html , lib/c-any/gfxmono*) contains that code in the libraries).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;tl;dr&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Make sure, you don't optimize a part of your program, that doesn't need that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe, text output doesn't need to be that fast, because a human is supposed to understand that output. Humans are very slow in reading text, at least I am. The output of an under-clocked LPC21 overpowers my brain by a factor of 100 at least. I'm not a gamer, though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523139#M5775</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523140#M5776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Pacman on Sun Oct 27 20:52:08 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;mask should not be (1 &amp;lt;&amp;lt; 8), but rather (1 &amp;lt;&amp;lt; 7).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Woops!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Eg.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mask = (1 &amp;lt;&amp;lt; (8 - 1));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mask = (1 &amp;lt;&amp;lt; (16 - 1));&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-because if you have a byte and you shift 1 8 times to the left, you shift it out, and the byte becomes zero.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Same about a 16-bit int and 16 shifts. ;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523140#M5776</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying text on LCD</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523141#M5777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Pacman on Mon Oct 28 13:44:42 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;This is good. You now have a good working starting point, which you can improve on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One thing that is important, is that when you read the array, you should read it into the same type of variable as the array is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Your array is of type uint16_t, but if it only holds bytes, just change it into an uint8_t.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;current_byte is a 'char'; this is the one I'm talking about; make it into a uint16_t or a uint8_t, depending on what type newFont[] is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If all characters fit into an 8-bit array, you'll save a lot of bytes on changing it to uint8_t.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try optimizing it little by little.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First thing&amp;nbsp; you could do is to create a bitmask; declare 'mask' at the top...&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;uint8_t mask;&amp;nbsp; /* same type as current_byte */&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then switch pos=8 out with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;mask = (1 &amp;lt;&amp;lt; 7);&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Change your inner for-loop and the if:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;while(mask)
{
if(current_byte &amp;amp; mask)
{
GLCD_SetPixel_16bpp(current_x, current_y, Black);
}
mask = mask &amp;gt;&amp;gt; 1;
current_x++;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next up: In your descriptors, you have already the vertical starting position and ending position.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But you might want to add the character width in pixels too.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So if you make sure the character is "right-aligned" like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
...####.
...#...#
...#...#
...####.
...#...#
...#...#
...####.
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;not left-aligned like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
####....
#...#...
#...#...
####....
#...#...
#...#...
####....
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you can load mask this way...&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;mask = (1 &amp;lt;&amp;lt; cwidth);&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...where cwidth is a number between 0 and 7 (which you read from your descriptors)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And after the inner loop, you could do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;current_x -= cwidth;
current_y++;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally outside the outer loop:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;current_x += cwidth;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:02:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Displaying-text-on-LCD/m-p/523141#M5777</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:02:15Z</dc:date>
    </item>
  </channel>
</rss>

