Move drivers from the lv_port_esp32 to here
This commit is contained in:
parent
5a32d98f83
commit
08384030b0
69 changed files with 14977 additions and 2 deletions
85
lvgl_touch/FT81x.c
Normal file
85
lvgl_touch/FT81x.c
Normal file
|
@ -0,0 +1,85 @@
|
|||
/**
|
||||
* @file FT81x.c
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "FT81x.h"
|
||||
|
||||
#include "../lvgl_tft/EVE.h"
|
||||
#include "../lvgl_tft/EVE_commands.h"
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
/**
|
||||
* Get the current position and state of the touchpad
|
||||
* @param data store the read data here
|
||||
* @return false: because no more data to be read
|
||||
*/
|
||||
bool FT81x_read(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||
{
|
||||
static int16_t last_x = 0;
|
||||
static int16_t last_y = 0;
|
||||
bool touched = true;
|
||||
|
||||
uint32_t XY = EVE_memRead32(REG_TOUCH_SCREEN_XY);
|
||||
uint16_t Y = XY & 0xffff;
|
||||
uint16_t X = XY >> 16;
|
||||
|
||||
// is it not touched (or invalid because of calibration range)
|
||||
if(X == 0x8000 || Y == 0x8000 || X > LV_HOR_RES_MAX || Y > LV_VER_RES_MAX)
|
||||
{
|
||||
touched = false;
|
||||
X = last_x;
|
||||
Y = last_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
last_x = X;
|
||||
last_y = Y;
|
||||
}
|
||||
|
||||
data->point.x = X;
|
||||
data->point.y = Y;
|
||||
data->state = (touched == false ? LV_INDEV_STATE_REL : LV_INDEV_STATE_PR);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
Loading…
Add table
Add a link
Reference in a new issue