Add and show weather icons

This commit is contained in:
Tyler Perkins 2021-12-22 19:14:41 -05:00
parent 036b8a8bc9
commit 6215d7701e
18 changed files with 66 additions and 15 deletions

12
CREDITS.md Normal file
View File

@ -0,0 +1,12 @@
Credits
=======
This project would not be possible without
- Weather Icon set by Laura Reen (thanks for the free high quality icons!)
- https://www.iconfinder.com/iconsets/the-weather-is-nice-today
- Rapidjson (thanks for the fast json parser!)
- https://rapidjson.org
- libcurl (thanks for being the best and most reliable general purpose network
library!)
- https://curl.se/libcurl/

BIN
img/clearday.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
img/clearnight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
img/cloudyday.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
img/cloudynight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
img/humidday.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
img/humidnight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
img/lrainday.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
img/lrainnight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
img/rainday.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
img/rainnight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
img/rainsnow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
img/shower.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
img/snowday.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
img/snownight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -22,10 +22,28 @@ dashboard::panel::panel* OVERLAY = new dashboard::panel::def_overlay();
// Locations of all static images used // Locations of all static images used
const char* IMAGE_LOCATIONS[] = { const char* IMAGE_LOCATIONS[] = {
//"bmp_24.png", //"bmp_24.png",
"wifi.png",
"weather_background.png", //wifi
"wifi.png",
"wifi_background.jpg", "wifi_background.jpg",
//weather
"weather_background.png",
"clearday.png",
"clearnight.png",
"cloudyday.png",
"cloudynight.png",
"humidday.png",
"humidnight.png",
"lrainday.png",
"lrainnight.png",
"rainday.png",
"rainnight.png",
"rainsnow.png",
"shower.png",
"snowday.png",
"snownight.png",
}; };
size_t IMAGE_LOCATIONS_LENGTH = sizeof(IMAGE_LOCATIONS)/sizeof(IMAGE_LOCATIONS[0]); size_t IMAGE_LOCATIONS_LENGTH = sizeof(IMAGE_LOCATIONS)/sizeof(IMAGE_LOCATIONS[0]);

View File

