Skip to content
Discussion options

You must be logged in to vote

The only way to do this is to use a sprite with the correct background gradient drawn in it. Here is an example:

#include <Arduino.h>
#include "SPI.h"
#include <TFT_eSPI.h>

#define MAX_DISPLAY_WIDTH 240
#define MAX_DISPLAY_HEIGHT 320

TFT_eSPI tft = TFT_eSPI();
TFT_eSprite spr = TFT_eSprite(&tft);

void setup()
{
  Serial.begin(115200);
  tft.begin();
  tft.fillRectVGradient(0, 0, MAX_DISPLAY_WIDTH, MAX_DISPLAY_HEIGHT, TFT_RED, TFT_YELLOW);
}

void loop()
{
  // Text and background will be rendered in a sprite
  spr.setTextFont(6);
  uint16_t tw = spr.textWidth("888"); // Width of test to be drawn
  uint16_t th = spr.fontHeight();     // Font height

  spr.createSprite(tw, th);
  spr.set…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by otl1
Comment options

You must be logged in to vote
1 reply
@Bodmer
Comment options

Comment options

You must be logged in to vote
1 reply
@Bodmer
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment