TFT Color LCD from Nuelectronics and TEXT?

Hello, i have used this forum until now only to read about my open questions. But now i have to ask for help.

I am working with a LCD Display together wit Arduino 328.

The Display is this one:
2.4" TFT Color LCD,touch screen sheild V1.2 for Arduino 168/328

Here the Shoppage:
The Shop where I ordered it is called Nuelectronics.com

The Display has as controller a ILI9325

What I want to do is using the display for sensor data and there iget problems with getting text on the screen…

There is demofile comming with the display and that is running fine.

I could also isolate the text demo part of the demo.
There are all the letters shown in a row … but ican simply not see
howto get a word or value send to the screen…

I have used now lots of hours but no chance to get it done allone.

Here is the code that is making now the font demo:

#include <f12x12.h>
#include <TFT_Font.h>
#include <TFT_Graphics.h>
#include <util/delay.h>
#include <stdlib.h>
#include “f15x22.h”
#include <stdlib.h>
#define TP_STABLE_COUNT 1

Graphics tft;

TFT_Font font;

void colormap();
void fontmap();
void bitmap();

#define MENU_FONT_COLOR WHITE
#define MENU_NORMAL_COLOR GREEN
#define MENU_HIGHLIGHT_COLOR RED

void setup()
{
tft.initialize(LCD_HORIZONTAL);
tft.ClearScreen(WHITE);
font.set_Font(f12x12);
}

void loop()

{
char i;
uint8_t row=0;

// draw font
tft.ClearScreen(WHITE);

tft.DrawRoundRect( 40, 70, 280, 230, 10, BLUE,1);

font.set_Font(f15x22);
font.set_Color(MENU_FONT_COLOR, MENU_NORMAL_COLOR,1);

font.set_Cursor( 50, 80);

for(i=font.Font_FirstChar; i<= font.Font_LastChar; i++)
{
if(font.CharWidth(i) !=0)
{
if( (font.CursorX + font.CharWidth(i)) > 270)
{
row++;
font.set_Cursor(50, 80+ (row* font.Font_Height + 2));
}

font.putChar(i);
}
}

font.set_Font(f12x12);

delay(5000);
}

I am a newbie with arduino and would really like tocome foreward,
maybe there is a way to make a programm like “HelloWorld!!”
for this type of Display… then I can crawl bymyself

You said that this demo works, and puts text on the screen.

