Yes, you can make it display faster if you only draw the specific segments.
Your example has two different shapes of segment i.e. horiz and vertical. a, d, g are horiz. b, c. e, f are vertical.
You just need two functions. Then draw them as required.
Calculating triangles is quite computational. It is probably easier to draw individual lines. Which seems to be exactly what you have done. Except that you have chosen non-intuitive names for the functions.
I added the "timing". And changed the colour so that a human could see the screen.
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft; // hard-wired for UNO shields anyway.
const int white = 0xFFFF;
const int mdgrey = 0xEF5D;
int state;
void setup()
{
uint16_t id;
id = tft.readID();
tft.begin(id);
tft.setRotation(1); //landscape
tft.fillScreen(white);
}
void loop() {
int fc = TFT_RED; //mdgrey;
if (state == LOW) {
state = HIGH;
} else {
state = LOW;
}
if (state == LOW) {
tft.fillRect(20, 20, 120, 44, white);
delay(600);
}
if (state == HIGH) {
uint32_t t = micros();
display_82(20, 20, fc);
display_82(50, 20, fc);
display_82(80, 20, fc);
display_82(110, 20, fc);
display_8(20, 20, fc);
display_8(50, 20, fc);
display_8(80, 20, fc);
display_8(110, 20, fc);
t = micros() - t;
tft.setCursor(0, 120);
tft.setTextColor(TFT_BLACK, TFT_WHITE);
tft.print(0.001 * t);
tft.print("ms ");
delay(600);
}
}
void display_82(int x, int y, int fc) {
tft.drawLine(x + 6, y + 39, x + 6, y + 42, fc);
tft.drawLine(x + 5, y + 40, x + 5, y + 41, fc);
tft.drawLine(x + 20, y + 39, x + 20, y + 42, fc);
tft.drawLine(x + 21, y + 40, x + 21, y + 41, fc);
tft.drawLine(x + 1, y + 5, x + 4, y + 5, fc);
tft.drawLine(x + 2, y + 4, x + 3, y + 4, fc);
tft.drawLine(x + 1, y + 19, x + 4, y + 19, fc);
tft.drawLine(x + 2, y + 20, x + 3, y + 20, fc);
tft.drawLine(x + 22, y + 5, x + 25, y + 5, fc);
tft.drawLine(x + 23, y + 4, x + 24, y + 4, fc);
tft.drawLine(x + 22, y + 19, x + 25, y + 19, fc);
tft.drawLine(x + 22, y + 20, x + 24, y + 20, fc);
tft.drawLine(x + 1, y + 24, x + 4, y + 24, fc);
tft.drawLine(x + 2, y + 23, x + 3, y + 23, fc);
tft.drawLine(x + 1, y + 38, x + 4, y + 38, fc);
tft.drawLine(x + 2, y + 39, x + 3, y + 39, fc);
tft.drawLine(x + 22, y + 24, x + 25, y + 24, fc);
tft.drawLine(x + 23, y + 23, x + 24, y + 23, fc);
tft.drawLine(x + 22, y + 38, x + 25, y + 38, fc);
tft.drawLine(x + 23, y + 39, x + 24, y + 39, fc);
tft.drawLine(x + 6, y + 1, x + 6, y + 4, fc);
tft.drawLine(x + 5, y + 2, x + 5, y + 3, fc);
tft.drawLine(x + 20, y + 1, x + 20, y + 4, fc);
tft.drawLine(x + 21, y + 2, x + 21, y + 3, fc);
tft.drawLine(x + 6, y + 20, x + 6, y + 23, fc);
tft.drawLine(x + 5, y + 21, x + 5, y + 22, fc);
tft.drawLine(x + 20, y + 20, x + 20, y + 23, fc);
tft.drawLine(x + 21, y + 21, x + 21, y + 22, fc);
}
void display_8(int x, int y, int fc) {
//Top left
tft.fillRect(x, y + 6, 6, 13, fc);
//Top right
tft.fillRect(x + 21, y + 6, 6, 13, fc);
//Bottom left
tft.fillRect(x, y + 25, 6, 13, fc);
//Bottom right
tft.fillRect(x + 21, y + 25, 6, 13, fc);
//Horizontal Top
tft.fillRect(x + 7, y, 13, 6, fc);
//Horizontal Middle
tft.fillRect(x + 7, y + 19, 13, 6, fc);
//Horizontal bottom
tft.fillRect(x + 7, y + 38, 13, 6, fc);
}
I was amazed to see that there was not much improvement in the time. 69.77ms on a Mega using the current Beta library.
David.
Edit. I was using a SSD1297 which is inherently slow.
If I use an ILI9341 I get 77.40ms for the bitmap and 26.54ms for your draw functions.