2.8" TFT -> extended character set

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
afcec
 
Posts: 5
Joined: Thu Apr 09, 2015 4:48 am

2.8" TFT -> extended character set

Post by afcec »

Hi,

I´ve been using your 2.8" TFT shield with an Arduino Leonardo successfully both with bmp images and text. However I need to use some specific spanish characters as 'ñ', 'á', '¿', etc...

¿How can I update the font to include those characters?

Thanks!
Last edited by afcec on Wed Apr 15, 2015 11:50 am, edited 1 time in total.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: 2.8" TFT -> special characters

Post by adafruit_support_mike »

Those are in the extended (higher than 127) values of the GFX library's built-in font. '¿' is character 168, for instance.

It will probably be easiest to write a quick program that prints all 256 character values in a 16x16 grid. The row and column values will give you the hex value for each character you want.

User avatar
afcec
 
Posts: 5
Joined: Thu Apr 09, 2015 4:48 am

Re: 2.8" TFT -> extended character set

Post by afcec »

Thank you, I finally ended up hacking glcdfont.c. I just changed the pattern values for those characters I am not using. It´s the easiest way and helps you save program memory...

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: 2.8" TFT -> extended character set

Post by adafruit_support_mike »

If it works, it works. ;-)

Happy hacking!

User avatar
DiegoLiedo
 
Posts: 1
Joined: Mon May 11, 2015 3:58 pm

Re: 2.8" TFT -> extended character set

Post by DiegoLiedo »

Thank you, I finally ended up hacking glcdfont.c. I just changed the pattern values for those characters I am not using. It´s the easiest way and helps you save program memory...
Hi afcec, could you point me on how to hack those characters, I'm in need for exactly the same spanish characters.
Thank you .

User avatar
afcec
 
Posts: 5
Joined: Thu Apr 09, 2015 4:48 am

Re: 2.8" TFT -> extended character set

Post by afcec »

DiegoLiedo wrote:
Thank you, I finally ended up hacking glcdfont.c. I just changed the pattern values for those characters I am not using. It´s the easiest way and helps you save program memory...
Hi afcec, could you point me on how to hack those characters, I'm in need for exactly the same spanish characters.
Thank you .
Hi,

find glcdfont.c which is one of the files included with the library "Adafruit-GFX-Library-master". If you open the file with any editor, you´ll see 255 rows consisting of 5 bytes each. Those 5 bytes represent the pattern for a single character in your font, according to the following criteria:

http://www.instructables.com/id/LED-Sco ... -/?lang=es

In my case, apart from [A-Z], [a-z], [0-9] I just needed [á,é,BANNED,ó,BANNED] so I took these steps:

1. Locate in the file 5 unused characters (in my case 5 characters with code lower than 127) and modify the patterns (yes, draw them) to meet your requirements. For that purpose I used Excel to draw the patterns. It´s a weird at the begginning but you´ll get used to doing it at the second attemp.
2. Once you are finished, remove from glcdfont.c all those characters with ASCII code higher than 127 in case you are not using them. You can save hundreds of precious bytes in program memory.

Give it a try and tell me in case you need any assistance.
Last edited by afcec on Wed May 13, 2015 2:52 am, edited 2 times in total.

User avatar
asteroid
 
Posts: 300
Joined: Tue Oct 22, 2013 9:10 pm

Re: 2.8" TFT -> extended character set

Post by asteroid »

For those interested, the following code will print glcdfont character set:

Code: Select all

/*
  Displays glcdfont character set on 2.8" TFT TouchShield
*/

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Adafruit_STMPE610.h>

// Default values for Adafruit shield v2.
#define STMPE_CS 8
#define TFT_DC 9
#define TFT_CS 10

Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

// Assign human-readable names to some common 16-bit color values:
#define	BLACK   0x0000
#define	BLUE    0x001F
#define	RED     0xF800
#define	GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

 // Rotations 0,2 = portrait  : 0->USB=right,upper : 2->USB=left,lower
 // Rotations 1,3 = landscape : 1->USB=left,upper  : 3->USB=right,lower
 const int rotation = 1; //(0->3)

 void CharacterGrid()
 {
  int row = 16;
  int col = 16;
  int left, top;   
  int l = 10;
  int t = 0;
  int w = 19;
  int h = 15;
  int hgap = 0;
  int vgap = 0;
  int id = 0;
  for(int j = 0; j < row; j++){
    for (int i = 0; i < col; i++){
       left = l + i*(w + vgap);
       top = t + j*(h + hgap);
       tft.drawChar(left, top, id, WHITE, BLUE, 2);
       id++;
      }
   }
 }
 
 void setup() 
 {
  tft.begin();
  tft.setRotation(rotation);
  tft.fillScreen(BLUE);
  CharacterGrid();
 }

 void loop()
 {
 }


Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”