/*
Forum: https://forum.arduino.cc/t/displaying-rgb-bitmap-on-tft-from-c-file/1191496
Wokwi: https://wokwi.com/projects/382118901174917121
*/
#include "asciiGraphs.h"
// Single sprites created from ASCII arrays
asciiImageStruct img1 {asciiImage1};
asciiImageStruct img2 {asciiImage2};
void setup() {
Serial.begin(115200);
tft.begin();
tft.setRotation(1);
img1.init();
img2.init();
int xCenter = (tft.width() - noOfCols) / 2;
// A single sprite is prepared for static drawing
// at different places with a different color
img2.setXYandStepAndDelay(xCenter, 200, 0, 0);
img2.draw();
img2.setXY(xCenter + noOfCols, 200);
img2.xColor = ILI9341_RED;
img2.draw();
img2.setXY(xCenter - noOfCols, 200);
img2.xColor = ILI9341_GREEN;
img2.draw();
// From here a single sprite is prepared for moving
img1.setXYandStepAndDelay(0, 120, 4, 50);
}
void loop() {
// move img1 every loop a step forward
img1.move();
// if it turns at the borders this will return TRUE
if (img1.isTurning) {
Serial.println("img1 has turned");
// and than the colors of the graphics shall change
changeColor();
}
}
void changeColor() {
if (img1.xColor == ILI9341_BLUE) {
img1.xColor = ILI9341_RED;
img1.oColor = ILI9341_BLUE;
} else {
img1.xColor = ILI9341_BLUE;
img1.oColor = ILI9341_RED;
}
}