#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
const char* host = "tillmannkloeckner.de";
unsigned char epd_bitmap_herz [] PROGMEM = {
0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x3c, 0x07, 0xe0, 0x7e, 0x0f, 0xf0, 0x7f,
0xbe, 0x70, 0xff, 0xfe, 0x70, 0xf1, 0xff, 0xf0, 0xf3, 0xff, 0xe0, 0xf3, 0xfb, 0xc0, 0xff, 0xe3,
0xc0, 0xfc, 0x2f, 0x80, 0x7f, 0x8f, 0x80, 0x3f, 0xff, 0x80, 0x0f, 0xff, 0x00, 0x01, 0xfe, 0x00,
0x00, 0xfc, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x10
};
String herz = "0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x3c, 0x07, 0xe0, 0x7e, 0x0f, 0xf0, 0x7f, 0xbe, 0x70, 0xff, 0xfe, 0x70, 0xf1, 0xff, 0xf0, 0xf3, 0xff, 0xe0, 0xf3, 0xfb, 0xc0, 0xff, 0xe3, 0xc0, 0xfc, 0x2f, 0x80, 0x7f, 0x8f, 0x80, 0x3f, 0xff, 0x80, 0x0f, 0xff, 0x00, 0x01, 0xfe, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x10";
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
delay(250);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
delay(1000);
Serial.println("HTTP-Begin");
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
HTTPClient http;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
// We now create a URI for the request
String url = "http://"+ (String) host + "/api/image.php?id=5";
Serial.print("Requesting URL: ");
Serial.println(url);
http.useHTTP10(true);
http.begin(client, url);
http.GET();
DynamicJsonDocument doc(2048);
deserializeJson(doc, http.getStream());
//Serial.print(http.getString());
Serial.println("");
Serial.print("ID = ");
Serial.println(doc["id"].as<long>());
Serial.print("black= ");
Serial.println(doc["black"].as<String>());
Serial.println(herz);
//String black = doc["black"].as<String>();
String black = herz;
// Umrechnen von String zu char
char zwischen [4];
//int string_length = sizeof(black)/sizeof(unsigned char);
int string_length = black.length();
int image_length = (int)string_length/6;
unsigned char herz_char[image_length];
int u=0;
int v=0;
for(int i = 0; i < string_length; i++)
{
if ((black[i]!=',')&&(black[i]!=' '))
{
zwischen[u]=black[i];
u++;
}
else if (black[i]!=' ')
{
herz_char[v] = strtol(zwischen,NULL,16);
v++;
u=0;
}
else
{
//es ist ein leerzeichen
}
}
for(int j = 0; j < 32; j++)
{
Serial.print("###: 0x");
Serial.print(herz_char[j],HEX);
Serial.print("-->: 0x");
Serial.println(epd_bitmap_herz[j],HEX);
}
Serial.print("string_length:");
Serial.println(string_length);
Serial.print("image_length:");
Serial.println(image_length);
// Disconnect
http.end();
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}