Bugfixing and refactoring - proper menu icons

This commit is contained in:
jpirnay
2026-04-03 11:03:10 +02:00
parent adc4efa9e6
commit 01d05e654d
14 changed files with 466 additions and 490 deletions
+14 -129
View File
@@ -1,104 +1,17 @@
#include "WeatherIcons.h"
#include "WeatherIcons48.h"
#include "WeatherIconsLarge.h"
// Weather icon glyph source attribution:
// https://github.com/erikflowers/weather-icons
// Large icons are provided by generated WI48_* arrays in WeatherIcons48.h.
// Large icons are provided by generated WI_LARGE_* arrays in WeatherIconsLarge.h.
// These large icons are 64x64, and the code uses WEATHER_ICON_SIZE=64.
// ============================================================================
// 24x24 Small Weather Icons (1-bit, MSB-first)
// Each row = 24 pixels = 3 bytes. Total = 24 * 3 = 72 bytes per icon.
// ============================================================================
#if WEATHER_ENABLE_SMALL_ICONS
// clang-format off
// Small Clear Day - Sun
static const uint8_t ICON_CLEAR_DAY_24[] = {
0xFF,0xFF,0xFF, 0xFF,0xE7,0xFF, 0xFF,0xE7,0xFF, 0xFF,0xE7,0xFF,
0xF3,0xE7,0xCF, 0xF9,0x00,0x9F, 0xFF,0x00,0xFF, 0xFE,0x00,0x7F,
0xFC,0x00,0x3F, 0xFC,0x00,0x3F, 0xE0,0x00,0x07, 0xE0,0x00,0x07,
0xE0,0x00,0x07, 0xE0,0x00,0x07, 0xFC,0x00,0x3F, 0xFC,0x00,0x3F,
0xFE,0x00,0x7F, 0xFF,0x00,0xFF, 0xF9,0x00,0x9F, 0xF3,0xE7,0xCF,
0xFF,0xE7,0xFF, 0xFF,0xE7,0xFF, 0xFF,0xE7,0xFF, 0xFF,0xFF,0xFF,
};
// Small Clear Night - Moon
static const uint8_t ICON_CLEAR_NIGHT_24[] = {
0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xF0,0xFF, 0xFF,0xE0,0x7F,
0xFF,0xC0,0x3F, 0xFF,0x80,0x3F, 0xFF,0x80,0x7F, 0xFF,0x00,0xFF,
0xFF,0x01,0xFF, 0xFF,0x03,0xFF, 0xFF,0x03,0xFF, 0xFF,0x03,0xFF,
0xFF,0x03,0xFF, 0xFF,0x03,0xFF, 0xFF,0x01,0xFF, 0xFF,0x00,0xFF,
0xFF,0x80,0x7F, 0xFF,0x80,0x3F, 0xFF,0xC0,0x3F, 0xFF,0xE0,0x7F,
0xFF,0xF0,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
};
// Small Partly Cloudy
static const uint8_t ICON_PARTLY_CLOUDY_24[] = {
0xFF,0xFF,0xFF, 0xFF,0xE7,0xFF, 0xFB,0xE7,0xDF, 0xFD,0x00,0xBF,
0xFF,0x00,0xFF, 0xFE,0x00,0x7F, 0xFE,0x00,0x7F, 0xFC,0x00,0x3F,
0xFF,0x00,0x7F, 0xFE,0x00,0x3F, 0xFC,0x00,0x1F, 0xF8,0x00,0x0F,
0xF0,0x00,0x0F, 0xF0,0x00,0x07, 0xE0,0x00,0x07, 0xE0,0x00,0x07,
0xE0,0x00,0x07, 0xE0,0x00,0x07, 0xF0,0x00,0x0F, 0xF8,0x00,0x1F,
0xFF,0x00,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
};
// Small Overcast - Cloud
static const uint8_t ICON_OVERCAST_24[] = {
0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
0xFF,0xF0,0xFF, 0xFF,0xE0,0x7F, 0xFF,0xC0,0x3F, 0xFF,0x80,0x1F,
0xFF,0x00,0x1F, 0xFE,0x00,0x0F, 0xFC,0x00,0x07, 0xF8,0x00,0x07,
0xF0,0x00,0x03, 0xE0,0x00,0x03, 0xE0,0x00,0x03, 0xE0,0x00,0x03,
0xE0,0x00,0x03, 0xF0,0x00,0x07, 0xF8,0x00,0x0F, 0xFE,0x00,0x7F,
0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
};
// Small Rain
static const uint8_t ICON_RAIN_24[] = {
0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xF0,0xFF, 0xFF,0xE0,0x7F,
0xFF,0x80,0x1F, 0xFF,0x00,0x0F, 0xFE,0x00,0x07, 0xFC,0x00,0x07,
0xF0,0x00,0x03, 0xE0,0x00,0x03, 0xE0,0x00,0x03, 0xE0,0x00,0x03,
0xF0,0x00,0x07, 0xF8,0x00,0x0F, 0xFF,0x00,0xFF, 0xFF,0xFF,0xFF,
0xFE,0xF7,0xBF, 0xFD,0xEF,0x7F, 0xFD,0xEF,0x7F, 0xFB,0xDF,0x7F,
0xFB,0xDF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
};
// Small Snow
static const uint8_t ICON_SNOW_24[] = {
0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xF0,0xFF, 0xFF,0xE0,0x7F,
0xFF,0x80,0x1F, 0xFF,0x00,0x0F, 0xFE,0x00,0x07, 0xFC,0x00,0x07,
0xF0,0x00,0x03, 0xE0,0x00,0x03, 0xE0,0x00,0x03, 0xE0,0x00,0x03,
0xF0,0x00,0x07, 0xF8,0x00,0x0F, 0xFF,0x00,0xFF, 0xFF,0xFF,0xFF,
0xFE,0xF7,0xBF, 0xFF,0x7B,0xDF, 0xFE,0xF7,0xBF, 0xFF,0x7B,0xDF,
0xFE,0xF7,0xBF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
};
// Small Thunderstorm
static const uint8_t ICON_THUNDERSTORM_24[] = {
0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xF0,0xFF, 0xFF,0xE0,0x7F,
0xFF,0x80,0x1F, 0xFF,0x00,0x0F, 0xFE,0x00,0x07, 0xFC,0x00,0x07,
0xF0,0x00,0x03, 0xE0,0x00,0x03, 0xE0,0x00,0x03, 0xE0,0x00,0x03,
0xF0,0x00,0x07, 0xF8,0x00,0x0F, 0xFF,0x00,0xFF, 0xFF,0xFF,0xFF,
0xFF,0xF1,0xFF, 0xFF,0xE3,0xFF, 0xFF,0xC0,0xFF, 0xFF,0xF1,0xFF,
0xFF,0xE3,0xFF, 0xFF,0xC7,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
};
// Small Fog
static const uint8_t ICON_FOG_24[] = {
0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xF0,0x00,0x0F, 0xE0,0x00,0x07,
0xF0,0x00,0x0F, 0xFF,0xFF,0xFF, 0xF8,0x00,0x1F, 0xF0,0x00,0x0F,
0xF8,0x00,0x1F, 0xFF,0xFF,0xFF, 0xF0,0x00,0x0F, 0xE0,0x00,0x07,
0xF0,0x00,0x0F, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,
};
// clang-format on
#endif // WEATHER_ENABLE_SMALL_ICONS
// ============================================================================
// Lookup functions
// ============================================================================
@@ -106,59 +19,31 @@ static const uint8_t ICON_FOG_24[] = {
const uint8_t* getWeatherIconLarge(WeatherIconType type) {
switch (type) {
case WeatherIconType::CLEAR_DAY:
return WI48_CLEAR_DAY;
return WI_LARGE_CLEAR_DAY;
case WeatherIconType::CLEAR_NIGHT:
return WI48_CLEAR_NIGHT;
return WI_LARGE_CLEAR_NIGHT;
case WeatherIconType::PARTLY_CLOUDY_DAY:
return WI48_PARTLY_CLOUDY_DAY;
return WI_LARGE_PARTLY_CLOUDY_DAY;
case WeatherIconType::PARTLY_CLOUDY_NIGHT:
return WI48_PARTLY_CLOUDY_NIGHT;
return WI_LARGE_PARTLY_CLOUDY_NIGHT;
case WeatherIconType::OVERCAST:
return WI48_OVERCAST;
return WI_LARGE_OVERCAST;
case WeatherIconType::FOG:
return WI48_FOG;
return WI_LARGE_FOG;
case WeatherIconType::DRIZZLE:
return WI48_DRIZZLE;
return WI_LARGE_DRIZZLE;
case WeatherIconType::RAIN:
case WeatherIconType::SHOWERS:
return WI48_RAIN;
return WI_LARGE_RAIN;
case WeatherIconType::SNOW:
return WI48_SNOW;
return WI_LARGE_SNOW;
case WeatherIconType::THUNDERSTORM:
return WI48_THUNDERSTORM;
return WI_LARGE_THUNDERSTORM;
default:
return WI48_OVERCAST;
return WI_LARGE_OVERCAST;
}
}
#if WEATHER_ENABLE_SMALL_ICONS
const uint8_t* getWeatherIconSmall(WeatherIconType type) {
switch (type) {
case WeatherIconType::CLEAR_DAY:
return ICON_CLEAR_DAY_24;
case WeatherIconType::CLEAR_NIGHT:
return ICON_CLEAR_NIGHT_24;
case WeatherIconType::PARTLY_CLOUDY_DAY:
case WeatherIconType::PARTLY_CLOUDY_NIGHT:
return ICON_PARTLY_CLOUDY_24;
case WeatherIconType::OVERCAST:
return ICON_OVERCAST_24;
case WeatherIconType::FOG:
return ICON_FOG_24;
case WeatherIconType::DRIZZLE:
case WeatherIconType::RAIN:
case WeatherIconType::SHOWERS:
return ICON_RAIN_24;
case WeatherIconType::SNOW:
return ICON_SNOW_24;
case WeatherIconType::THUNDERSTORM:
return ICON_THUNDERSTORM_24;
default:
return ICON_OVERCAST_24;
}
}
#endif // WEATHER_ENABLE_SMALL_ICONS
const char* getWindDirectionText(int degrees) {
// Normalize to 0-360
degrees = ((degrees % 360) + 360) % 360;