#include "vtanimations.h"
void setup()
{
DisplayController.
begin();
Terminal.
begin(&DisplayController);
}
void slowPrintf(const char * format, ...)
{
va_list ap;
va_start(ap, format);
int size = vsnprintf(nullptr, 0, format, ap) + 1;
if (size > 0) {
va_end(ap);
va_start(ap, format);
char buf[size + 1];
vsnprintf(buf, size, format, ap);
for (int i = 0; i < size; ++i) {
delay(25);
}
}
va_end(ap);
}
void demo1()
{
Terminal.
write(
"\e[40;92m");
Terminal.
write(
"\e[1;1H");
slowPrintf("* * * * W E L C O M E T O F a b G L * * * *\r\n");
slowPrintf("2019-2022 by Fabrizio Di Vittorio - www.fabgl.com\r\n");
slowPrintf("===============================================\r\n\n");
slowPrintf("Text only VGA display controller demo\r\n\n");
slowPrintf("Current settings\r\n");
slowPrintf(
"Terminal Size : %d x %d\r\n", Terminal.
getColumns(), Terminal.
getRows());
slowPrintf("Free Memory : %d bytes\r\n\n", heap_caps_get_free_size(MALLOC_CAP_32BIT));
}
void demo2()
{
Terminal.
write(
"\e[40;92m");
slowPrintf("16 colors supported\r\n");
slowPrintf("ANSI colors:\r\n");
Terminal.
write(
"\e[31mRED\t"); delay(500);
Terminal.
write(
"\e[32mGREEN\t"); delay(500);
Terminal.
write(
"\e[33mYELLOW\t"); delay(500);
Terminal.
write(
"\e[34mBLUE\t"); delay(500);
Terminal.
write(
"\e[35mMAGENTA\t"); delay(500);
Terminal.
write(
"\e[36mCYAN\t"); delay(500);
Terminal.
write(
"\e[37mWHITE\r\n"); delay(500);
Terminal.
write(
"\e[90mHBLACK\t"); delay(500);
Terminal.
write(
"\e[91mHRED\t"); delay(500);
Terminal.
write(
"\e[92mHGREEN\t"); delay(500);
Terminal.
write(
"\e[93mHYELLOW\t"); delay(500);
Terminal.
write(
"\e[94mHBLUE\t"); delay(500);
Terminal.
write(
"\e[95mHMAGENTA\t"); delay(500);
Terminal.
write(
"\e[96mHCYAN\t"); delay(500);
Terminal.
write(
"\e[97mHWHITE\r\n"); delay(500);
Terminal.
write(
"\e[40mBLACK\t"); delay(500);
Terminal.
write(
"\e[41mRED\e[40m\t"); delay(500);
Terminal.
write(
"\e[42mGREEN\e[40m\t"); delay(500);
Terminal.
write(
"\e[43mYELLOW\e[40m\t"); delay(500);
Terminal.
write(
"\e[44mBLUE\e[40m\t"); delay(500);
Terminal.
write(
"\e[45mMAGENTA\e[40m\t"); delay(500);
Terminal.
write(
"\e[46mCYAN\e[40m\t"); delay(500);
Terminal.
write(
"\e[47mWHITE\e[40m\r\n"); delay(500);
Terminal.
write(
"\e[100mHBLACK\e[40m\t"); delay(500);
Terminal.
write(
"\e[101mHRED\e[40m\t"); delay(500);
Terminal.
write(
"\e[102mHGREEN\e[40m\t"); delay(500);
Terminal.
write(
"\e[103mHYELLOW\e[40m\t"); delay(500);
Terminal.
write(
"\e[104mHBLUE\e[40m\t"); delay(500);
Terminal.
write(
"\e[105mHMAGENTA\e[40m\t"); delay(500);
Terminal.
write(
"\e[106mHCYAN\e[40m\r\n"); delay(500);
}
void demo3()
{
Terminal.
write(
"\e[40;92m");
slowPrintf("\nSupported styles:\r\n");
slowPrintf("\e[0mNormal\r\n");
slowPrintf("\e[1mBold\e[0m\r\n");
slowPrintf("\e[4mUnderlined\e[0m\r\n");
slowPrintf("\e[5mBlink\e[0m\r\n");
slowPrintf("\e[7mInverse\e[0m\r\n");
slowPrintf("\e[1;4mBoldUnderlined\e[0m\r\n");
slowPrintf("\e[1;4;5mBoldUnderlinedBlinking\e[0m\r\n");
slowPrintf("\e[1;4;5;7mBoldUnderlinedBlinkingInverse\e[0m\r\n");
}
void demo5()
{
Terminal.
write(
"\e[40;93m");
slowPrintf("\e[10;56HFast Rendering");
slowPrintf("\e[12;50HThis is a VT/ANSI animation");
Terminal.
write(
"\e[20h");
Terminal.
write(
"\e[92m");
for (int j = 0; j < 4; ++j) {
for (int i = 0; i < sizeof(vt_animation); ++i) {
Terminal.
write(vt_animation[i]);
if (vt_animation[i] == 0x1B && vt_animation[i + 1] == 0x5B && vt_animation[i + 2] == 0x48)
delay(120);
}
}
Terminal.
write(
"\e[20l");
}
void loop()
{
delay(1000);
demo1();
delay(4000);
demo2();
delay(4000);
demo3();
delay(4000);
demo5();
delay(4000);
}
int getScreenHeight()
Determines the screen height in pixels.
int getScreenWidth()
Determines the screen width in pixels.
int getRows()
Returns the number of lines.
int getColumns()
Returns the number of columns.
size_t write(const uint8_t *buffer, size_t size)
Sends specified number of codes to the display.
void enableCursor(bool value)
Enables or disables cursor.
bool begin(BaseDisplayController *displayController, int maxColumns=-1, int maxRows=-1, Keyboard *keyboard=nullptr)
Initializes the terminal.
An ANSI-VT100 compatible display terminal.
void begin(gpio_num_t redGPIO, gpio_num_t greenGPIO, gpio_num_t blueGPIO, gpio_num_t HSyncGPIO, gpio_num_t VSyncGPIO)
This is the 8 colors (5 GPIOs) initializer.
void setResolution(char const *modeline=nullptr, int viewPortWidth=-1, int viewPortHeight=-1, bool doubleBuffered=false)
Sets fixed resolution.
Represents the VGA text-only controller.
This file is the all in one include file. Application can just include this file to use FabGL library...