This code:

     for(i=font.Font_FirstChar; i<= font.Font_LastChar; i++)
     {

loops through all the characters in the font, in order.

This code:

           if(font.CharWidth(i) !=0)
           {

verifies that the character has some real width (i.e. is a printable character).

This code:

                  if( (font.CursorX + font.CharWidth(i)) > 270)
                  {
                             row++;
                             font.set_Cursor(50, 80+ (row* font.Font_Height + 2));
                       }

positions the cursor after the preceding character, on the current line, if there is room. If not, it moves the cursor to the next row.

This code:

               font.putChar(i);

prints the character.

To print a different string of characters, you need to figure out the index (i) of the character that you want to print, and call the putChar() method for that index. A simple perusal of TFT_Font.h should reveal that.

Thank you for the fast answer…

did i get it right that i have to create a index and make there the definition about the letters?

now in the demofile is it a (i) called index

char i;

is making this index ??

and:

for(i=font.Font_FirstChar; i<= font.Font_LastChar; i++)

is putting life into the index.

Now i have a font that is called: f15x22.h made by H. Reddmann

looks like this:

struct FONT {
// common shared fields
uint16_t font_Size_in_Bytes_over_all_included_Size_it_self;
uint8_t font_Width_in_Pixel_for_fixed_drawing;
uint8_t font_Height_in_Pixel_for_all_Characters;
uint8_t font_Bits_per_Pixels;
// if MSB are set then font is a compressed font
uint8_t font_First_Char;
uint8_t font_Last_Char;
uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1];
// for each character the separate width in pixels,
// characters < 128 have an implicit virtual right empty row
// characters with font_Char_Widths == 0 are undefined

// if compressed font then additional fields
uint8_t font_Byte_Padding;
// each Char in the table are aligned in size to this value
uint8_t font_RLE_Table[3];
// Run Length Encoding Table for compression
uint8_t font_Char_Size_in_Bytes[font_Last_Char - font_First_Char +1];
// for each char the size in (bytes / font_Byte_Padding) are stored,
// this get us the table to seek to the right beginning of each char
// in the font_data.

// for compressed and uncompressed fonts
uint8_t font_data;
// bit field of all characters
}
*/

#include <inttypes.h>
#include <avr/pgmspace.h>

#ifndef f15x22_H
#define f15x22_H

#define f15x22_WIDTH 15
#define f15x22_HEIGHT 22

static uint8_t attribute ((progmem)) f15x22 = {
0x07, 0xDE, 0x0F, 0x16, 0x81, 0x18, 0x7E,
0x09, 0x0B, 0x0B, 0x0A, 0x08, 0x08, 0x08, 0x09, 0x07, 0x02, 0x05, 0x0B, 0x08, 0x0E, 0x0A, 0x02,
0x05, 0x05, 0x06, 0x0A, 0x02, 0x05, 0x02, 0x05, 0x08, 0x05, 0x08, 0x08, 0x09, 0x08, 0x08, 0x08,
0x08, 0x08, 0x02, 0x02, 0x08, 0x08, 0x08, 0x08, 0x0E, 0x0B, 0x09, 0x0A, 0x0A, 0x09, 0x09, 0x0B,
0x0A, 0x02, 0x07, 0x0A, 0x08, 0x0D, 0x0A, 0x0B, 0x09, 0x0B, 0x0B, 0x09, 0x0A, 0x0A, 0x0B, 0x0D,
0x0B, 0x0C, 0x0A, 0x04, 0x05, 0x04, 0x07, 0x0A, 0x03, 0x08, 0x08, 0x07, 0x08, 0x08, 0x06, 0x08,
0x08, 0x02, 0x03, 0x07, 0x02, 0x0C, 0x08, 0x08, 0x08, 0x08, 0x05, 0x07, 0x05, 0x08, 0x09, 0x0D,
0x08, 0x09, 0x08, 0x06, 0x02, 0x06, 0x08,
0x01, 0x02, 0x03, 0x07,
0x1B, 0x1A, 0x1A, 0x15, 0x18, 0x12, 0x12, 0x14, 0x09, 0x06, 0x09, 0x1B, 0x17, 0x27, 0x18, 0x04,
0x0B, 0x0B, 0x0D, 0x13, 0x05, 0x0A, 0x05, 0x09, 0x11, 0x0A, 0x14, 0x14, 0x14, 0x14, 0x14, 0x12,
0x16, 0x14, 0x05, 0x05, 0x12, 0x12, 0x12, 0x11, 0x27, 0x18, 0x17, 0x16, 0x14, 0x19, 0x13, 0x1B,
0x12, 0x04, 0x0E, 0x15, 0x0F, 0x18, 0x14, 0x16, 0x14, 0x18, 0x1A, 0x1A, 0x12, 0x12, 0x15, 0x18,
0x18, 0x17, 0x19, 0x09, 0x0A, 0x09, 0x0E, 0x10, 0x05, 0x16, 0x11, 0x10, 0x12, 0x15, 0x0B, 0x12,
0x10, 0x06, 0x07, 0x10, 0x04, 0x18, 0x11, 0x11, 0x11, 0x11, 0x0B, 0x14, 0x0B, 0x11, 0x11, 0x18,
0x15, 0x13, 0x18, 0x0E, 0x04, 0x0E, 0x0F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x9F, 0x5B, 0x37,
0xC1, 0x9B, 0xE0, 0x6E, 0x69, 0xCC, 0x49, 0x55, 0x3C, 0x79,

and some more HEX code…

is the hex code a letter?

Map each hex value to binary. 0x07 is 00000111 0xDE is 11011110 0x0F is 00001111 etc.

Two values make up each row of a letter (15 of 16 pixels are drawn), and 22 pairs make up each letter.

If you take a piece of graph paper, asnd color in each square where there is a one, you will see a letter take shape when you have used the first 44 values from the array.

Somewhere there should be a map that says that A starts at some position in the f15x22 array, and the B starts somewhere, etc.

ahhh there is light comming up… iam getting it slowly.

i have here the TFT_Font.h

/* TFT_Font.h – High-level graphic routines for TFT panel /
/
Author- xy /
/
Web - www.nuelectronics.com /
/
Version - v0.1 /
/
Date - 12/04/2010 */

// Font routinen, can be used as Icons

#ifndef TFT_FONT_H
#define TFT_FONT_H

#include <inttypes.h>
#include <avr/pgmspace.h>

#define FONT_HEADER_SIZE 7

class TFT_Font{

public:
uint8_t *Font_Ptr;
uint8_t Font_Width;
uint8_t Font_Height;
uint8_t Font_BitsPixel;
char Font_FirstChar;
char Font_LastChar;

uint8_t FixedFont;
uint16_t Font_color;
uint16_t BK_color;
uint16_t CursorX;
uint16_t CursorY;
uint8_t Char_space;
uint8_t Transparent; // Transparent =1 - don’t print background color, 0 - print background color

TFT_Font();
void set_Color(uint16_t fColor, uint16_t bColor, uint8_t Transparent);
void set_Cursor(uint16_t x, uint16_t y);
void set_Font(uint8_t *p_font); // select font
void putChar(char c);
uint8_t CharWidth(char c); // calculate char width
void putstr_P(char *str); //print ROM string
uint16_t str_Width_P(char *str); // calulate ROM string width
void putstr(char *str); // Print RAM string
void putnumber(long n); // Print integer value
uint16_t str_Width(char *str); // calculate RAM string width
};

#endif

and the TFT_Font.cpp

/* TFT_Font.cpp – Font routines for TFT panel /
/
Author- xy /
/
Web - www.nuelectronics.com /
/
Version - v0.1 /
/
Date - 12/04/2010 */

#include “TFT_Font.h”
#include “TFT_ILI9325.h”

TFT_Font::TFT_Font()
{
Font_color = WHITE;
BK_color = BLACK;
CursorX = 0;
CursorY = 0;
Transparent = 0; // Transparent =1 - don’t print background color, 0 - print background color
Char_space=2;
FixedFont = 0;
}

void TFT_Font::set_Color(uint16_t fColor, uint16_t bColor, uint8_t Transp)
{
this->Font_color = fColor;
this->BK_color = bColor;
this->Transparent = Transp;
}
void TFT_Font::set_Cursor(uint16_t x, uint16_t y)
{
CursorX = x;
CursorY = y;
}

void TFT_Font::set_Font(uint8_t *pfont)
{
this->Font_Ptr = pfont;
this->Font_Width = pgm_read_byte(Font_Ptr + 2);
this->Font_Height = pgm_read_byte(Font_Ptr + 3);
this->Font_BitsPixel = pgm_read_byte(Font_Ptr + 4);
this->Font_FirstChar = pgm_read_byte(Font_Ptr + 5);
this->Font_LastChar = pgm_read_byte(Font_Ptr + 6);
}

uint8_t TFT_Font::CharWidth(char c) // calculate char width
{
uint8_t len = 0;

if(!Font_Ptr)
return 0;

if(c< Font_FirstChar || c>Font_LastChar) return 0;

len = pgm_read_byte(Font_Ptr + FONT_HEADER_SIZE + c - Font_FirstChar);

return len;
}

void TFT_Font::putstr_P(char *str)
{
char c;
while( (c = pgm_read_byte(str++)))
putChar(c);
}

uint16_t TFT_Font::str_Width_P(char *str)
{
uint16_t len = 0;
char c;

while( (c = pgm_read_byte(str++)))
len += CharWidth(c) + Char_space;

return len;
}

void TFT_Font::putstr(char *str)
{
char c;
while( c = *(str++))
putChar(c);
}

uint16_t TFT_Font::str_Width(char *str)
{
uint16_t len = 0;
char c;

while( c= *(str++))
len += CharWidth(c) + Char_space;

return len;
}

void TFT_Font::putChar(char c)
{

uint8_t *ptr;
uint8_t bit_num;
uint8_t font_data;
uint8_t i, j;
uint16_t pix_x, pix_y;

uint8_t charwidth = CharWidth(c);
if (charwidth == 0) return;

uint8_t width = charwidth + Char_space;

// pre-set fontwidth for fixedfont
if ((FixedFont == 1) && (width<Font_Width)) {
width = Font_Width;
}

// line adjust
if (CursorX + (uint16_t)charwidth > LCD::GetWidth())
{
CursorY = CursorY + (unsigned int)Font_Height ;
if ((CursorY + Font_Height) > LCD::GetHeight())
CursorY = 0;
CursorX = 0;
}

uint32_t index = 0;

if (Font_BitsPixel & 0x80) //compressed font
{
uint8_t rle_table[4];
uint8_t padding, pixel_count = 0, bit_count=0,pixel_color;
uint8_t bitspixel;
uint16_t bits = 0;

bitspixel = Font_BitsPixel & 0x7f;
ptr = Font_Ptr + FONT_HEADER_SIZE + (Font_LastChar - Font_FirstChar +1);

padding = pgm_read_byte(ptr++);

// get run-length encoding table
rle_table[0] = 1;
rle_table[1] = pgm_read_byte(ptr++);
rle_table[2] = pgm_read_byte(ptr++);
rle_table[3] = pgm_read_byte(ptr++);

for (i = Font_FirstChar; i < c; i++) {
index += pgm_read_byte(ptr++);
}
index *= padding;
ptr = Font_Ptr + FONT_HEADER_SIZE + (Font_LastChar - Font_FirstChar +1)*2 + 4 + index;

for(i=0;i<charwidth; i++)
{
pix_x = (uint16_t)i + CursorX;

for(j=0; j<Font_Height; j++)
{
if(LCD::GetOrientation() == LCD_HORIZONTAL)
pix_y = (uint16_t)(Font_Height-j) + CursorY;
else
pix_y = (uint16_t)(j) + CursorY;

if(pixel_count==0)
{
if(bit_count<=8){
bits |= (pgm_read_byte(ptr++))<<bit_count;
bit_count +=8;
}
pixel_count = rle_table[bits & 0x3];
bits>>=2;
bit_count-=2;
pixel_color = bits & (0xff>>(8-bitspixel));
bits>>=bitspixel;
bit_count-= bitspixel;
}
if(pixel_color){
LCD::putPixel(pix_x, pix_y, Font_color);
}
else if(!Transparent){
LCD::putPixel(pix_x , pix_y, BK_color);
}
pixel_count–;
}
}

}
else // uncompressed font
{
// find font startpoint
ptr = Font_Ptr + FONT_HEADER_SIZE;
for (i = Font_FirstChar; i < c; i++) {
index += pgm_read_byte(ptr++);
}

index *= Font_Height * Font_BitsPixel;

bit_num = (uint8_t) (index & 0x7);
index = index>>3;
ptr = Font_Ptr + FONT_HEADER_SIZE + (Font_LastChar - Font_FirstChar +1) + index;

// walk through every pixel
font_data = pgm_read_byte(ptr++);

for(i=0;i<charwidth; i++)
{
pix_x = (uint16_t)i + CursorX;

for(j=0; j<Font_Height; j++)
{
if(LCD::GetOrientation() == LCD_HORIZONTAL)
pix_y = (uint16_t)(Font_Height-j) + CursorY;
else
pix_y = (uint16_t)(j) + CursorY;

if(font_data & (1<<bit_num)) //putpixel at fontcolor
LCD::putPixel(pix_x , pix_y, Font_color);
else
{ //putpixel at background color
if(!Transparent)
LCD::putPixel(pix_x , pix_y, BK_color);
}

bit_num++;

if(bit_num>7){
font_data = pgm_read_byte(ptr++); // new data
bit_num= 0;
}

}
}
}
// adjust cursor to next position
CursorX += (uint16_t)(charwidth + Char_space);
}

void TFT_Font::putnumber(long n){
char buf[10];
uint8_t i=0;

if(n==0)
putChar(‘0’);
else if(n < 0)
{
putChar(’-’);
n = -n;
}
while(n>0 && i <= 10){
buf[i++] = (n % 10)+‘0’; // n % base
n /= 10; // n/= base
}
for(; i >0; i–)
putChar(buf[i-1]);

}

As it looks for me the demois made so that the letters are not seperated by a table and just are sended out …right?

is there a way (for me) to make or import a table for the letters?

is there a way (for me) to make or import a table for the letters?

void TFT_Font::putstr(char *str)

This function sends a string to the LCD, one character at a time. It appears that the put_Char() method does the look-up of the position of the character in the font array, so put_Char() just takes the letter to print as an input, not the position of the letter in the array, like I first thought.

okay, now i lost directly the control ...

can you help me with an example?

#include <f12x12.h>
#include <TFT_Font.h>
#include <TFT_Graphics.h>
#include <util/delay.h>
#include <stdlib.h>
#include "f15x22.h"
#include <stdlib.h>
#define TP_STABLE_COUNT 1

Graphics tft;

TFT_Font font;

#define MENU_FONT_COLOR            WHITE
#define MENU_NORMAL_COLOR      GREEN
#define MENU_HIGHLIGHT_COLOR      RED

void setup()
{
     tft.initialize(LCD_HORIZONTAL);
     tft.ClearScreen(WHITE);
     font.set_Font(f12x12);
}

void loop()
{
     tft.ClearScreen(WHITE);
     
     font.set_Font(f15x22);
     font.set_Color(MENU_FONT_COLOR, MENU_NORMAL_COLOR,1);
     
     font.set_Cursor( 50, 80);
     font.putstr("Hey, there, with the hair colored yellow");
     delay(1000);
}

GREAT!! Works well... Thank you allot!!!

If i want now to use a a sensor value can i use the:

font.putstr("Hey, there, with the hair colored yellow");

as a

font.putstr(sensorValue, DEC);

?

I got that also to work... to get the sensor value I have used this function:

font.putnumber(sensorvalue);