Some refactoring

This commit is contained in:
Th3maz1ng 2023-01-07 23:16:31 +01:00
parent a4b6ac5299
commit 5c7bfc223a
4 changed files with 11 additions and 57 deletions

View File

@ -63,12 +63,12 @@ void lv_port_disp_init(void)
lcd_register_draw_finished_cb(&LCDConfig, &(lcd_draw_finished_cb), &display_driver);
#if defined(W800)
LCDConfig.LCDPWMBacklightPin = WM_IO_PA_07;
LCDConfig.LCDClockPin = WM_IO_PB_06;
LCDConfig.LCDDataPin = WM_IO_PB_07;
LCDConfig.LCDChipSelectPin = WM_IO_PB_10;
LCDConfig.LCDDataCommandPin = WM_IO_PB_08;
LCDConfig.LCDResetPin = WM_IO_PB_09;
LCDConfig.LCDPWMBacklightPin = LCD_PWM_BACKLIGHT;
LCDConfig.LCDClockPin = LCD_CLOCK_CLOCK;
LCDConfig.LCDDataPin = LCD_DATA_LINE;
LCDConfig.LCDChipSelectPin = LCD_CHIP_SELECT;
LCDConfig.LCDDataCommandPin = LCD_DATA_COMMAND;
LCDConfig.LCDResetPin = LCD_RESET;
#elif defined(W801)
LCDConfig.LCDPWMBacklightPin = WM_IO_PA_08;
LCDConfig.LCDClockPin = WM_IO_PA_09;

View File

@ -1,5 +1,5 @@
/**
* @file lv_port_indev_templ.c
* @file lv_port_indev.c
*
*/

View File

@ -11,7 +11,6 @@
*********************/
#include "lv_port_indev.h"
#include "touchpad.h"
#include "i2c.h"
/*********************
* DEFINES
@ -68,18 +67,6 @@ lv_indev_t * indev_touchpad;
* GLOBAL FUNCTIONS
**********************/
uint16_t x = 0, y = 0, action = 0;
static void touch_screen_isr(void *arg)
{
tls_clr_gpio_irq_status(WM_IO_PB_00);
uint8_t tc_data[9];
i2c_read(0x15, 0x00, tc_data, sizeof tc_data);
x = ((tc_data[3] & 0x0f) << 8) | tc_data[4];
y = ((tc_data[5] & 0x0f) << 8) | tc_data[6];
action = tc_data[3] >> 6;
}
void lv_port_indev_init(void)
{
/**
@ -101,10 +88,7 @@ void lv_port_indev_init(void)
* -----------------*/
/*Initialize your touchpad if you have*/
//touchpad_init();
tls_gpio_cfg(WM_IO_PB_00, WM_GPIO_DIR_INPUT, WM_GPIO_ATTR_PULLHIGH);
tls_gpio_isr_register(WM_IO_PB_00, &(touch_screen_isr), NULL);
tls_gpio_irq_enable(WM_IO_PB_00, WM_GPIO_IRQ_TRIG_FALLING_EDGE);
touchpad_init();
/*Register a touchpad input device*/
lv_indev_drv_init(&indev_drv);
@ -203,7 +187,7 @@ static void touchpad_init(void)
}
/*Will be called by the library to read the touchpad*/
/*static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
static lv_coord_t last_x = 0;
static lv_coord_t last_y = 0;
@ -220,40 +204,15 @@ static void touchpad_init(void)
// Set the last pressed coordinates
data->point.x = 240-last_y;
data->point.y = last_x;
}*/
static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
static lv_coord_t last_x = 0;
static lv_coord_t last_y = 0;
// Save the pressed coordinates and the state
if(touchpad_is_pressed()) {
last_x = x;
last_y = y;
data->state = LV_INDEV_STATE_PR;
}
else {
data->state = LV_INDEV_STATE_REL;
}
// Set the last pressed coordinates
data->point.x = 239-last_x;
data->point.y = 239-last_y;
}
/*Return true is the touchpad is pressed*/
/*static bool touchpad_is_pressed(void)
static bool touchpad_is_pressed(void)
{
// Your code comes here
bool val = bsp_touchpad_is_pressed();
// printf("---> %d\n",val);
return val;
}*/
static bool touchpad_is_pressed(void)
{
return action == 2;
}
/*Get the x and y coordinates if the touchpad is pressed*/
@ -266,11 +225,6 @@ static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
// printf("---> x:%d y:%d\n", (*x), (*y));
}
/*static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y)
{
}*/
// /*------------------
// * Mouse
// * -----------------*/

View File

@ -1,6 +1,6 @@
/**
* @file lv_port_indev_templ.h
* @file lv_port_indev.h
*
*/