Go Down

Topic: Umlaut on ePaper (Read 86 times) previous topic - next topic

Hobbes_1

Hi All,

With the below code I can receive Telegram messages from my Bot on a 4.2 b/w Waveshare ePaper. All works nicely, however instead of getting an Umlaut (ÄÖÜäöü) on my ePaper, I get e.g. "u00d61l" for "Öl".
I installed the Adafruit GFX Library and played around, but the code would not compile.

Can anyone please tell me where to add what in my code?

Thanks a lot!

Code: [Select]
//ePaper
#include <GxEPD.h>
#include <GxGDEW042T2/GxGDEW042T2.h>      // 4.2" b/w

#include <Fonts/FreeMonoBold9pt7b.h>
#include <Fonts/FreeMonoBold12pt7b.h>

#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>
GxIO_Class io(SPI, /*CS=D1*/ 5, /*DC=D3*/ 0, /*RST=D4*/ 2);
GxEPD_Class display(io, /*RST=D4*/ 2, /*BUSY=D2*/ 4);

//Bot
#include "CTBot.h"
CTBot myBot;
TBUser sender;

#include <TimeLib.h>
String l_line;
int DST;
int tzHours = 1;
int Stunde;

void setup()
{
  Serial.begin(115200);

  display.init(115200); //ePaper

  String ssid  = "myWiFi";
  String pass  = "myPassword";
  String token = "myBotToken";
  myBot.wifiConnect(ssid, pass);
  myBot.setTelegramToken(token);

  delay(5000);
 
  display.fillScreen(GxEPD_WHITE);
  display.setTextColor(GxEPD_BLACK);
  display.setFont(&FreeMonoBold12pt7b);
  display.setCursor(0, 40);
  // Check if all things are ok
  if (myBot.testConnection()) {
    display.println("DiWa Telegram Receiver Ready");
    display.print("WiFi network: ");
    display.print(ssid);
  }
  else {
    display.print("Connection problem.");
  }
  display.update();
}

void loop()
{
  TBMessage msg;

  if (myBot.getNewMessage(msg)) {
    Serial.print(msg.text);
    display.fillScreen(GxEPD_WHITE);
    display.setTextColor(GxEPD_BLACK);
    display.setFont(&FreeMonoBold9pt7b);
    //display.setFont(&FreeMonoBold9pt7b);
    display.setCursor(0, 40);
    display.println(msg.sender.firstName);
    l_line = (msg.date);
    time_t t = l_line.toInt();
    if (month(t)<3 || month(t)>10) DST = 0; // keine Sommerzeit in Jan, Feb, Nov, Dez
    if (month(t)>3 && month(t)<10) DST = 1; // Sommerzeit in Apr, Mai, Jun, Jul, Aug, Sep
    if (month(t)==3 && (hour(t) + 24 * day(t))>=(1 + tzHours + 24*(31 - (5 * year(t) /4 + 4) % 7)) || month(t)==10 && (hour(t) + 24 * day(t))<(1 + tzHours + 24*(31 - (5 * year(t) /4 + 1) % 7)))
      DST = 1;
    if (DST == 1) Stunde = hour(t)+tzHours+1;
    else Stunde = hour(t)+tzHours;
    if (Stunde<10) display.print("0");
    display.print(Stunde);
    display.print(":");
    if (minute(t)<10) display.print("0");
    display.print(minute(t));
    display.print(" Uhr, ");
    if (day(t)<10) display.print("0");
    display.print(day(t));
    display.print(".");
    if (month(t)<10) display.print("0");
    display.print(month(t));
    display.print(".");
    display.println(year(t));
    display.println();
    display.println("Umlaut ÄÖÜäéöü"); // <------------------ Only shows "Umlaut"
    display.println(msg.text);
    display.update();
   
    myBot.sendMessage(msg.sender.id, "Text ist angekommen.");
  }
  delay(500);
}

PaulS

Quote
Can anyone please tell me where to add what in my code?
Add whatever is needed to accomplish the undefined task, at the appropriate place.

Code: [Select]
  TBMessage msg;
Where is this object type defined?

Code: [Select]
    Serial.print(msg.text);
Does this print the text, including umlauts, correctly?

Code: [Select]
    display.setFont(&FreeMonoBold9pt7b);
Does this font include characters with umlauts?
The art of getting good answers lies in asking good questions.

lesept

Have a look here, there is a link to a program called fontconverter
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

Go Up