Hello everybody,
I'm searching a solution to remove the http Header from my Display.
I found many topics about this, but nobody was using the same packages as I do.
#include <GxEPD.h>
//Display Class
#include <GxGDEW042T2/GxGDEW042T2.h> // 4.2" b/w#include GxEPD_BitmapExamples
// FreeFonts from Adafruit_GFX
#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBold12pt7b.h>
#include <Fonts/FreeMonoBold18pt7b.h>
#include <Fonts/FreeMonoBold24pt7b.h>#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>GxIO_Class io(SPI, /CS=5/ SS, /DC=/ 17, /RST=/ 16); // arbitrary selection of 17, 16
GxEPD_Class display(io, /RST=/ 16, /BUSY=/ 4); // arbitrary selection of (16), 4#include <WiFi.h>
const char * ssid = "ssid";
const char * pswd = "pswd";const char * site = "site";
const int port = 80;void setup() {
Serial.begin(115200);
Serial.println();connectWLAN(ssid, pswd);
Serial.println();
delay(2000);
display.init(115200); //enable diagnostic output on SerialSerial.println();
Serial.println();Serial.println("--------------------------SETUP DONE--------------------------");
Serial.println();
Serial.println();
}void loop() {
readPage(site, port);delay(10000);
}void showFont(const GFXfont* f, String header)
{
display.fillScreen(GxEPD_WHITE);
display.setTextColor(GxEPD_BLACK);
display.setFont(f);
display.setCursor(0, 0);
display.println(header);
display.println();
display.println(nameofmeeting);
display.println(room);
display.println(organisator);
//display.update();
}void connectWLAN(const char * ssid, const char * pswd)
{
Serial.println("Verbinden mit " + String(ssid));WiFi.begin(ssid, pswd);
while (WiFi.status() != WL_CONNECTED);
Serial.println();
Serial.println("Verbunden");
Serial.print("Eigene IP Adresse: ");
Serial.println(WiFi.localIP());
}void printPage(WiFiClient client) {
while (client.available())
{
String line = client.readStringUntil('\r');showFont(&FreeMonoBold9pt7b,String(line), "", "", "");
display.update();Serial.println(line);
}
}String createGetCommand(const char * site) {
return (String)"GET / HTTP/1.1\r\n" +
"Host: " + String(site) + "\r\n" +
"Connection: close\r\n\r\n";
}void getPage(WiFiClient client, const char * site) {
client.print(createGetCommand(site));
unsigned long timeout = millis();
while (client.available() == 0) // maximal 5 Sekunden
{
if (millis() - timeout > 5000)
{
Serial.println("*** Client Zeitüberschreitung ***");
client.stop();
return;
}
}
Serial.println();
}void readPage(const char * site, uint8_t port)
{
Serial.println("Verbinden mit URL: " + String(site));// TCP-Verbindung erzeugen
WiFiClient client;
if (!client.connect(site, port)) // verbinden
{
Serial.println("*** Verbindung fehlgeschlagen ***");
return; // in die nächste Runde
Serial.println("*Nächster Versuch");
}
// Verbindungsaufbau ist jetzt gestartet:
Serial.println("Verbindung steht");getPage(client, site); // Seite holen
printPage(client); // Seite ausgebenSerial.println("Schließen der Verbindung");
client.stop(); // Verbindung schließen
}