Update touch drivers

This commit is contained in:
fvanroie 2021-03-10 16:19:46 +01:00
parent 2d44ff7aa4
commit 93f09dc7df
8 changed files with 129 additions and 151 deletions

View File

@ -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"
]
}

View File

@ -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
// }

View File

@ -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

View File

@ -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

View 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

View File

@ -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 <SDL2/SDL.h>
#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

View File

@ -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
#endif // ARDUINO
#endif // HASP_TFTESPI_DRIVER_H

View File

@ -26,10 +26,7 @@
#include "hasplib.h"
#if defined(WINDOWS) || defined(POSIX)
#include "display/monitor.h"
#include "indev/mouse.h"
#endif
//#include "tpcal.h"