Update configs to allocate correctly
This commit is contained in:
parent
aed9bbc35d
commit
51b9e6401f
@ -24,8 +24,9 @@ Depends on
|
|||||||
optional dependencies
|
optional dependencies
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
- rapidxml
|
- Weather/RSS
|
||||||
- libcurl
|
- rapidxml
|
||||||
|
- libcurl
|
||||||
|
|
||||||
Building sdl2 on rpi
|
Building sdl2 on rpi
|
||||||
--------------------
|
--------------------
|
||||||
|
BIN
img/rainy.png
Normal file
BIN
img/rainy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
BIN
img/sunny.png
Normal file
BIN
img/sunny.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 58 KiB |
@ -337,7 +337,6 @@ int board::init(){
|
|||||||
void board::start(){
|
void board::start(){
|
||||||
initConstResources();
|
initConstResources();
|
||||||
//get Panel size
|
//get Panel size
|
||||||
const size_t panel_count = sizeof(PANELS) / sizeof(PANELS[0]);
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
//timing, for dealing with framerates
|
//timing, for dealing with framerates
|
||||||
@ -353,13 +352,12 @@ void board::start(){
|
|||||||
fcount++;
|
fcount++;
|
||||||
|
|
||||||
//check if we can loop back over
|
//check if we can loop back over
|
||||||
if(i > panel_count)
|
if(i > PANELS_LENGTH)
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
//SDL_RenderClear(_renderer);
|
SDL_RenderClear(_renderer);
|
||||||
|
|
||||||
//PLACEHOLDER, cycle color
|
//PLACEHOLDER, cycle color
|
||||||
/*
|
|
||||||
{
|
{
|
||||||
static uint8_t red = 0;
|
static uint8_t red = 0;
|
||||||
static bool up = true;
|
static bool up = true;
|
||||||
@ -379,12 +377,11 @@ void board::start(){
|
|||||||
red --;
|
red --;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
//END PLACEHOLDER
|
//END PLACEHOLDER
|
||||||
|
|
||||||
|
|
||||||
//call draw on the current panel
|
//call draw on the current panel
|
||||||
PANELS[i]->draw();
|
//PANELS[i]->draw();
|
||||||
|
|
||||||
if(fcount % 10 == 0)
|
if(fcount % 10 == 0)
|
||||||
std::cerr << "Frame : " << fcount << "\n";
|
std::cerr << "Frame : " << fcount << "\n";
|
||||||
@ -416,7 +413,7 @@ void board::initConstResources(){
|
|||||||
SDL_Log("Static images directory prefix: %s\n", fullPath.c_str());
|
SDL_Log("Static images directory prefix: %s\n", fullPath.c_str());
|
||||||
SDL_Log("Loading static images into working memory...\n");
|
SDL_Log("Loading static images into working memory...\n");
|
||||||
for(unsigned int i = 0;
|
for(unsigned int i = 0;
|
||||||
i < (sizeof(IMAGE_LOCATIONS)/sizeof(IMAGE_LOCATIONS[0])); ++i){
|
i < IMAGE_LOCATIONS_LENGTH; ++i){
|
||||||
|
|
||||||
SDL_Texture_Wrapper tw(fullPath + IMAGE_LOCATIONS[0]);
|
SDL_Texture_Wrapper tw(fullPath + IMAGE_LOCATIONS[0]);
|
||||||
|
|
||||||
@ -434,7 +431,7 @@ void board::initConstResources(){
|
|||||||
SDL_Log("Static Fonts directory prefix: %s\n", fullPath.c_str());
|
SDL_Log("Static Fonts directory prefix: %s\n", fullPath.c_str());
|
||||||
SDL_Log("Loading fonts into working memory...\n");
|
SDL_Log("Loading fonts into working memory...\n");
|
||||||
for(unsigned int i = 0;
|
for(unsigned int i = 0;
|
||||||
i < (sizeof(FONT_LOCATIONS)/sizeof(FONT_LOCATIONS[0])); ++i){
|
i < FONT_LOCATIONS_LENGTH; ++i){
|
||||||
|
|
||||||
SDL_Font_Wrapper fw(fullPath + FONT_LOCATIONS[0]._name,
|
SDL_Font_Wrapper fw(fullPath + FONT_LOCATIONS[0]._name,
|
||||||
FONT_LOCATIONS[0]._size);
|
FONT_LOCATIONS[0]._size);
|
||||||
@ -449,7 +446,7 @@ void board::initConstResources(){
|
|||||||
std::cerr << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n";
|
std::cerr << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n";
|
||||||
SDL_Log("Loading static strings into working memory...\n");
|
SDL_Log("Loading static strings into working memory...\n");
|
||||||
for(unsigned int i = 0;
|
for(unsigned int i = 0;
|
||||||
i < (sizeof(CONST_STRINGS)/sizeof(CONST_STRINGS[0])); ++i){
|
i < CONST_STRINGS_LENGTH; ++i){
|
||||||
|
|
||||||
SDL_Texture_Wrapper tw(CONST_STRINGS[i]._text,
|
SDL_Texture_Wrapper tw(CONST_STRINGS[i]._text,
|
||||||
{ CONST_STRINGS[i]._font_size._name,
|
{ CONST_STRINGS[i]._font_size._name,
|
||||||
|
49
src/config.cpp
Normal file
49
src/config.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Tyler Perkins
|
||||||
|
// 9-29-21
|
||||||
|
// configuration file
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "config.hpp"
|
||||||
|
|
||||||
|
// PANELS
|
||||||
|
// A list of all panels to be displayed, in order
|
||||||
|
dashboard::panel::panel* PANELS[] = {
|
||||||
|
new dashboard::panel::weather(),
|
||||||
|
};
|
||||||
|
size_t PANELS_LENGTH = sizeof(PANELS)/sizeof(PANELS[0]);
|
||||||
|
|
||||||
|
// IMAGE_LOCATIONS
|
||||||
|
// Locations of all static images used
|
||||||
|
const char* IMAGE_LOCATIONS[] = {
|
||||||
|
"bmp_24.png",
|
||||||
|
//Weather
|
||||||
|
"sunny.png",
|
||||||
|
"rainy.png",
|
||||||
|
};
|
||||||
|
size_t IMAGE_LOCATIONS_LENGTH = sizeof(IMAGE_LOCATIONS)/sizeof(IMAGE_LOCATIONS[0]);
|
||||||
|
|
||||||
|
// FONT_LOCATIONS
|
||||||
|
// Locations of all fonts used
|
||||||
|
//struct FONT_SIZE {
|
||||||
|
// const char* _name;
|
||||||
|
// const size_t _size;
|
||||||
|
//};
|
||||||
|
const FONT_SIZE FONT_LOCATIONS[] = {
|
||||||
|
{ "Roboto_Mono/RobotoMono-Medium.ttf", 24 },
|
||||||
|
};
|
||||||
|
size_t FONT_LOCATIONS_LENGTH = sizeof(FONT_LOCATIONS)/sizeof(FONT_LOCATIONS[0]);
|
||||||
|
|
||||||
|
// CONST_STRINGS
|
||||||
|
// All constant strings
|
||||||
|
//struct FONT_SIZE_STRING {
|
||||||
|
// const char* _text;
|
||||||
|
// const FONT_SIZE _font_size;
|
||||||
|
//};
|
||||||
|
const FONT_SIZE_STRING CONST_STRINGS[] = {
|
||||||
|
//Weather strings
|
||||||
|
{ "Today's Weather", { "Roboto_Mono/RobotoMono-Medium.ttf", 24 } },
|
||||||
|
{ "Sunny" , { "Roboto_Mono/RobotoMono-Medium.ttf", 24 } },
|
||||||
|
{ "Rainy" , { "Roboto_Mono/RobotoMono-Medium.ttf", 24 } },
|
||||||
|
};
|
||||||
|
size_t CONST_STRINGS_LENGTH = sizeof(CONST_STRINGS)/sizeof(CONST_STRINGS[0]);
|
@ -95,6 +95,9 @@ constexpr char DATA_IMG[] = DATA_IMG_;
|
|||||||
// Locations of all static images used
|
// Locations of all static images used
|
||||||
static const char* IMAGE_LOCATIONS[] = {
|
static const char* IMAGE_LOCATIONS[] = {
|
||||||
"bmp_24.png",
|
"bmp_24.png",
|
||||||
|
//Weather
|
||||||
|
"sunny.png",
|
||||||
|
"rainy.png",
|
||||||
};
|
};
|
||||||
|
|
||||||
// FONT_DIR
|
// FONT_DIR
|
||||||
|
@ -26,5 +26,8 @@ namespace dashboard::panel {
|
|||||||
virtual void draw() = 0;
|
virtual void draw() = 0;
|
||||||
|
|
||||||
size_t _time_on_screen = 0;
|
size_t _time_on_screen = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SDL_Texture* _texture;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,22 @@ using namespace dashboard::panel;
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
weather::weather(){
|
weather::weather(){
|
||||||
|
std::cerr << "WEATHER CONSTRUCTOR\n";
|
||||||
_time_on_screen = WEATHER_DEFAULT_ON_SCREEN_TIME;
|
_time_on_screen = WEATHER_DEFAULT_ON_SCREEN_TIME;
|
||||||
_update_interval = std::chrono::milliseconds{UPDATE_INTERVAL};
|
_update_interval = std::chrono::milliseconds{UPDATE_INTERVAL};
|
||||||
_last_update = std::chrono::high_resolution_clock::now();
|
_last_update = std::chrono::high_resolution_clock::now();
|
||||||
_rss = rss_utils::rss(WEATHER_URL_SOURCE);
|
_rss = rss_utils::rss(WEATHER_URL_SOURCE);
|
||||||
|
|
||||||
|
_texture = SDL_CreateTexture(board::getRenderer(),
|
||||||
|
SDL_PIXELFORMAT_RGBA8888,
|
||||||
|
SDL_TEXTUREACCESS_TARGET,
|
||||||
|
SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
weather::~weather(){
|
weather::~weather(){
|
||||||
|
std::cerr << "WEATHER DECONSTRUCTOR\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -36,10 +42,42 @@ void weather::draw(){
|
|||||||
> _update_interval){
|
> _update_interval){
|
||||||
//TODO multithread this
|
//TODO multithread this
|
||||||
update();
|
update();
|
||||||
|
|
||||||
|
update_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO add this all to one canvas thing?
|
static SDL_Rect tgt = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT };
|
||||||
//BEGIN GRAPHICS
|
|
||||||
|
//SDL_RenderCopy(board::getRenderer(), _texture, NULL,
|
||||||
|
//&tgt);
|
||||||
|
|
||||||
|
//TODO add this all to one texture
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Helper functions ///////////////////////////////////////////////////////////
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
///////////////////////////////////////
|
||||||
|
// Update the information of the obj
|
||||||
|
// This DOES NOT update the display
|
||||||
|
void weather::update() {
|
||||||
|
std::cerr << "WEATHER::UPDATE\n";
|
||||||
|
_last_update = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
|
//fetch updates
|
||||||
|
_rss.update();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////
|
||||||
|
// Update the texture that is being
|
||||||
|
// displayed, based on data in
|
||||||
|
// _rss
|
||||||
|
void weather::update_texture(){
|
||||||
|
//SDL_SetRenderTarget(board::getRenderer(), _texture);
|
||||||
|
|
||||||
SDL_Rect tgt;
|
SDL_Rect tgt;
|
||||||
tgt.x = 50;
|
tgt.x = 50;
|
||||||
tgt.y = 50;
|
tgt.y = 50;
|
||||||
@ -51,23 +89,5 @@ void weather::draw(){
|
|||||||
board::getString(_rss.getTitle(),
|
board::getString(_rss.getTitle(),
|
||||||
{ "Roboto_Mono/RobotoMono-Medium.ttf", 24 }), NULL, &tgt );
|
{ "Roboto_Mono/RobotoMono-Medium.ttf", 24 }), NULL, &tgt );
|
||||||
|
|
||||||
|
//SDL_SetRenderTarget(board::getRenderer(), NULL);
|
||||||
|
|
||||||
//END GRAPHICS
|
|
||||||
|
|
||||||
SDL_RenderPresent(board::getRenderer());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Helper functions ///////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void weather::update() {
|
|
||||||
std::cerr << "WEATHER::UPDATE\n";
|
|
||||||
_last_update = std::chrono::high_resolution_clock::now();
|
|
||||||
|
|
||||||
//fetch updates
|
|
||||||
_rss.update();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ namespace dashboard::panel {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void update();
|
void update();
|
||||||
|
void update_texture();
|
||||||
|
|
||||||
rss_utils::rss _rss;
|
rss_utils::rss _rss;
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> _last_update;
|
std::chrono::time_point<std::chrono::high_resolution_clock> _last_update;
|
||||||
|
Loading…
Reference in New Issue
Block a user