mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-19 09:16:41 +00:00
Update touch drivers
This commit is contained in:
parent
2d44ff7aa4
commit
93f09dc7df
@ -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
|
|
||||||
// }
|
|
@ -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
|
|
@ -7,6 +7,7 @@
|
|||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
|
|
||||||
namespace dev {
|
namespace dev {
|
||||||
@ -36,19 +37,19 @@ class BaseTft {
|
|||||||
} // namespace dev
|
} // namespace dev
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
#warning Building for ESP32 Devices
|
#warning Building for ESP32 Tfts
|
||||||
#include "tft_driver_tftespi.h"
|
#include "tft_driver_tftespi.h"
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
#warning Building for ESP8266 Devices
|
#warning Building for ESP8266 Tfts
|
||||||
#include "tft_driver_tftespi.h"
|
#include "tft_driver_tftespi.h"
|
||||||
#elif defined(STM32F4)
|
#elif defined(STM32F4)
|
||||||
#warning Building for STM32F4xx Devices
|
#warning Building for STM32F4xx Tfts
|
||||||
#include "tft_driver_tftespi.h"
|
#include "tft_driver_tftespi.h"
|
||||||
#elif defined(WINDOWS) || defined(POSIX)
|
#elif defined(WINDOWS) || defined(POSIX)
|
||||||
#warning Building for Win32 Devices
|
#warning Building for SDL2
|
||||||
#include "tft_driver_sdl2.h"
|
#include "tft_driver_sdl2.h"
|
||||||
#else
|
#else
|
||||||
#warning Building for Generic Devices
|
#warning Building for Generic Tfts
|
||||||
using dev::BaseTft;
|
using dev::BaseTft;
|
||||||
extern dev::BaseTft haspTft;
|
extern dev::BaseTft haspTft;
|
||||||
#endif
|
#endif
|
||||||
|
96
src/drv/tft_driver_sdl2.cpp
Normal file
96
src/drv/tft_driver_sdl2.cpp
Normal file
@ -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 <SDL2/SDL.h>
|
||||||
|
|
||||||
|
#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
|
@ -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 */
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
#ifndef HASP_SDL2_DRIVER_H
|
#ifndef HASP_SDL2_DRIVER_H
|
||||||
#define HASP_SDL2_DRIVER_H
|
#define HASP_SDL2_DRIVER_H
|
||||||
|
|
||||||
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
#include "display/monitor.h"
|
|
||||||
#include "indev/mouse.h"
|
|
||||||
|
|
||||||
#include "tft_driver.h"
|
#include "tft_driver.h"
|
||||||
#include "dev/device.h"
|
#include "indev/mouse.h"
|
||||||
#include "hasp_debug.h"
|
|
||||||
|
|
||||||
//#include "bootscreen.h" // Sketch tab header for xbm images
|
|
||||||
|
|
||||||
namespace dev {
|
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 {
|
class TftSdl2 : BaseTft {
|
||||||
public:
|
public:
|
||||||
void init(int w, int h)
|
void init(int w, int h);
|
||||||
{
|
void show_info();
|
||||||
|
void splashscreen();
|
||||||
// Workaround for sdl2 `-m32` crash
|
void set_rotation(uint8_t rotation);
|
||||||
// https://bugs.launchpad.net/ubuntu/+source/libsdl2/+bug/1775067/comments/7
|
void set_invert(bool invert);
|
||||||
#ifndef WIN32
|
static void flush_pixels(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p);
|
||||||
setenv("DBUS_FATAL_WARNINGS", "0", 1);
|
bool is_driver_pin(uint8_t pin);
|
||||||
#endif
|
const char* get_tft_model();
|
||||||
|
|
||||||
/* 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";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dev
|
} // namespace dev
|
||||||
@ -98,4 +29,6 @@ class TftSdl2 : BaseTft {
|
|||||||
using dev::TftSdl2;
|
using dev::TftSdl2;
|
||||||
extern dev::TftSdl2 haspTft;
|
extern dev::TftSdl2 haspTft;
|
||||||
|
|
||||||
#endif
|
#endif // defined(WINDOWS) || defined(POSIX)
|
||||||
|
|
||||||
|
#endif // HASP_SDL2_DRIVER_H
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "TFT_eSPI.h"
|
#include "TFT_eSPI.h"
|
||||||
@ -64,4 +63,6 @@ class TftEspi : BaseTft {
|
|||||||
using dev::TftEspi;
|
using dev::TftEspi;
|
||||||
extern dev::TftEspi haspTft;
|
extern dev::TftEspi haspTft;
|
||||||
|
|
||||||
#endif
|
#endif // ARDUINO
|
||||||
|
|
||||||
|
#endif // HASP_TFTESPI_DRIVER_H
|
@ -26,10 +26,7 @@
|
|||||||
|
|
||||||
#include "hasplib.h"
|
#include "hasplib.h"
|
||||||
|
|
||||||
#if defined(WINDOWS) || defined(POSIX)
|
|
||||||
#include "display/monitor.h"
|
|
||||||
#include "indev/mouse.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#include "tpcal.h"
|
//#include "tpcal.h"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user