@ -170,6 +170,7 @@ void weather::update_texture(){
SDL_RenderCopy(board::getRenderer(), SDL_RenderCopy(board::getRenderer(),
board::getString(temp.c_str(), board::getString(temp.c_str(),
{ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt); { "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt);
//tommorow's weather //tommorow's weather
@ -202,6 +203,16 @@ void weather::update_texture(){
SDL_RenderCopy(board::getRenderer(), SDL_RenderCopy(board::getRenderer(),
board::getString(temp.c_str(), board::getString(temp.c_str(),
{ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt); { "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt);
//icon
tgt.w = (SCREEN_WIDTH / 3) - 50;
tgt.h = tgt.w;
tgt.y = DEF_OVERLAY_BAR_HEIGHT + 25;
tgt.x = 0;
SDL_RenderCopy(board::getRenderer(),
board::getImage(weather_tommorow->second),
NULL, &tgt);
//day after's weather //day after's weather
TTF_SizeText(board::getFont({ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), TTF_SizeText(board::getFont({ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }),
@ -233,8 +244,17 @@ void weather::update_texture(){
SDL_RenderCopy(board::getRenderer(), SDL_RenderCopy(board::getRenderer(),
board::getString(temp.c_str(), board::getString(temp.c_str(),
{ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt); { "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt);
//icon
tgt.w = (SCREEN_WIDTH / 3) - 50;
tgt.h = tgt.w;
tgt.y = DEF_OVERLAY_BAR_HEIGHT + 25;
tgt.x = (2*SCREEN_WIDTH / 3);
std::cerr << "WEATHER DAY AFTER " << weather_day_after->second << "\n";
std::cerr << board::getImage(weather_day_after->second) << "\n";
SDL_RenderCopy(board::getRenderer(),
board::getImage(weather_day_after->second),
NULL, &tgt);
SDL_SetRenderTarget(board::getRenderer(), NULL); SDL_SetRenderTarget(board::getRenderer(), NULL);
} }

View File

@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include <string> #include <string>
#include "def_overlay_config.hpp"
namespace dashboard::panel { namespace dashboard::panel {
//This will be displayed at the top left on the status bar. Set to a blank //This will be displayed at the top left on the status bar. Set to a blank
@ -41,14 +42,14 @@ namespace dashboard::panel {
{"Clear skies", "clearnight.png"}; {"Clear skies", "clearnight.png"};
const std::pair<std::string, std::string> WEATHER_PCLOUDY_DAY = const std::pair<std::string, std::string> WEATHER_PCLOUDY_DAY =
{"Slightly cloudy", "pcloudyday.png"}; {"Slightly cloudy", "cloudyday.png"};
const std::pair<std::string, std::string> WEATHER_PCLOUDY_NIGHT = const std::pair<std::string, std::string> WEATHER_PCLOUDY_NIGHT =
{"Slightly cloudy", "pcloudynight.png"}; {"Slightly cloudy", "cloudynight.png"};
const std::pair<std::string, std::string> WEATHER_MCLOUDY_DAY = const std::pair<std::string, std::string> WEATHER_MCLOUDY_DAY =
{"Moderately cloudy", "mcloudyday.png"}; {"Moderately cloudy", "cloudyday.png"};
const std::pair<std::string, std::string> WEATHER_MCLOUDY_NIGHT = const std::pair<std::string, std::string> WEATHER_MCLOUDY_NIGHT =
{"Moderately cloudy", "mcloudynight.png"}; {"Moderately cloudy", "cloudynight.png"};
const std::pair<std::string, std::string> WEATHER_CLOUDY_DAY = const std::pair<std::string, std::string> WEATHER_CLOUDY_DAY =
{"Very cloudy", "cloudyday.png"}; {"Very cloudy", "cloudyday.png"};
@ -71,19 +72,19 @@ namespace dashboard::panel {
{"Rain", "rainnight.png"}; {"Rain", "rainnight.png"};
const std::pair<std::string, std::string> WEATHER_OSHOWER_DAY = const std::pair<std::string, std::string> WEATHER_OSHOWER_DAY =
{"Overcast with showers", "oshowerday.png"}; {"Overcast with showers", "shower.png"};
const std::pair<std::string, std::string> WEATHER_OSHOWER_NIGHT = const std::pair<std::string, std::string> WEATHER_OSHOWER_NIGHT =
{"Overcast with showers", "oshowernight.png"}; {"Overcast with showers", "shower.png"};
const std::pair<std::string, std::string> WEATHER_ISHOWER_DAY = const std::pair<std::string, std::string> WEATHER_ISHOWER_DAY =
{"Moderate showers", "ishowerday.png"}; {"Moderate showers", "shower.png"};
const std::pair<std::string, std::string> WEATHER_ISHOWER_NIGHT = const std::pair<std::string, std::string> WEATHER_ISHOWER_NIGHT =
{"Moderate showers", "ishowernight.png"}; {"Moderate showers", "shower.png"};
const std::pair<std::string, std::string> WEATHER_LSNOW_DAY = const std::pair<std::string, std::string> WEATHER_LSNOW_DAY =
{"Light snow", "lsnowday.png"}; {"Light snow", "snowday.png"};
const std::pair<std::string, std::string> WEATHER_LSNOW_NIGHT = const std::pair<std::string, std::string> WEATHER_LSNOW_NIGHT =
{"Light snow", "lsnownight.png"}; {"Light snow", "snownight.png"};
const std::pair<std::string, std::string> WEATHER_SNOW_DAY = const std::pair<std::string, std::string> WEATHER_SNOW_DAY =
{"Moderate snow", "snowday.png"}; {"Moderate snow", "snowday.png"};
@ -91,7 +92,7 @@ namespace dashboard::panel {
{"Moderate snow", "snownight.png"}; {"Moderate snow", "snownight.png"};
const std::pair<std::string, std::string> WEATHER_RAINSNOW_DAY = const std::pair<std::string, std::string> WEATHER_RAINSNOW_DAY =
{"Rain and snow", "rainsnowday.png"}; {"Rain and snow", "rainsnow.png"};
const std::pair<std::string, std::string> WEATHER_RAINSNOW_NIGHT = const std::pair<std::string, std::string> WEATHER_RAINSNOW_NIGHT =
{"Rain and snow", "rainsnownight.png"}; {"Rain and snow", "rainsnow.png"};
} }