Only enable SDL2 driver with USE_MONITOR

This commit is contained in:
Kuba Szczodrzyński 2024-02-06 19:52:23 +01:00
parent a7b558eb33
commit 246f5e3ac2
No known key found for this signature in database
GPG Key ID: 43037AC62A600562
8 changed files with 28 additions and 14 deletions

View File

@ -371,7 +371,9 @@ static WiFiSpiClass WiFi;
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include <stdio.h> #include <stdio.h>
#if USE_MONITOR
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#endif
#define snprintf_P snprintf #define snprintf_P snprintf
#define memcpy_P memcpy #define memcpy_P memcpy
@ -380,7 +382,9 @@ static WiFiSpiClass WiFi;
#define strcpy_P strcpy #define strcpy_P strcpy
#define strstr_P strstr #define strstr_P strstr
#define halRestartMcu() #define halRestartMcu()
#if USE_MONITOR
#define millis SDL_GetTicks #define millis SDL_GetTicks
#endif
#define DEC 10 #define DEC 10
#define HEX 16 #define HEX 16

View File

@ -11,7 +11,9 @@
#include "hasp_conf.h" #include "hasp_conf.h"
#include "hasp_debug.h" #include "hasp_debug.h"
#if USE_MONITOR
#include "display/monitor.h" #include "display/monitor.h"
#endif
namespace dev { namespace dev {
@ -48,8 +50,10 @@ const char* Win32Device::get_hostname()
void Win32Device::set_hostname(const char* hostname) void Win32Device::set_hostname(const char* hostname)
{ {
_hostname = hostname; _hostname = hostname;
#if USE_MONITOR
monitor_title(hostname); monitor_title(hostname);
// SDL_SetWindowTitle(monitor.window, hostname); // SDL_SetWindowTitle(monitor.window, hostname);
#endif
} }
const char* Win32Device::get_core_version() const char* Win32Device::get_core_version()
{ {
@ -112,7 +116,9 @@ void Win32Device::update_backlight()
{ {
uint8_t level = _backlight_power ? _backlight_level : 0; uint8_t level = _backlight_power ? _backlight_level : 0;
if(_backlight_invert) level = 255 - level; if(_backlight_invert) level = 255 - level;
#if USE_MONITOR
monitor_backlight(level); monitor_backlight(level);
#endif
} }
size_t Win32Device::get_free_max_block() size_t Win32Device::get_free_max_block()
@ -152,4 +158,4 @@ long Win32Device::get_uptime()
dev::Win32Device haspDevice; dev::Win32Device haspDevice;
#endif // WINDOWS #endif // WINDOWS

View File

@ -96,4 +96,4 @@ extern dev::Win32Device haspDevice;
#endif // WINDOWS #endif // WINDOWS
#endif // HASP_DEVICE_WINDOWS_H #endif // HASP_DEVICE_WINDOWS_H

View File

@ -77,7 +77,7 @@ class BaseTft {
#elif defined(STM32F7) #elif defined(STM32F7)
#warning Building for STM32F7xx Tfts #warning Building for STM32F7xx Tfts
#include "tft_driver_tftespi.h" #include "tft_driver_tftespi.h"
#elif defined(WINDOWS) || defined(POSIX) #elif USE_MONITOR && (defined(WINDOWS) || defined(POSIX))
// #warning Building for SDL2 // #warning Building for SDL2
#include "tft_driver_sdl2.h" #include "tft_driver_sdl2.h"
#else #else

View File

@ -1,7 +1,7 @@
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie /* MIT License - Copyright (c) 2019-2022 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if defined(WINDOWS) || defined(POSIX) #if USE_MONITOR && (defined(WINDOWS) || defined(POSIX))
#include "hasplib.h" #include "hasplib.h"
#include "lvgl.h" #include "lvgl.h"
@ -115,4 +115,4 @@ const char* TftSdl::get_tft_model()
dev::TftSdl haspTft; dev::TftSdl haspTft;
#endif // WINDOWS || POSIX #endif // WINDOWS || POSIX

View File

@ -6,7 +6,7 @@
#include "tft_driver.h" #include "tft_driver.h"
#if defined(WINDOWS) || defined(POSIX) #if USE_MONITOR && (defined(WINDOWS) || defined(POSIX))
// #warning Building H driver TFT SDL2 // #warning Building H driver TFT SDL2
#include "lvgl.h" #include "lvgl.h"

View File

@ -309,7 +309,7 @@ void guiSetup()
static lv_indev_drv_t indev_drv; static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER; indev_drv.type = LV_INDEV_TYPE_POINTER;
#if defined(WINDOWS) || defined(POSIX) #if USE_MONITOR && (defined(WINDOWS) || defined(POSIX))
indev_drv.read_cb = mouse_read; indev_drv.read_cb = mouse_read;
#else #else
indev_drv.read_cb = gui_touch_read; indev_drv.read_cb = gui_touch_read;

View File

@ -25,7 +25,9 @@
#include "hasplib.h" #include "hasplib.h"
// #include "app_hal.h" // #include "app_hal.h"
#if USE_MONITOR
#include "display/monitor.h" #include "display/monitor.h"
#endif
#include "hasp_debug.h" #include "hasp_debug.h"
#include "hasp_gui.h" #include "hasp_gui.h"
@ -258,12 +260,14 @@ int main(int argc, char* argv[])
} }
#endif #endif
SDL_Init(0); // Needs to be initialized for GetPerfPath
char buf[4096]; // never know how much is needed char buf[4096]; // never know how much is needed
std::cout << "CWD: " << cwd(buf, sizeof buf) << std::endl; std::cout << "CWD: " << cwd(buf, sizeof buf) << std::endl;
#if USE_MONITOR
SDL_Init(0); // Needs to be initialized for GetPerfPath
cd(SDL_GetPrefPath("hasp", "hasp")); cd(SDL_GetPrefPath("hasp", "hasp"));
std::cout << "CWD changed to: " << cwd(buf, sizeof buf) << std::endl;
SDL_Quit(); // We'll properly init later SDL_Quit(); // We'll properly init later
#endif
std::cout << "CWD changed to: " << cwd(buf, sizeof buf) << std::endl;
// Change to preferences dir // Change to preferences dir
std::cout << "\nCommand-line arguments:\n"; std::cout << "\nCommand-line arguments:\n";
@ -376,11 +380,11 @@ int main(int argc, char* argv[])
LOG_TRACE(TAG_MAIN, "main loop completed"); LOG_TRACE(TAG_MAIN, "main loop completed");
#if defined(WINDOWS) #if defined(WINDOWS)
WriteConsole(std_out, "bye\n\n", 3, NULL, NULL); WriteConsole(std_out, "bye\n\n", 3, NULL, NULL);
std::cout << std::endl << std::flush; std::cout << std::endl << std::flush;
fflush(stdout); fflush(stdout);
FreeConsole(); FreeConsole();
exit(0); exit(0);
#endif #endif
return 0; return 0;