Code C graphic LCD #5

/////////////////////////////////////////////////////////////////////////
// Purpose: Write text on a graphic LCD
// Inputs: (x,y) – The upper left coordinate of the first letter
// textptr – A pointer to an array of text to display
// size – The size of the text: 1 = 5×7, 2 = 10×14, …
// color – ON or OFF
/////////////////////////////////////////////////////////////////////////
#ifdef LARGE_LCD
void glcd_text57(int16 x, int16 y, char* textptr, int8 size, int1 color)
#else
void glcd_text57(int8 x, int8 y, char* textptr, int8 size, int1 color)
#endif
{
int i, j, k, l, m, n; // Loop counters
int1 Up,Lo;
BYTE pixelData[5]; // Stores character data
char Upper[12],Lower[2];

sprintf(Upper,”ÑÔÕÖ×çèéêëìÓ”);
sprintf(lower,”ØÙ”);

for(i=0; textptr[i] != ”; ++i, ++x) // Loop through the passed string
{
Up=0;Lo=0;
if(textptr[i] < ‘S’) // Checks if the letter is in the first text array
memcpy(pixelData, TEXT[textptr[i]-‘ ‘], 5);
else if(textptr[i] <= ‘~’) // Check if the letter is in the second array
memcpy(pixelData, TEXT2[textptr[i]-‘S’], 5);
else if(textptr[i] < ‘&Iuml;’) // Checks if the letter is in the first text array
memcpy(pixelData, TEXT3[textptr[i]-0xA0], 5); // 0xA0 = Space in thaifron
else if(textptr[i] <= ‘&Ugrave;’) // Check if the letter is in the second array
memcpy(pixelData, TEXT4[textptr[i]-‘&Iuml;’], 5);
else if(textptr[i] <=’&igrave;’)
memcpy(pixelData, TEXT5[textptr[i]-‘&agrave;’], 5); // Default to space
else
memcpy(pixelData, TEXT[0], 5);

if(textptr[i] > 0xA0)
{
for(n=0;n<12;++n)
{
if(textptr[i]==Upper[n]){Up=1;x-=6;break;} // Revers x 5 step
}
for(n=0;n<2;++n)
{
if(textptr[i]==Lower[n]){Lo=1;x-=6;break;} // Revers x 5 step
}
}

if(x+5*size >= GLCD_WIDTH) // Performs character wrapping
{
x = 0; // Set x at far left position
y += 7*size + 1; // Set y at next position down
}
for(j=0; j<5; ++j, x+=size) // Loop through character byte data
{
if(Up) //Test Upper case
{
for(k=0; k<7*size; ++k) // Loop through the vertical pixels
{
if(bit_test(pixelData[j], k)) // Check if the pixel should be set
{
for(l=0; l<size; ++l) // The next two loops change the
{ // character’s size
for(m=0; m<size; ++m)
{ //-3
glcd_pixel(x+m, ((y+k*size+l)-3), color); // Draws the pixel
}
}
}
}
}
else if(Lo) //Test Lower case
{
for(k=0; k<7*size; ++k) // Loop through the vertical pixels
{
if(bit_test(pixelData[j], k)) // Check if the pixel should be set
{
for(l=0; l<size; ++l) // The next two loops change the
{ // character’s size
for(m=0; m<size; ++m)
{ //+7
glcd_pixel(x+m, ((y+k*size+l)+7), color); // Draws the pixel
}
}
}
}
}
else
{
for(k=0; k<7*size; ++k) // Loop through the vertical pixels
{
if(bit_test(pixelData[j], k)) // Check if the pixel should be set
{
for(l=0; l<size; ++l) // The next two loops change the
{ // character’s size
for(m=0; m<size; ++m)
{
glcd_pixel(x+m, y+k*size+l, color); // Draws the pixel
}
}
}
}
}

}
if(size>1)++x;
}
}

Programming Click Now

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s

%d bloggers like this: