diff --git a/src/drv/hasp_drv_display.cpp b/src/drv/hasp_drv_display.cpp index c0b569ed..5cf555da 100644 --- a/src/drv/hasp_drv_display.cpp +++ b/src/drv/hasp_drv_display.cpp @@ -1,31 +1,31 @@ /* 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" +// #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 -} +// 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: */ +// /* 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 +// /* 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 index 78bdf4c2..1a9b0a37 100644 --- a/src/drv/hasp_drv_display.h +++ b/src/drv/hasp_drv_display.h @@ -1,7 +1,7 @@ /* MIT License - Copyright (c) 2019-2021 Francis Van Roie For full license information read the LICENSE file in the project folder */ -#ifndef HASP_DRV_DISPLAY_H +#if 0 // ndef HASP_DRV_DISPLAY_H #define HASP_DRV_DISPLAY_H #include "lvgl.h" diff --git a/src/drv/hasp_drv_touch.cpp b/src/drv/hasp_drv_touch.cpp index 446018b6..da3a80ee 100644 --- a/src/drv/hasp_drv_touch.cpp +++ b/src/drv/hasp_drv_touch.cpp @@ -3,6 +3,7 @@ #include "hasp_drv_touch.h" #include "hasp/hasp.h" +#include "drv/tft_driver.h" #include "lvgl.h" #if TOUCH_DRIVER == 2046 @@ -74,7 +75,7 @@ static inline bool drv_touchpad_getXY(int16_t* touchX, int16_t* touchY) int16_t normal_x; int16_t normal_y; #if TOUCH_DRIVER == 2046 // XPT2046 Resistive touch panel driver - touched = tft_espi_get_touch(&normal_x, &normal_y, 300u); + touched = haspTft.tft.getTouch((uint16_t*)&normal_x, (uint16_t*)&normal_y, 20); #elif TOUCH_DRIVER == 0x2046B touched = XPT2046_getXY(&normal_x, &normal_y, true); diff --git a/src/drv/tft_driver_tftespi.h b/src/drv/tft_driver_tftespi.h index 63931c0a..40da4274 100644 --- a/src/drv/tft_driver_tftespi.h +++ b/src/drv/tft_driver_tftespi.h @@ -23,6 +23,8 @@ namespace dev { class TftEspi : BaseTft { public: + TFT_eSPI tft; + void init(int w, int h); void show_info(); void splashscreen(); @@ -34,8 +36,6 @@ class TftEspi : BaseTft { bool is_driver_pin(uint8_t pin); private: - TFT_eSPI tft; - void tftOffsetInfo(uint8_t pin, uint8_t x_offset, uint8_t y_offset) { if(x_offset != 0) { diff --git a/src/drv/tft_espi_drv.cpp b/src/drv/tft_espi_drv.cpp index d005a380..9fdc66c6 100644 --- a/src/drv/tft_espi_drv.cpp +++ b/src/drv/tft_espi_drv.cpp @@ -8,12 +8,42 @@ #include "hal/hasp_hal.h" // for halGpioName() #include "dev/device.h" +#include "drv/tft_driver.h" #include "tft_espi_drv.h" #include "ArduinoLog.h" #include "hasp_macro.h" -#if USE_TFT_ESPI != 0 +#if defined(TOUCH_CS) + +void tft_espi_calibrate(uint16_t* calData) +{ + haspTft.tft.fillScreen(TFT_BLACK); + haspTft.tft.setCursor(20, 0); + haspTft.tft.setTextFont(1); + haspTft.tft.setTextSize(1); + haspTft.tft.setTextColor(TFT_WHITE, TFT_BLACK); + + // tft.println(PSTR("Touch corners as indicated")); + + haspTft.tft.setTextFont(1); + delay(500); + haspTft.tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15); + haspTft.tft.setTouch(calData); +} + +void tft_espi_set_touch(uint16_t* calData) +{ + haspTft.tft.setTouch(calData); +} + +bool tft_espi_get_touch(int16_t* touchX, int16_t* touchY, uint16_t threshold) +{ + return haspTft.tft.getTouch((uint16_t*)touchX, (uint16_t*)touchY, threshold); +} +#endif + +#if 0 // USE_TFT_ESPI != 0 #include #include "TFT_eSPI.h" diff --git a/src/hasp_gui.cpp b/src/hasp_gui.cpp index 0a9ef0b0..a95a48b3 100644 --- a/src/hasp_gui.cpp +++ b/src/hasp_gui.cpp @@ -15,8 +15,9 @@ #include "drv/tft_driver.h" #include "dev/device.h" -#include "drv/hasp_drv_display.h" +//#include "drv/hasp_drv_display.h" #include "drv/hasp_drv_touch.h" +#include "drv/tft_espi_drv.h" #include "hasp_debug.h" #include "hasp_config.h" @@ -196,7 +197,7 @@ void guiSetup(void) // _lv_fs_init(); // lvgl File System -- not neaded, it done in lv_init() when LV_USE_FILESYSTEM is set LOG_VERBOSE(TAG_LVGL, F("Filesystem : Enabled")); lv_fs_if_init(); // auxilary file system drivers - filesystem_list_path("S:/"); + filesystem_list_path("S:/fs/"); #else LOG_VERBOSE(TAG_LVGL, F("Filesystem : Disabled")); #endif @@ -626,4 +627,4 @@ void guiTakeScreenshot() LOG_ERROR(TAG_GUI, F("Data sent does not match header size")); } } -#endif \ No newline at end of file +#endif