I am using a Mega2560 with a Mcufriend 3.5" tft display. I am working on a project that I would like to flash/blink a line of text. This works ok with the built in font but not so well with the 7 segment font that is supplied with the mcufriend library where there is a very noticeable left to right draw that is not acceptable in this application. I have written a small sketch to test this but the result is still the same, so...as the built-in font is almost like a 7 segment font is it possible to modify it to look like a seven segment font? or is there a faster way of doing this?
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft; // hard-wired for UNO shields anyway.
#include <TouchScreen.h>
#include <FreeDefaultFonts.h>
const int white = 0xFFFF;
const int green = 0x07E0;
int state;
void setup() {
uint16_t id;
tft.reset();
id = tft.readID();
tft.begin(id);
tft.setRotation(1);//landscape
tft.fillScreen(white);
}
void loop() {
tft.setFont(&FreeSevenSegNumFont);
tft.setTextSize(1);
if (state==LOW) {state=HIGH;} else {state=LOW;}
if (state==LOW) {tft.setCursor(20,76);
tft.setTextColor(white);
tft.print(2850);
delay(300);}
if (state==HIGH) {tft.setCursor(20,76);
tft.setTextColor(green);
tft.print(2850);
delay(300);}
tft.setFont(NULL);
tft.setTextSize(1);
if (state==LOW) {tft.setCursor(20,100);
tft.setTextColor(white);
tft.print(2850);
delay(300);}
if (state==HIGH) {tft.setCursor(20,100);
tft.setTextColor(green);
tft.print(2850);
delay(300);}
}
Same result, the switching fonts was there just so I could see the difference between the two fonts, actually the built-in font should be size 6 but it doesn't make a lot of difference to the draw speed
I have to say that I wish I could write a piece of code like that without making any mistakes at all! Sadly I can't and that way of doing it doesn't make any difference unfortunately. I've used that technique of filling a rectangle but I tend to use it where I know the characters will change between flashes, usually works well. I think this problem is because of the way the built-in fonts are different from the add-on fonts, only I'm not sure what the difference is. when you look at those two fonts they are not a world apart so why should one take a lot longer to draw that the other?
I think this problem is because of the way the built-in fonts are different from the add-on fonts
I don't think the issue is with the way the two different kinds of fonts are designed. The built-in fonts most likely live in PROGMEM, while the add-on fonts live in SRAM. The code is optimized for displaying PROGMEM data.
PaulS:
I don't think the issue is with the way the two different kinds of fonts are designed. The built-in fonts most likely live in PROGMEM, while the add-on fonts live in SRAM. The code is optimized for displaying PROGMEM data.
In order to deal with more complex font, MCUFRIEND_kbv does way more when drawing a char / pixel than the original adafruit library... there is a cost there probably to that flexibility