diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 9a44568a..d304a5ef 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,8 +1,8 @@ -{ - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "ms-vscode.cpptools", - "platformio.platformio-ide" - ] -} +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "ms-vscode.cpptools", + "platformio.platformio-ide" + ] +} diff --git a/src/drv/hasp_drv_display.cpp b/src/drv/hasp_drv_display.cpp deleted file mode 100644 index 5cf555da..00000000 --- a/src/drv/hasp_drv_display.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* MIT License - Copyright (c) 2019-2021 Francis Van Roie - For full license information read the LICENSE file in the project folder */ - -// #include "hasp_drv_display.h" -// #include "tft_espi_drv.h" -// //#include "fsmc_ili9341.h" - -// void drv_display_init(lv_disp_drv_t* disp_drv, uint8_t rotation, bool invert_display) -// { -// /* TFT init */ -// #if defined(USE_FSMC) -// fsmc_ili9341_init(rotation, invert_display); -// disp_drv->flush_cb = fsmc_ili9341_flush; // Normal callback when flushing -// // xpt2046_init(rotation); -// #else -// tft_espi_init(rotation, invert_display); -// disp_drv->flush_cb = tft_espi_flush; // Normal callback when flushing -// #endif -// } - -// /* Callback used for screenshots only: */ - -// /* indirect callback to flush screenshot data to the screen */ -// void drv_display_flush_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p) -// { -// #if defined(USE_FSMC) -// fsmc_ili9341_flush(disp, area, color_p); -// #else -// tft_espi_flush(disp, area, color_p); -// #endif -// } \ No newline at end of file diff --git a/src/drv/hasp_drv_display.h b/src/drv/hasp_drv_display.h deleted file mode 100644 index 1a9b0a37..00000000 --- a/src/drv/hasp_drv_display.h +++ /dev/null @@ -1,19 +0,0 @@ -/* MIT License - Copyright (c) 2019-2021 Francis Van Roie - For full license information read the LICENSE file in the project folder */ - -#if 0 // ndef HASP_DRV_DISPLAY_H -#define HASP_DRV_DISPLAY_H - -#include "lvgl.h" - -// Select Display Driver -#if defined(USE_FSMC) -#include "fsmc_ili9341.h" -#else -#include "tft_espi_drv.h" -#endif - -void drv_display_init(lv_disp_drv_t* disp_drv, uint8_t rotation, bool invert_display); -void drv_display_flush_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p); - -#endif \ No newline at end of file diff --git a/src/drv/tft_driver.h b/src/drv/tft_driver.h index 07d79b7a..52a25f5d 100644 --- a/src/drv/tft_driver.h +++ b/src/drv/tft_driver.h @@ -7,6 +7,7 @@ #ifdef ARDUINO #include "Arduino.h" #endif + #include "lvgl.h" namespace dev { @@ -36,19 +37,19 @@ class BaseTft { } // namespace dev #if defined(ESP32) -#warning Building for ESP32 Devices +#warning Building for ESP32 Tfts #include "tft_driver_tftespi.h" #elif defined(ESP8266) -#warning Building for ESP8266 Devices +#warning Building for ESP8266 Tfts #include "tft_driver_tftespi.h" #elif defined(STM32F4) -#warning Building for STM32F4xx Devices +#warning Building for STM32F4xx Tfts #include "tft_driver_tftespi.h" #elif defined(WINDOWS) || defined(POSIX) -#warning Building for Win32 Devices +#warning Building for SDL2 #include "tft_driver_sdl2.h" #else -#warning Building for Generic Devices +#warning Building for Generic Tfts using dev::BaseTft; extern dev::BaseTft haspTft; #endif diff --git a/src/drv/tft_driver_sdl2.cpp b/src/drv/tft_driver_sdl2.cpp new file mode 100644 index 00000000..b0079ec2 --- /dev/null +++ b/src/drv/tft_driver_sdl2.cpp @@ -0,0 +1,96 @@ +/* MIT License - Copyright (c) 2019-2021 Francis Van Roie + For full license information read the LICENSE file in the project folder */ + +#if defined(WINDOWS) || defined(POSIX) + +#include "lvgl.h" +#include + +#include "display/monitor.h" +#include "indev/mouse.h" + +#include "tft_driver_sdl2.h" + +#include "dev/device.h" +#include "hasp_debug.h" + +//#include "bootscreen.h" // Sketch tab header for xbm images + +namespace dev { + +/** + * A task to measure the elapsed time for LittlevGL + * @param data unused + * @return never return + */ +static int tick_thread(void* data) +{ + (void)data; + + while(1) { + SDL_Delay(5); /*Sleep for 5 millisecond*/ + lv_tick_inc(5); /*Tell LittelvGL that 5 milliseconds were elapsed*/ + } + + return 0; +} + + void TftSdl2::init(int w, int h) + { + +// Workaround for sdl2 `-m32` crash +// https://bugs.launchpad.net/ubuntu/+source/libsdl2/+bug/1775067/comments/7 +#ifndef WIN32 + setenv("DBUS_FATAL_WARNINGS", "0", 1); +#endif + + /* Add a display + * Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/ + monitor_init(); + monitor_title(haspDevice.get_hostname()); + + /* Add the mouse as input device + * Use the 'mouse' driver which reads the PC's mouse*/ + mouse_init(); + + /* Tick init. + * You have to call 'lv_tick_inc()' in periodically to inform LittelvGL about how much time were elapsed + * Create an SDL thread to do this*/ + SDL_CreateThread(tick_thread, "tick", NULL); + } + void TftSdl2::show_info() + { + SDL_version linked; + SDL_GetVersion(&linked); + LOG_VERBOSE(TAG_TFT, F("SDL2 : v%d.%d.%d"), linked.major, linked.minor, linked.patch); + LOG_VERBOSE(TAG_TFT, F("Driver : SDL2")); + } + + void TftSdl2::splashscreen() + { + // tft.fillScreen(TFT_DARKCYAN); + // int x = (tft.width() - logoWidth) / 2; + // int y = (tft.height() - logoHeight) / 2; + // tft.drawXBitmap(x, y, bootscreen, logoWidth, logoHeight, TFT_WHITE); + } + void TftSdl2::set_rotation(uint8_t rotation) + {} + void set_invert(bool invert) + {} + static void TftSdl2::flush_pixels(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p) + { + monitor_flush(disp, area, color_p); + } + bool TftSdl2:is_driver_pin(uint8_t pin) + { + return false; + } + const char* TftSdl2::get_tft_model() + { + return "SDL2"; + } + +} // namespace dev + +dev::TftSdl2 haspTft; +#endif \ No newline at end of file diff --git a/src/drv/tft_driver_sdl2.h b/src/drv/tft_driver_sdl2.h index fdab19bb..47cfe712 100644 --- a/src/drv/tft_driver_sdl2.h +++ b/src/drv/tft_driver_sdl2.h @@ -1,96 +1,27 @@ -/* MIT License - Copyright (c) 2019-2021 Francis Van Roie + /* MIT License - Copyright (c) 2019-2021 Francis Van Roie For full license information read the LICENSE file in the project folder */ #ifndef HASP_SDL2_DRIVER_H #define HASP_SDL2_DRIVER_H +#if defined(WINDOWS) || defined(POSIX) + #include "lvgl.h" -#include - -#include "display/monitor.h" -#include "indev/mouse.h" - #include "tft_driver.h" -#include "dev/device.h" -#include "hasp_debug.h" - -//#include "bootscreen.h" // Sketch tab header for xbm images +#include "indev/mouse.h" namespace dev { -/** - * A task to measure the elapsed time for LittlevGL - * @param data unused - * @return never return - */ -static int tick_thread(void* data) -{ - (void)data; - - while(1) { - SDL_Delay(5); /*Sleep for 5 millisecond*/ - lv_tick_inc(5); /*Tell LittelvGL that 5 milliseconds were elapsed*/ - } - - return 0; -} - class TftSdl2 : BaseTft { public: - void init(int w, int h) - { - -// Workaround for sdl2 `-m32` crash -// https://bugs.launchpad.net/ubuntu/+source/libsdl2/+bug/1775067/comments/7 -#ifndef WIN32 - setenv("DBUS_FATAL_WARNINGS", "0", 1); -#endif - - /* Add a display - * Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/ - monitor_init(); - monitor_title(haspDevice.get_hostname()); - - /* Add the mouse as input device - * Use the 'mouse' driver which reads the PC's mouse*/ - mouse_init(); - - /* Tick init. - * You have to call 'lv_tick_inc()' in periodically to inform LittelvGL about how much time were elapsed - * Create an SDL thread to do this*/ - SDL_CreateThread(tick_thread, "tick", NULL); - } - void show_info() - { - SDL_version linked; - SDL_GetVersion(&linked); - LOG_VERBOSE(TAG_TFT, F("SDL2 : v%d.%d.%d"), linked.major, linked.minor, linked.patch); - LOG_VERBOSE(TAG_TFT, F("Driver : SDL2")); - } - - void splashscreen() - { - // tft.fillScreen(TFT_DARKCYAN); - // int x = (tft.width() - logoWidth) / 2; - // int y = (tft.height() - logoHeight) / 2; - // tft.drawXBitmap(x, y, bootscreen, logoWidth, logoHeight, TFT_WHITE); - } - void set_rotation(uint8_t rotation) - {} - void set_invert(bool invert) - {} - static void flush_pixels(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p) - { - monitor_flush(disp, area, color_p); - } - bool is_driver_pin(uint8_t pin) - { - return false; - } - const char* get_tft_model() - { - return "SDL2"; - } + void init(int w, int h); + void show_info(); + void splashscreen(); + void set_rotation(uint8_t rotation); + void set_invert(bool invert); + static void flush_pixels(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p); + bool is_driver_pin(uint8_t pin); + const char* get_tft_model(); }; } // namespace dev @@ -98,4 +29,6 @@ class TftSdl2 : BaseTft { using dev::TftSdl2; extern dev::TftSdl2 haspTft; -#endif +#endif // defined(WINDOWS) || defined(POSIX) + +#endif // HASP_SDL2_DRIVER_H diff --git a/src/drv/tft_driver_tftespi.h b/src/drv/tft_driver_tftespi.h index 7bc88004..05e21792 100644 --- a/src/drv/tft_driver_tftespi.h +++ b/src/drv/tft_driver_tftespi.h @@ -6,7 +6,6 @@ #ifdef ARDUINO #include "Arduino.h" -#endif #include "lvgl.h" #include "TFT_eSPI.h" @@ -64,4 +63,6 @@ class TftEspi : BaseTft { using dev::TftEspi; extern dev::TftEspi haspTft; -#endif \ No newline at end of file +#endif // ARDUINO + +#endif // HASP_TFTESPI_DRIVER_H \ No newline at end of file diff --git a/src/hasp_gui.cpp b/src/hasp_gui.cpp index a714124c..ad9e7ba2 100644 --- a/src/hasp_gui.cpp +++ b/src/hasp_gui.cpp @@ -26,10 +26,7 @@ #include "hasplib.h" -#if defined(WINDOWS) || defined(POSIX) -#include "display/monitor.h" -#include "indev/mouse.h" -#endif + //#include "tpcal.h"