diff options
Diffstat (limited to 'hal/api.cpp')
-rw-r--r-- | hal/api.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/hal/api.cpp b/hal/api.cpp index 92b3cd1..f15c4ec 100644 --- a/hal/api.cpp +++ b/hal/api.cpp @@ -1,10 +1,15 @@ #include <stdio.h> +#ifndef SDL2_BUILD #include "pico/stdlib.h" extern "C" { #include "hardware/rtc.h" } +#else +#include "sdl2/display.hpp" +#endif #include "api.hpp" +#include "../buttons.hpp" #include "../init.hpp" #include "../globals.hpp" @@ -35,6 +40,7 @@ void Api::display_set_contrast(unsigned char contrast) { int Api::display_write_string(int iScrollX, int x, int y, const char *szMsg, int iSize, int bInvert, int bRender) { oledWriteString(&m_oled, iScrollX, x, y, szMsg, iSize, bInvert, 0); m_writebb_needed = true; + return 0; } void Api::display_fill(unsigned char ucData, int bRender) { @@ -60,10 +66,15 @@ void Api::display_write_buffer(uint8_t *pBuffer) { oledDumpBuffer(&m_oled, pBuffer); } -void Api::display_write_backbuffer() { +bool Api::display_write_backbuffer() { +#ifndef SDL2_BUILD if (m_writebb_needed) oledDumpBuffer(&m_oled, m_ucBuffer); m_writebb_needed = false; + return false; +#else + return m_sdl_display.update_display(m_ucBuffer); +#endif } int Api::display_write_pixel(int x, int y, unsigned char ucColor, int bRender) { @@ -284,7 +295,7 @@ bool Api::gui_footer_text(std::string text, int offset_x, int offset_row, bool i oledRectangle(&m_oled, 0,56-offset_row*8, 127,64-offset_row*8, invert, 1); m_writebb_needed = true; } - oledWriteString(&m_oled, 0,offset_x,7-offset_row, text.c_str(), font, invert, 0); + return oledWriteString(&m_oled, 0,offset_x,7-offset_row, text.c_str(), font, invert, 0); } bool Api::gui_header_text(std::string text, int offset_x, int offset_row, bool invert, bool no_bg) { @@ -305,7 +316,7 @@ bool Api::gui_header_text(std::string text, int offset_x, int offset_row, bool i oledRectangle(&m_oled, 0,0+offset_row*8, 127,8+offset_row*8, invert, 1); m_writebb_needed = true; } - oledWriteString(&m_oled, 0,offset_x,0+offset_row, text.c_str(), font, invert, 0); + return oledWriteString(&m_oled, 0,offset_x,0+offset_row, text.c_str(), font, invert, 0); } bool Api::performance_set(int perf) { @@ -313,11 +324,19 @@ bool Api::performance_set(int perf) { } bool Api::datetime_get(datetime_t *t) { +#ifndef SDL2_BUILD return rtc_get_datetime(t); +#else + return false; +#endif } bool Api::datetime_set(datetime_t *t) { +#ifndef SDL2_BUILD return rtc_set_datetime(t); +#else + return false; +#endif } uint Api::button_last_get() { |