#include <Adafruit_GFX.h>
#include "Adafruit_ILI9341.h"
#include "beanstalk15.h"
#include "utf8_fix.h"
#define TFT_DC 2
#define TFT_RST 4
#define TFT_CS 5
#define TFT_WHITE 0xFFFF
#define TFT_BLACK 0x0000
GFX_UTF8 tft(TFT_CS, TFT_DC, TFT_RST);
void setup(void) {
Serial.begin(115200);
tft.begin();
tft.fillScreen(TFT_BLACK);
tft.setFont(&beanstalk15);
tft.setRotation(0);
tft.setTextWrap(false);
tft.setTextColor(TFT_WHITE);
int x = 2, y = 15;
int charW = 7;
int lineH = 17;
for (uint16_t code = 0x0020; code <= 0x017F; code++) {
tft.setCursor(x, y);
if (code < 0x80) {
tft.write((uint8_t)code);
} else {
// UTF-8 encode
tft.write((uint8_t)(0xC0 | (code >> 6)));
tft.write((uint8_t)(0x80 | (code & 0x3F)));
}
x += charW;
if (x + charW > 238) {
x = 2;
y += lineH;
}
if (y > 310) {
delay(3000);
tft.fillScreen(TFT_BLACK);
y = 15;
x = 2;
}
}
}
void loop() {
delay(500);
}