Files
flyradar/src/weather.h
2026-08-16 14:33:27 +02:00

32 lines
1.2 KiB
C++

#pragma once
#include <Arduino.h>
// Very simple weather display (icon in the header, where the camera button
// used to be) - periodically queries the current weather for the currently
// active location (including active location preset, see
// LocationManager::getHomeLocation() - if e.g. Milan is selected there,
// the icon shows the weather in Milan). Uses the free Open-Meteo API (no
// API key needed).
namespace Weather {
enum class Condition {
Unknown, // no successful query yet - icon shows nothing
Clear,
PartlyCloudy,
Cloudy,
Rain,
Snow,
Thunderstorm
};
// Must be called regularly from NetTask (Core 0) - handles the query
// interval internally (Config::WEATHER_FETCH_INTERVAL_MS) and detects
// location changes (e.g. different active preset) to immediately re-query
// instead of waiting for the next regular interval.
void update();
// Currently known weather condition, thread-safe enough for this purpose (a
// single uint8-like enum, only written by NetTask and read by the UI thread
// - no lock needed, a briefly stale read is harmless).
Condition current();
}