From 5ffbd18d8b015b3b0952ae31d485c1667121f338 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Tue, 16 Feb 2021 17:02:49 +0100 Subject: [PATCH] Xplatform changes --- lib/ArduinoLog/ArduinoLog.cpp | 58 ++++++++++++++++++--------------- lib/lv_fs_if/lv_fs_spiffs.cpp | 4 +++ lib/lv_lib_zifont/lv_zifont.cpp | 5 +++ src/main_arduino.cpp | 3 +- src/main_windows.cpp | 1 + src/mouse_cursor_icon.c | 1 - 6 files changed, 43 insertions(+), 29 deletions(-) diff --git a/lib/ArduinoLog/ArduinoLog.cpp b/lib/ArduinoLog/ArduinoLog.cpp index d3174f52..af50c24f 100644 --- a/lib/ArduinoLog/ArduinoLog.cpp +++ b/lib/ArduinoLog/ArduinoLog.cpp @@ -29,85 +29,87 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "ArduinoLog.h" +#ifdef ARDUINO + + #include "ArduinoLog.h" void Logging::begin(int level, bool showLevel) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING setLevel(0, level); setLevel(1, level); setLevel(2, level); setShowLevel(0, showLevel); -#endif + #endif } void Logging::registerOutput(uint8_t slot, Print * logOutput, int level, bool showLevel) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING if(slot >= 3) return; setLevel(slot, level); setShowLevel(slot, showLevel); _logOutput[slot] = logOutput; -#endif + #endif } void Logging::unregisterOutput(uint8_t slot) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING if(slot >= 3) return; _logOutput[slot] = NULL; -#endif + #endif } void Logging::setLevel(uint8_t slot, int level) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING _level[slot] = constrain(level, LOG_LEVEL_SILENT, LOG_LEVEL_OUTPUT); -#endif + #endif } int Logging::getLevel(uint8_t slot) const { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING return _level[slot]; -#else + #else return 0; -#endif + #endif } void Logging::setShowLevel(uint8_t slot, bool showLevel) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING _showLevel[slot] = showLevel; -#endif + #endif } bool Logging::getShowLevel(uint8_t slot) const { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING return _showLevel[slot]; -#else + #else return false; -#endif + #endif } void Logging::setPrefix(printfunction f) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING _prefix = f; -#endif + #endif } void Logging::setSuffix(printfunction f) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING _suffix = f; -#endif + #endif } void Logging::print(Print * logOutput, const __FlashStringHelper * format, va_list args) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING PGM_P p = reinterpret_cast(format); char c = pgm_read_byte(p++); for(; c != 0; c = pgm_read_byte(p++)) { @@ -118,12 +120,12 @@ void Logging::print(Print * logOutput, const __FlashStringHelper * format, va_li logOutput->print(c); } } -#endif + #endif } void Logging::print(Print * logOutput, const char * format, va_list args) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING for(; *format != 0; ++format) { if(*format == '%') { ++format; @@ -132,12 +134,12 @@ void Logging::print(Print * logOutput, const char * format, va_list args) logOutput->print(*format); } } -#endif + #endif } void Logging::printFormat(Print * logOutput, const char format, va_list * args) { -#ifndef DISABLE_LOGGING + #ifndef DISABLE_LOGGING if(format == '%') { logOutput->print(format); } else if(format == 's') { @@ -179,7 +181,9 @@ void Logging::printFormat(Print * logOutput, const char format, va_list * args) logOutput->print(F("false")); } } -#endif + #endif } Logging Log = Logging(); + +#endif // ARDUINO \ No newline at end of file diff --git a/lib/lv_fs_if/lv_fs_spiffs.cpp b/lib/lv_fs_if/lv_fs_spiffs.cpp index e4fe5e82..c8e8fb95 100644 --- a/lib/lv_fs_if/lv_fs_spiffs.cpp +++ b/lib/lv_fs_if/lv_fs_spiffs.cpp @@ -6,6 +6,8 @@ /********************* * INCLUDES *********************/ +#ifdef ARDUINO + #include #include "lv_fs_if.h" #include "lv_fs_spiffs.h" @@ -504,3 +506,5 @@ static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p) #endif /*LV_USE_FS_IF*/ #endif /*LV_FS_IF_SPIFFS*/ + +#endif /*ARDUINO*/ \ No newline at end of file diff --git a/lib/lv_lib_zifont/lv_zifont.cpp b/lib/lv_lib_zifont/lv_zifont.cpp index 90e586b1..25bfe0b4 100644 --- a/lib/lv_lib_zifont/lv_zifont.cpp +++ b/lib/lv_lib_zifont/lv_zifont.cpp @@ -1,6 +1,9 @@ /********************* * INCLUDES *********************/ + +#ifndef WINDOWS + #include #include @@ -557,6 +560,8 @@ static inline void IRAM_ATTR colorsAdd(uint8_t * charBitmap_p, uint8_t color1, u } } +#endif + /* void printPixel(uint8_t pixel) { diff --git a/src/main_arduino.cpp b/src/main_arduino.cpp index b8eb8087..2a68517f 100644 --- a/src/main_arduino.cpp +++ b/src/main_arduino.cpp @@ -1,9 +1,10 @@ /* MIT License - Copyright (c) 2020 Francis Van Roie For full license information read the LICENSE file in the project folder */ -#ifdef ARDUINO +#ifndef WINDOWS #include +#include "lvgl.h" #include "hasp_conf.h" // load first #if HASP_USE_CONFIG > 0 diff --git a/src/main_windows.cpp b/src/main_windows.cpp index b3b021cd..56710613 100644 --- a/src/main_windows.cpp +++ b/src/main_windows.cpp @@ -98,6 +98,7 @@ int main(int argv, char ** args) setup(); std::cout << "HSetup OK\n"; + while(1) { SDL_Delay(5); lv_task_handler(); diff --git a/src/mouse_cursor_icon.c b/src/mouse_cursor_icon.c index 14c089a4..1c3a93a8 100644 --- a/src/mouse_cursor_icon.c +++ b/src/mouse_cursor_icon.c @@ -1,4 +1,3 @@ -#include "Arduino.h" #include "lvgl.h" #if 1