diff options
Diffstat (limited to 'hal/sdl2/display.cpp')
-rw-r--r-- | hal/sdl2/display.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/hal/sdl2/display.cpp b/hal/sdl2/display.cpp index 64b92cd..a5cff6a 100644 --- a/hal/sdl2/display.cpp +++ b/hal/sdl2/display.cpp @@ -1,7 +1,9 @@ #ifdef SDL2_BUILD #include "display.hpp" #include "../../buttons.hpp" +#include "pico/types.h" #include <iostream> +#include <time.h> #define SCREEN_HEIGHT 64 #define SCREEN_WIDTH 128 @@ -43,6 +45,13 @@ SDLDisplay::SDLDisplay() { SDL_SetPaletteColors(m_surface->format->palette, colors, 0, 2); } +SDLDisplay::~SDLDisplay() { + SDL_DestroyTexture(m_texture); + SDL_DestroyRenderer(m_renderer); + SDL_DestroyWindow(m_window); + SDL_Quit(); +} + bool SDLDisplay::process_input() { SDL_Event e; while (SDL_PollEvent(&e) != 0) { @@ -75,11 +84,22 @@ bool SDLDisplay::update_display(const uint8_t* oled_screen) { return false; } -SDLDisplay::~SDLDisplay() { - SDL_DestroyTexture(m_texture); - SDL_DestroyRenderer(m_renderer); - SDL_DestroyWindow(m_window); - SDL_Quit(); +bool SDLDisplay::get_datetime(datetime_t* t) { + // Get current date and time + time_t rawtime; + struct tm* timeinfo; + time(&rawtime); + timeinfo = localtime(&rawtime); + + // Map ISO C tm struct to Pico's datetime_t + t->day = timeinfo->tm_mday; + t->dotw = timeinfo->tm_wday; + t->month = timeinfo->tm_mon; + t->year = timeinfo->tm_year + 1900; + t->hour = timeinfo->tm_hour; + t->min = timeinfo->tm_min; + t->sec = timeinfo->tm_sec; + return true; } unsigned char rorb(unsigned char x, unsigned char n) { |