/*
This shows the capabilities of the library text engine that is
extremely flexible and simple! All commands are the same for all type of text
(INT,EXT or Render ones) and things like println works too.
You can use all the print() options (like print(var,HEX), etc. Take a look the print command
in the arduino guide!)
*/
#include <SPI.h>
#include <RA8875.h>
#include "fonts/heydings_36.c"//minipixel
#include "fonts/akashi_36.c"//minipixel
#define RA8875_CS 10
#define RA8875_RESET 8//any pin or 255 to disable it!
RA8875 tft = RA8875(RA8875_CS, RA8875_RESET);
void setup()
{
Serial.begin(38400);
long unsigned debug_start = millis ();
while (!Serial && ((millis () - debug_start) <= 5000)) ;
Serial.println("RA8875 start");
// begin display: Choose from: RA8875_480x272, RA8875_800x480, RA8875_800x480ALT, Adafruit_480x272, Adafruit_800x480
tft.begin(Adafruit_800x480);
tft.fillWindow(RA8875_BLACK);//fill window black
tft.setRotation(0);//works at any rotation as well
tft.setFont(&heydings_36);
tft.setFontScale(1);
tft.setCursor(0,0);
//tft.setTextColor(RA8875_GREEN);//notice that! After grandient text will be this color!
//grandient it's one shot, text color will be reset as the one choosed by setTextColor
tft.setTextGrandient(RA8875_RED,RA8875_CYAN);//works also with rendered text!
tft.println("BSuRF");
tft.print("_");
tft.fillWindow(RA8875_BLACK);//fill window black
int16_t nX,nY;
int16_t nBX1,nBY1; // Bounds result
uint16_t nBW,nBH; // Bounds result
char acStr[20];
// Provide some offset away from top-left corner
nX = 20;
nY = 10;
sprintf(acStr,"Tes
ting");
// Font selection
tft.setFont(INTFONT);
//tft.setFont(&akashi_36);
tft.setFontScale(1);
// Fetch string dimensions
nBX1 = nX;
nBY1 = nY;
nBW = 0;
nBH = 0;
tft.getTextBounds(acStr,nX,nY,&nBX1,&nBY1,&nBW,&nBH);
Serial.printf("%d, %d, %d, %d\n", nBX1, nBY1, nBW, nBH);
// Display the fetched bounding rectangle
tft.drawRect(nX,nY,nBW,nBH,RA8875_YELLOW);
// Render text
tft.setCursor(nX, nY);
tft.setTextColor(RA8875_WHITE);
tft.print(acStr);
}
void loop()
{
}