Yes, there are several inappropriate TextColor() and TextSize()
I have no idea what the program is supposed to do. Increment buttons seem to decrement. OK button does not seem to function.
As I suggested earlier. Please get it functional with 5x7 System font. Use size = 1. Then it should be easy to see what colours, fonts or sizes will be appropriate for the Text in the Release.
It seems to respond to non-button images. I suggest that you make buttons look obvious. e.g. rounded. and show when they are pressed.
Woo-hoo. You had mapped the Touch from BOT to TOP instead of TOP to BOT. Hence none of the buttons made sense.
pixel_x = map(p.x, TS_LEFT, TS_RT, 0, tft.width()); //.kbv makes sense to me
pixel_y = map(p.y, TS_TOP, TS_BOT, 0, tft.height()); //.kbv changed from BOT, TOP
Get the functionality correct.
Then we can change to some more attractive fonts. (and colours)
Using escapes in labels is a one-off.
Anything with lots of Danish text would be easier with UTF-8 encoded strings.
The pic is from a test of other charset, where I use FreeMonoBold9pt7b, FreeMonoBold12pt7b, FreeMonoBold18pt7b and FreeArial12full. In the top the filename is written.
I forget some of the menus when packing the files and I deleted a routine, but don't all the call to it. Apologize.
The setup:
const int XP = 8, XM = A2, YP = A3, YM = 9; //ID=0x9341 m. Elegoo 2.8"
const int TS_LEFT = 907, TS_RT = 111, TS_TOP = 902, TS_BOT = 79;
is correct for my shield.
When I make this setup in 'buttom_multible.ino' (and changed TOP/BOT) the program work exelent!
In the attachment I has added the missing menus.
Not more for now, other things has to be done!
Kurt
I has tryed some other tft-shild from mcufriend, and they all use:
const int XP = 6, XM = A2, YP = A1, YM = 7; as you say, so my shield from Elegoo is special!
I have tryed FreeArial12full and I like it, but would like also to get it in a bold version. And maybe also in fontsize 9.
Is it possible in your program to make it to reference to upper left corner as normal for GFX?
And I would like to have an arrowUp and arrowDown.
I suppose, that you have a program to make the charsets, is it a free program?
There are many variations for the Touch pins. And even more for the directions.
Adafruit provide C source code for fontconvert. Fine if you have Linux.
Painful for Windows.
I believe that has the fontconvert.exe available online.
Kris has a tutorial video
I make other fonts with an Arduino sketch.
David.
I just used Kris's video to make the Bold9full font. Untested.
There is a bit of faffing about with changing names etc. And Notepad++ saves in Unifont and not regular ascii. (Please check the format)
In an ideal world someone would amend the current web-based converter accept first and last character arguments. It can default to 32, 126 but let you make a Number or Full font.
Edit. When you generate a 12pt Font from the Arial Bold TTF font, you get the Euro symbol at 128. You get blanks for characters 128-160 in 9pt even though it is generated from the same TTF.
I have changed the baseline in my edition of charset FreeArial_Bold12full, so the baseline now is top left and I has 'handcoded' the two last chars ($FE and $FF) to show ArrowUp and ArrowDown.
In order to avoid mistake I would like to give the file another name, but it give error when compiling.
I have seen the tutorial video from #45, but it is difficult for mee to understand the method.
Anybody knowing a written tutorial anywhere?
It displayed char(254) and char(255) as arrows.
You will need to use escapes to display in regular Adafruit_GFX print() statements.
e.g. I appended this to the bottom of setup()
I realy want to rename, but I can't compile without error.
In the top of the file 'FreeArial_Bold12full_TL' I wrote:
// generate FreeFont from LCD Vision font
const uint8_t FreeArial_Bold12full_TLBitmaps[] PROGMEM = {.....
Later nearly 70% down I wrote:
// strip blank pixels: top = 0, bot = 0, left = 0, rt = 1, adv = 18, desc = 3
const GFXglyph FreeArial_Bold12full_TLBitmapsGlyphs[] PROGMEM = {
{ 0, 0, 0, 9, 8, -1 }, // 0x20 ' '
When compiling the error is: #include "c:\Arduino\Project\libraries\Adafruit-GFX-Library-Master\Fonts2\FreeArial_Bold12full_TL.h"
^
compilation terminated.
You would test for system font i.e. gfxFont == NULL
If not NULL, you would add the appropriate offset to _y1.
The system font uses 8 pixels height. - (4 * _textsize) centres it. i.e. subtract half-height * textsize to get the top-line
You would look up the height of the letter '8'. Then add half-height * textsize to get the base line
Most fonts contain the letter '8'. It is normally the same height as CAPITALS
Personally, I would always choose x1 when using FreeFonts.
What is the point of turning an attractive smooth font into an ugly blocky one?
You can see the difficulties with "special fonts"
OK.
I plan to use font in 9, 12 and 18 pt. in order not to use x2.
But the problem when not using monospace is (as well as I can see in the program), that the program don't know the width af the single chars and then not the langth of the string. Am I rigth?
There are methods like getTextBounds(). I think there is a charWidth() too.
Look in Adafruit_GFX.h
You can write your own functions to centre or right-align proportional width fonts.
A monospaced font is easier. You read fixed width and height as a one-off.
When overwriting text, you can draw a fresh background for the whole string. Looks blinky.
Or you draw a fresh background one character at a time. Looks nicer.
Ideally you would draw letter and background in one go like you do with the 5x7 font.