Update configs to allocate correctly

This commit is contained in:
Tyler Perkins
2021-10-02 14:14:58 -04:00
parent aed9bbc35d
commit 51b9e6401f
9 changed files with 107 additions and 33 deletions

View File

@@ -26,5 +26,8 @@ namespace dashboard::panel {
virtual void draw() = 0;
size_t _time_on_screen = 0;
protected:
SDL_Texture* _texture;
};
}

View File

@@ -14,16 +14,22 @@ using namespace dashboard::panel;
///////////////////////////////////////////////////////////////////////////////
weather::weather(){
std::cerr << "WEATHER CONSTRUCTOR\n";
_time_on_screen = WEATHER_DEFAULT_ON_SCREEN_TIME;
_update_interval = std::chrono::milliseconds{UPDATE_INTERVAL};
_last_update = std::chrono::high_resolution_clock::now();
_rss = rss_utils::rss(WEATHER_URL_SOURCE);
_texture = SDL_CreateTexture(board::getRenderer(),
SDL_PIXELFORMAT_RGBA8888,
SDL_TEXTUREACCESS_TARGET,
SCREEN_WIDTH, SCREEN_HEIGHT);
update();
}
weather::~weather(){
std::cerr << "WEATHER DECONSTRUCTOR\n";
}
///////////////////////////////////////////////////////////////////////////////
@@ -36,10 +42,42 @@ void weather::draw(){
> _update_interval){
//TODO multithread this
update();
update_texture();
}
//TODO add this all to one canvas thing?
//BEGIN GRAPHICS
static SDL_Rect tgt = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT };
//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;
tgt.x = 50;
tgt.y = 50;
@@ -51,23 +89,5 @@ void weather::draw(){
board::getString(_rss.getTitle(),
{ "Roboto_Mono/RobotoMono-Medium.ttf", 24 }), NULL, &tgt );
//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();
//SDL_SetRenderTarget(board::getRenderer(), NULL);
}

View File

@@ -27,6 +27,7 @@ namespace dashboard::panel {
private:
void update();
void update_texture();
rss_utils::rss _rss;
std::chrono::time_point<std::chrono::high_resolution_clock> _last_update;