Qrome / marquee-scroller

Marquee Scroller Clock News Weather and More
https://www.thingiverse.com/thing:2867294
MIT License
328 stars 159 forks source link

Add Local News Source #175

Open chray68 opened 3 years ago

chray68 commented 3 years ago

First of all, this is a superb Project!! Just build two of the Marquees and also one of the tiny Double Printer Monitor and everything worked out fine! I was able to change a view words in the code to appear in german but couldn't find a way to display the special characters ( ä,ö,ü ) at the weather report to ae ue oe? Can this be done somehow? But the main Question is about the news: How can i change the code/settings to add/show another news service which isn't chooseable through the Web Interface? I would like to show the Austrian Headlines and i guess the correct entry should look something like this:http:// newsapi.org/v2/top-headlines?country=at&apiKey=XXXXXXXXXXXXXXXX Line Nr. 45 at the NewsApiClient.cpp looks similar and i tried to change it to show my Local News but w/o any success. Maybe somebody could be so kind and show me the exact entry step by step to make that change possible. Thanks again for that great Design and Code!

chray68 commented 3 years ago

Found it out by myself how to edit Line 45 :) Now only the issue with the special characters in the weather report remains open - maybe any Hints?

physi commented 3 years ago

I fixed that by creating a Helper class Helper.h

#include <Arduino.h>
String cleanText(String text);

Helper.cpp

#include "Helper.h"
#include <Arduino.h>

String cleanText(String text) {
  text.replace("’", "'");
  text.replace("“", "\"");
  text.replace("”", "\"");
  text.replace("`", "'");
  text.replace("‘", "'");
  text.replace("„", "'");
  text.replace("\\\"", "'");
  text.replace("•", "-");
  text.replace("é", "e");
  text.replace("è", "e");
  text.replace("ë", "e");
  text.replace("ê", "e");
  text.replace("à", "a");
  text.replace("â", "a");
  text.replace("ù", "u");
  text.replace("ç", "c");
  text.replace("î", "i");
  text.replace("ï", "i");
  text.replace("ô", "o");
  text.replace("…", "...");
  text.replace("–", "-");
  text.replace("Â", "A");
  text.replace("À", "A");
  text.replace("æ", "ae");
  text.replace("Æ", "AE");
  text.replace("É", "E");
  text.replace("È", "E");
  text.replace("Ë", "E");
  text.replace("Ô", "O");
  text.replace("Ö", "Oe");
  text.replace("ö", "oe");
  text.replace("œ", "oe");
  text.replace("Œ", "OE");
  text.replace("Ù", "U");
  text.replace("Û", "U");
  text.replace("Ü", "Ue");
  text.replace("ü", "ue");
  text.replace("Ä", "Ae");
  text.replace("ä", "ae");
  text.replace("ß", "ss");
  text.replace("»", "'");
  text.replace("«", "'");
  return text;
}

and include that into OpenWeatherMapClient.cpp with #include "Helper.h"and change line 109 to weathers[inx].city = cleanText(root["list"][inx]["name"]);

chray68 commented 3 years ago

I fixed that by creating a Helper class Helper.h

#include <Arduino.h>
String cleanText(String text);

Helper.cpp

#include "Helper.h"
#include <Arduino.h>

String cleanText(String text) {
  text.replace("’", "'");
  text.replace("“", "\"");
  text.replace("”", "\"");
  text.replace("`", "'");
  text.replace("‘", "'");
  text.replace("„", "'");
  text.replace("\\\"", "'");
  text.replace("•", "-");
  text.replace("é", "e");
  text.replace("è", "e");
  text.replace("ë", "e");
  text.replace("ê", "e");
  text.replace("à", "a");
  text.replace("â", "a");
  text.replace("ù", "u");
  text.replace("ç", "c");
  text.replace("î", "i");
  text.replace("ï", "i");
  text.replace("ô", "o");
  text.replace("…", "...");
  text.replace("–", "-");
  text.replace("Â", "A");
  text.replace("À", "A");
  text.replace("æ", "ae");
  text.replace("Æ", "AE");
  text.replace("É", "E");
  text.replace("È", "E");
  text.replace("Ë", "E");
  text.replace("Ô", "O");
  text.replace("Ö", "Oe");
  text.replace("ö", "oe");
  text.replace("œ", "oe");
  text.replace("Œ", "OE");
  text.replace("Ù", "U");
  text.replace("Û", "U");
  text.replace("Ü", "Ue");
  text.replace("ü", "ue");
  text.replace("Ä", "Ae");
  text.replace("ä", "ae");
  text.replace("ß", "ss");
  text.replace("»", "'");
  text.replace("«", "'");
  return text;
}

and include that into OpenWeatherMapClient.cpp with #include "Helper.h"and change line 109 to weathers[inx].city = cleanText(root["list"][inx]["name"]);

Thank you physi for trying to help ! I've just followed your instruction but unfortunately it is still displaying wrong characters? Right now it should say "Überwiegend bewölkt" but the Ü is shown as £ and iso ö it shows other weird characters. Helper Files created and line 109 changed accordingly any Idea what else the Problem could be?

physi commented 3 years ago

Ok, I had the Problem with the cityname, you may need to change line 111 to: weathers[inx].condition = cleanText(root["list"][inx]["weather"][0]["main"]); And to be on the whole German side , just do it for each line in that section 😊

chray68 commented 3 years ago

the condition line didn't change anything but the description line did :) Now everything is displayed as it should be ! Thank you very much for your help!!!