/*
Mandelbrot image
2foxi 25.09.2024
convert JPG image to Hex-String Array without "0x"
url: https://tomeko.net/online_tools/file_to_hex.php?lang=en
*/
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
#include <TJpg_Decoder.h>
#include "mandel.h" // Mandelbrot image char hex Array
#define TFT_CS 5
#define TFT_RST 4
#define TFT_DC 2
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap) { // callback function
tft.drawRGBBitmap(x, y, bitmap, w, h);
return 1;
}
uint8_t* hexToByteArray(const char* hexString) {
size_t len = strlen(hexString);
uint8_t* byteArray = new uint8_t[len / 2]; // Größe des Byte-Arrays
for (size_t i = 0; i < len; i += 2) {
char byte[3] = { hexString[i], hexString[i + 1], 0 }; // 2 Hex-Ziffern und Null-Terminator
byteArray[i / 2] = (uint8_t)strtol(byte, nullptr, 16); // Umwandlung in Byte
}
return byteArray;
}
void setup() {
tft.begin();
tft.setRotation(0);
tft.fillScreen(ILI9341_BLACK);
TJpgDec.setJpgScale(1); // init JPG-DEcoder in Originalgröße
TJpgDec.setCallback(tft_output);
const uint8_t* imageData = hexToByteArray(mandel);
uint32_t imageSize = mandelSize;
TJpgDec.drawJpg(0, 0, imageData, imageSize);
delete[] imageData;
}
void loop() {}Mandelbrot
25.9.2024