v.0.3.1 use of WeatherFetcher
This commit is contained in:
@@ -49,7 +49,7 @@ public:
|
||||
void clearRow(uint8_t y);
|
||||
|
||||
// Draw text string
|
||||
void drawText(int x, int y, const char *text, CRGB color);
|
||||
void drawText(int x, int y, const char *text, CRGB color = CRGB::White);
|
||||
|
||||
void drawHorizontalScrollText(uint8_t y, const char *text, CRGB color, uint8_t scrollSpeed = 100);
|
||||
};
|
||||
|
||||
@@ -41,19 +41,22 @@ Weather WeatherFetcher::actual_weather(const char *city, const char *lang, bool
|
||||
}
|
||||
|
||||
String weather_url =
|
||||
"https://api.weatherapi.com/v1/current.json?key=" + String(API_KEY) +
|
||||
"http://api.weatherapi.com/v1/current.json?key=" + String(API_KEY) +
|
||||
"&q=" + String(city) + "&aqi=yes&lang=" + String(lang);
|
||||
|
||||
Serial.println("Hole Wetterdaten von: " + weather_url);
|
||||
String msg = "Hole Wetterdaten von: " + weather_url;
|
||||
ColorSerial::info(msg.c_str());
|
||||
|
||||
String json_data = fetch_from_url(weather_url);
|
||||
|
||||
if (!json_data.isEmpty())
|
||||
{
|
||||
ColorSerial::info("data retrieved");
|
||||
weather = parse_weather_json(json_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorSerial::error("no data retrieved");
|
||||
Serial.println("Fehler beim Abrufen der Wetterdaten!");
|
||||
}
|
||||
|
||||
@@ -66,7 +69,7 @@ String WeatherFetcher::fetch_from_url(const String &url)
|
||||
String payload = "";
|
||||
|
||||
http.begin(url);
|
||||
http.setTimeout(10000);
|
||||
// http.setTimeout(10000);
|
||||
|
||||
int httpCode = http.GET();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef WEATHERSTRUCTS_H
|
||||
#define WEATHERSTRUCTS_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <optional>
|
||||
|
||||
struct Location
|
||||
|
||||
Reference in New Issue
Block a user