Remove support of Four-line display
Four line Display support removed because the Display font cannot draw the Celsius symbol and wind direction
This commit is contained in:
@@ -21,8 +21,6 @@ build_flags = ${env:esp32dev.build_flags}
|
|||||||
- `void setEnable(bool enable)` – To change enable state
|
- `void setEnable(bool enable)` – To change enable state
|
||||||
- `bool isEnable()` – To query enable state
|
- `bool isEnable()` – To query enable state
|
||||||
- `WeatherInfo *currentWeather()` – To query current weather struct
|
- `WeatherInfo *currentWeather()` – To query current weather struct
|
||||||
- `inline bool drawWeatherOnDisplay(long howLong)` – Show current weather (if available) on four line display for _howLong_ milliseconds.
|
|
||||||
See _YA_WEATHER_DRAW_ in __Additional Build Flags__ section
|
|
||||||
|
|
||||||
### Access from other Usermod
|
### Access from other Usermod
|
||||||
|
|
||||||
@@ -98,7 +96,6 @@ Enable post weather data to MQTT topic (/yandexWeather)
|
|||||||
| YA_WEATHER_DEBUG | Show debug message with _[YandexWeatherUsermod]_ prefix |
|
| YA_WEATHER_DEBUG | Show debug message with _[YandexWeatherUsermod]_ prefix |
|
||||||
| YA_WEATHER_ALLOW_ALL_TIMEOUT | Allows you to set UpdateInterval to less than 30 (Use for tests or if you have a paid ApiKey) |
|
| YA_WEATHER_ALLOW_ALL_TIMEOUT | Allows you to set UpdateInterval to less than 30 (Use for tests or if you have a paid ApiKey) |
|
||||||
| YA_WEATHER_HIDE_REMAINING | Hide the remaining time to update in Info |
|
| YA_WEATHER_HIDE_REMAINING | Hide the remaining time to update in Info |
|
||||||
| YA_WEATHER_DRAW | Enable support of [Four Line Display](https://mm.kno.wled.ge/usermods/4LineDisplay) |
|
|
||||||
|
|
||||||
-----
|
-----
|
||||||
Author:
|
Author:
|
||||||
|
|||||||
@@ -6,13 +6,6 @@
|
|||||||
// #define YA_WEATHER_DEBUG // Show debug message with [YandexWeatherUsermod] prefix
|
// #define YA_WEATHER_DEBUG // Show debug message with [YandexWeatherUsermod] prefix
|
||||||
// #define YA_WEATHER_ALLOW_ALL_TIMEOUT // Allows you to set UpdateInterval to less than 30
|
// #define YA_WEATHER_ALLOW_ALL_TIMEOUT // Allows you to set UpdateInterval to less than 30
|
||||||
// #define YA_WEATHER_HIDE_REMAINING // Hide the remaining time to update in Info
|
// #define YA_WEATHER_HIDE_REMAINING // Hide the remaining time to update in Info
|
||||||
// #define YA_WEATHER_DRAW // Enable support of Four Line Display
|
|
||||||
|
|
||||||
#ifdef YA_WEATHER_DRAW
|
|
||||||
#ifndef USERMOD_FOUR_LINE_DISPLAY
|
|
||||||
#undef YA_WEATHER_DRAW
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class YandexWeatherUsermod: public Usermod
|
class YandexWeatherUsermod: public Usermod
|
||||||
{
|
{
|
||||||
@@ -47,10 +40,6 @@ private:
|
|||||||
char errorMessage[100] = "";
|
char errorMessage[100] = "";
|
||||||
WeatherInfo *_weatherInfo;
|
WeatherInfo *_weatherInfo;
|
||||||
|
|
||||||
#ifdef YA_WEATHER_DRAW
|
|
||||||
FourLineDisplayUsermod* display;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// configurable parameters
|
// configurable parameters
|
||||||
String _apiKey = "";
|
String _apiKey = "";
|
||||||
int _updateInterval = 30;
|
int _updateInterval = 30;
|
||||||
@@ -108,25 +97,22 @@ private:
|
|||||||
|
|
||||||
inline String firstWeatherLine() {
|
inline String firstWeatherLine() {
|
||||||
if (_weatherInfo == nullptr) return String(F(""));
|
if (_weatherInfo == nullptr) return String(F(""));
|
||||||
String res = "";
|
char r[20];
|
||||||
res += _weatherInfo->tempReal;
|
sprintf_P(r, "%d (like %d)", _weatherInfo->tempReal, _weatherInfo->tempFeels);
|
||||||
res += F("°C\n(like ");
|
return String(r);
|
||||||
res += _weatherInfo->tempFeels;
|
|
||||||
res += F("°C)");
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline String secondWeatherLine() {
|
inline String secondWeatherLine() {
|
||||||
if (_weatherInfo == nullptr) return String(F(""));
|
if (_weatherInfo == nullptr) return String(F(""));
|
||||||
String res = "";
|
char r[15];
|
||||||
res += _weatherInfo->windSpeed;
|
sprintf(r, "%.2f m/s", _weatherInfo->windSpeed);
|
||||||
res += F(" m/s");
|
|
||||||
if (!_weatherInfo->windDir.isEmpty()) {
|
if (!_weatherInfo->windDir.isEmpty()) {
|
||||||
res += F(" (");
|
char wd[4];
|
||||||
res += String(windCharByString(_weatherInfo->windDir.c_str()).c_str());
|
sprintf(wd, "(%s)", windCharByString(_weatherInfo->windDir.c_str()).c_str());
|
||||||
res += F(")");
|
strcat(r, wd);
|
||||||
}
|
}
|
||||||
return res;
|
return String(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helping functions
|
// Helping functions
|
||||||
@@ -369,35 +355,9 @@ public:
|
|||||||
return apiGetWeather(errorMessage);
|
return apiGetWeather(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show weather (if exists) on Four line Display
|
|
||||||
* @param howLong Display time in milliseconds
|
|
||||||
* @return `true` – If displayed successfully, otherwise – `false`
|
|
||||||
*/
|
|
||||||
inline bool drawWeatherOnDisplay(long howLong) {
|
|
||||||
#ifdef YA_WEATHER_DRAW
|
|
||||||
if (display != nullptr) {
|
|
||||||
display->wakeDisplay();
|
|
||||||
#if defined(USE_ALT_DISPLAY) || defined(USE_ALT_DISPlAY)
|
|
||||||
if (display->canDraw()) display->overlay(firstWeatherLine().c_str(), secondWeatherLine().c_str(), howLong); // WLEDMM bugfix
|
|
||||||
#else
|
|
||||||
display->overlay(firstWeatherLine().c_str(), secondWeatherLine().c_str(), howLong);
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// WLED lyfecycle
|
// WLED lyfecycle
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
#ifdef YA_WEATHER_DRAW
|
|
||||||
display = (FourLineDisplayUsermod*) usermods.lookup(USERMOD_ID_FOUR_LINE_DISP);
|
|
||||||
#endif
|
|
||||||
initDone = true;
|
initDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user