/*
Forum: https://forum.arduino.cc/t/displaying-rgb-bitmap-on-tft-from-c-file/1191496
Wokwi: https://wokwi.com/projects/381952766027751425
*/
#include "hi.h"
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
constexpr int offX = 100;
constexpr int offY = 120;
void setup() {
Serial.begin(115200);
Serial.println(image.width);
Serial.println(image.height);
tft.begin();
tft.fillScreen(ILI9341_RED);
decodeImage();
}
void loop() {
}
void decodeImage(){
uint16_t a;
uint16_t b;
uint16_t color;
for (int row=0; row < image.height; row++){
for (int col=0;col < image.width;col++){
a = pixil_frame[row*image.width*2+col*2];
b = pixil_frame[row*image.width*2+col*2+1];
// Line was color = a << 8 + b;
// 2023-11-22 ec2021: Changed to ...
color = b << 8 + a;
if (color == 0) {color = ILI9341_WHITE;};
tft.drawPixel(col+offX,row+offY,color);
}
}
}