2016-06-08 07:25:08 +02:00
|
|
|
/**
|
|
|
|
* @file lv_dispi.c
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
********************/
|
2016-06-10 15:00:56 +02:00
|
|
|
#include "lv_conf.h"
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
#include "misc/os/ptask.h"
|
|
|
|
#include "misc/math/math_base.h"
|
|
|
|
#include "lv_dispi.h"
|
|
|
|
#include "../lv_draw/lv_draw_rbasic.h"
|
|
|
|
#include "hal/indev/indev.h"
|
|
|
|
#include "hal/systick/systick.h"
|
|
|
|
#include "lv_obj.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
static void dispi_task(void);
|
|
|
|
static void dispi_proc_point(lv_dispi_t * dispi_p, cord_t x, cord_t y);
|
|
|
|
static void dispi_proc_press(lv_dispi_t * dispi_p);
|
|
|
|
static void disi_proc_release(lv_dispi_t * dispi_p);
|
2016-10-07 11:15:46 +02:00
|
|
|
static lv_obj_t * dispi_search_obj(const lv_dispi_t * dispi_p, lv_obj_t * obj);
|
2016-06-08 07:25:08 +02:00
|
|
|
static void dispi_drag(lv_dispi_t * dispi_p);
|
|
|
|
static void dispi_drag_throw(lv_dispi_t * dispi_p);
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC VARIABLES
|
|
|
|
**********************/
|
|
|
|
static ptask_t* dispi_task_p;
|
|
|
|
static bool lv_dispi_reset_qry;
|
|
|
|
static bool lv_dispi_reset_now;
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL FUNCTIONS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the display input subsystem
|
|
|
|
*/
|
|
|
|
void lv_dispi_init(void)
|
|
|
|
{
|
|
|
|
lv_dispi_reset_qry = false;
|
|
|
|
lv_dispi_reset_now = false;
|
|
|
|
|
|
|
|
#if LV_DISPI_READ_PERIOD != 0
|
|
|
|
dispi_task_p = ptask_create(dispi_task, LV_DISPI_READ_PERIOD, PTASK_PRIO_MID);
|
|
|
|
#else
|
|
|
|
dispi_task_p = ptask_create(dispi_task, 1, PTASK_PRIO_OFF); /*Not use lv_dispi*/
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset all display inputs
|
|
|
|
*/
|
|
|
|
void lv_dispi_reset(void)
|
|
|
|
{
|
|
|
|
lv_dispi_reset_qry = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the last point on display input
|
|
|
|
* @param dispi_p pointer to a display input
|
|
|
|
* @param point_p pointer to a point to store the result
|
|
|
|
*/
|
|
|
|
void lv_dispi_get_point(lv_dispi_t * dispi_p, point_t * point_p)
|
|
|
|
{
|
|
|
|
point_p->x = dispi_p->act_point.x;
|
|
|
|
point_p->y = dispi_p->act_point.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if there is dragging on display input or not
|
|
|
|
* @param dispi_p pointer to a display input
|
|
|
|
* @return true: drag is in progress
|
|
|
|
*/
|
|
|
|
bool lv_dispi_is_dragging(lv_dispi_t * dispi_p)
|
|
|
|
{
|
|
|
|
return dispi_p->drag_in_prog == 0 ? false : true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the vector of dragging on a display input
|
|
|
|
* @param dispi_p pointer to a display input
|
|
|
|
* @param point_p pointer to a point to store the vector
|
|
|
|
*/
|
|
|
|
void lv_dispi_get_vect(lv_dispi_t * dispi_p, point_t * point_p)
|
|
|
|
{
|
|
|
|
point_p->x = dispi_p->vect.x;
|
|
|
|
point_p->y = dispi_p->vect.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC FUNCTIONS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called periodically to handle the display inputs
|
|
|
|
*/
|
|
|
|
static void dispi_task(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
static lv_dispi_t dispi[INDEV_NUM];
|
|
|
|
cord_t x;
|
|
|
|
cord_t y;
|
|
|
|
uint8_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < INDEV_NUM; i++) {
|
|
|
|
dispi[i].pressed = indev_get(i, &x, &y);
|
|
|
|
dispi_proc_point(&dispi[i], x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*If reset query occurred in this round then set a flag to
|
|
|
|
* ask the dispis to reset themself in the next round */
|
|
|
|
if(lv_dispi_reset_qry != false) {
|
|
|
|
lv_dispi_reset_qry = false;
|
|
|
|
lv_dispi_reset_now = true;
|
|
|
|
}
|
|
|
|
/*If now a reset occurred then clear the flag*/
|
|
|
|
else if (lv_dispi_reset_now != false){
|
|
|
|
lv_dispi_reset_now = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process new points by a display input. dispi_p->pressed has to be set
|
|
|
|
* @param dispi_p pointer to a display input
|
|
|
|
* @param x x coordinate of the next point
|
|
|
|
* @param y y coordinate of the next point
|
|
|
|
*/
|
|
|
|
static void dispi_proc_point(lv_dispi_t * dispi_p, cord_t x, cord_t y)
|
|
|
|
{
|
|
|
|
#if LV_DOWNSCALE > 1 && LV_VDB_SIZE != 0
|
|
|
|
dispi_p->act_point.x = x * LV_DOWNSCALE;
|
|
|
|
dispi_p->act_point.y = y * LV_DOWNSCALE;
|
|
|
|
#else
|
|
|
|
dispi_p->act_point.x = x;
|
|
|
|
dispi_p->act_point.y = y;
|
|
|
|
#endif
|
|
|
|
/*Handle the reset query*/
|
|
|
|
if(lv_dispi_reset_now != false) {
|
2016-10-07 11:15:46 +02:00
|
|
|
dispi_p->act_obj = NULL;
|
|
|
|
dispi_p->last_obj = NULL;
|
2016-06-08 07:25:08 +02:00
|
|
|
dispi_p->drag_in_prog = 0;
|
|
|
|
dispi_p->long_press_sent = 0;
|
|
|
|
dispi_p->press_time_stamp = 0;
|
2016-12-17 12:02:30 +01:00
|
|
|
dispi_p->lpr_rep_time_stamp = 0;
|
2016-06-08 07:25:08 +02:00
|
|
|
dispi_p->vect_sum.x = 0;
|
|
|
|
dispi_p->vect_sum.y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dispi_p->pressed != false){
|
|
|
|
#if LV_DISPI_TP_MARKER != 0
|
|
|
|
area_t area;
|
|
|
|
area.x1 = x;
|
|
|
|
area.y1 = y;
|
|
|
|
area.x2 = x + 1;
|
|
|
|
area.y2 = y + 1;
|
|
|
|
lv_rfill(&area, NULL, COLOR_MAKE(0xFF, 0, 0), OPA_COVER);
|
|
|
|
#endif
|
|
|
|
dispi_proc_press(dispi_p);
|
|
|
|
} else {
|
|
|
|
disi_proc_release(dispi_p);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dispi_p->last_point.x = dispi_p->act_point.x;
|
|
|
|
dispi_p->last_point.y = dispi_p->act_point.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process the pressed state
|
|
|
|
* @param dispi_p pointer to a display input
|
|
|
|
*/
|
|
|
|
static void dispi_proc_press(lv_dispi_t * dispi_p)
|
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * pr_obj = dispi_p->act_obj;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*If there is no last object then search*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(dispi_p->act_obj == NULL) {
|
|
|
|
pr_obj = dispi_search_obj(dispi_p, lv_scr_act());
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
/*If there is last object but it can not be dragged also search*/
|
2016-10-07 11:15:46 +02:00
|
|
|
else if(lv_obj_get_drag(dispi_p->act_obj) == false) {/*Now act_obj != NULL*/
|
|
|
|
pr_obj = dispi_search_obj(dispi_p, lv_scr_act());
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
/*If a dragable object was the last then keep it*/
|
|
|
|
else {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*If a new object was found reset some variables and send a pressed signal*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(pr_obj != dispi_p->act_obj) {
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
dispi_p->last_point.x = dispi_p->act_point.x;
|
|
|
|
dispi_p->last_point.y = dispi_p->act_point.y;
|
|
|
|
|
|
|
|
/*If a new object found the previous was lost, so send a signal*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(dispi_p->act_obj != NULL) {
|
|
|
|
dispi_p->act_obj->signal_f(dispi_p->act_obj,
|
2016-06-08 07:25:08 +02:00
|
|
|
LV_SIGNAL_PRESS_LOST, dispi_p);
|
|
|
|
}
|
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
if(pr_obj != NULL) {
|
2016-06-08 07:25:08 +02:00
|
|
|
/* Save the time when the obj pressed.
|
|
|
|
* It is necessary to count the long press time.*/
|
|
|
|
dispi_p->press_time_stamp = systick_get();
|
|
|
|
dispi_p->long_press_sent = 0;
|
|
|
|
dispi_p->drag_in_prog = 0;
|
|
|
|
dispi_p->vect_sum.x = 0;
|
|
|
|
dispi_p->vect_sum.y = 0;
|
|
|
|
|
|
|
|
/*Search for 'top' attribute*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * i = pr_obj;
|
2016-06-08 07:25:08 +02:00
|
|
|
lv_obj_t * last_top = NULL;
|
|
|
|
while(i != NULL){
|
|
|
|
if(i->top_en != 0) last_top = i;
|
|
|
|
i = lv_obj_get_parent(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(last_top != NULL) {
|
|
|
|
/*Move the last_top object to the foreground*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * par =lv_obj_get_parent(last_top);
|
2016-06-08 07:25:08 +02:00
|
|
|
/*After list change it will be the new head*/
|
2016-10-07 11:15:46 +02:00
|
|
|
ll_chg_list(&par->child_ll, &par->child_ll, last_top);
|
2016-06-08 07:25:08 +02:00
|
|
|
lv_obj_inv(last_top);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Send a signal about the press*/
|
2016-10-07 11:15:46 +02:00
|
|
|
pr_obj->signal_f(pr_obj, LV_SIGNAL_PRESSED, dispi_p);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-17 12:02:30 +01:00
|
|
|
/* The reset can be set in the signal function.
|
2016-06-08 07:25:08 +02:00
|
|
|
* In case of reset query ignore the remaining parts.*/
|
|
|
|
if(lv_dispi_reset_qry == false) {
|
2016-10-07 11:15:46 +02:00
|
|
|
dispi_p->act_obj = pr_obj; /*Save the pressed object*/
|
|
|
|
dispi_p->last_obj = dispi_p->act_obj; /*Refresh the last_obj*/
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Calculate the vector*/
|
|
|
|
dispi_p->vect.x = dispi_p->act_point.x - dispi_p->last_point.x;
|
|
|
|
dispi_p->vect.y = dispi_p->act_point.y - dispi_p->last_point.y;
|
|
|
|
|
|
|
|
/*If there is active object and it can be dragged run the drag*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(dispi_p->act_obj != NULL) {
|
2016-12-21 14:49:23 +01:00
|
|
|
dispi_p->act_obj->signal_f(dispi_p->act_obj, LV_SIGNAL_PRESSING, dispi_p);
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
dispi_drag(dispi_p);
|
|
|
|
|
|
|
|
/*If there is no drag then check for long press time*/
|
|
|
|
if(dispi_p->drag_in_prog == 0 && dispi_p->long_press_sent == 0) {
|
|
|
|
/*Send a signal about the long press if enough time elapsed*/
|
|
|
|
if(systick_elaps(dispi_p->press_time_stamp) > LV_DISPI_LONG_PRESS_TIME) {
|
2016-10-07 11:15:46 +02:00
|
|
|
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS, dispi_p);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Mark the signal sending to do not send it again*/
|
2016-12-17 12:02:30 +01:00
|
|
|
dispi_p->long_press_sent = 1;
|
|
|
|
|
|
|
|
/*Save the long press time stamp for the long press repeat handler*/
|
|
|
|
dispi_p->lpr_rep_time_stamp = systick_get();
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-17 12:02:30 +01:00
|
|
|
/*Send long press repeated signal*/
|
|
|
|
if(dispi_p->drag_in_prog == 0 && dispi_p->long_press_sent == 1) {
|
|
|
|
/*Send a signal about the long press repeate if enough time elapsed*/
|
|
|
|
if(systick_elaps(dispi_p->lpr_rep_time_stamp) > LV_DISPI_LONG_PRESS_REP_TIME) {
|
|
|
|
pr_obj->signal_f(pr_obj, LV_SIGNAL_LONG_PRESS_REP, dispi_p);
|
|
|
|
dispi_p->lpr_rep_time_stamp = systick_get();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process the released state
|
|
|
|
* @param dispi_p pointer to a display input
|
|
|
|
*/
|
|
|
|
static void disi_proc_release(lv_dispi_t * dispi_p)
|
|
|
|
{
|
|
|
|
/*Forgot the act obj and send a released signal */
|
2016-10-07 11:15:46 +02:00
|
|
|
if(dispi_p->act_obj != NULL) {
|
|
|
|
dispi_p->act_obj->signal_f(dispi_p->act_obj,
|
2016-06-08 07:25:08 +02:00
|
|
|
LV_SIGNAL_RELEASED, dispi_p);
|
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
dispi_p->act_obj = NULL;
|
2016-06-08 07:25:08 +02:00
|
|
|
dispi_p->press_time_stamp = 0;
|
2016-12-17 12:02:30 +01:00
|
|
|
dispi_p->lpr_rep_time_stamp = 0;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*The reset can be set in the signal function.
|
|
|
|
* In case of reset query ignore the remaining parts.*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(dispi_p->last_obj != NULL && lv_dispi_reset_qry == false) {
|
2016-06-08 07:25:08 +02:00
|
|
|
dispi_drag_throw(dispi_p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Search the most top, clickable object on the last point of a display input
|
|
|
|
* @param dispi_p pointer to a display input
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param obj pointer to a start object, typically the screen
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return pointer to the found object or NULL if there was no suitable object
|
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
static lv_obj_t * dispi_search_obj(const lv_dispi_t * dispi_p, lv_obj_t * obj)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * found_p = NULL;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*If the point is on this object*/
|
|
|
|
/*Check its children too*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(area_is_point_on(&obj->cords, &dispi_p->act_point)) {
|
|
|
|
lv_obj_t * i;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
LL_READ(obj->child_ll, i) {
|
2016-06-08 07:25:08 +02:00
|
|
|
found_p = dispi_search_obj(dispi_p, i);
|
|
|
|
|
|
|
|
/*If a child was found then break*/
|
|
|
|
if(found_p != NULL) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*If then the children was not ok, but this obj is clickable
|
|
|
|
* and it or its parent is not hidden then save this object*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(found_p == NULL && lv_obj_get_click(obj) != false) {
|
|
|
|
lv_obj_t * i = obj;
|
2016-06-08 07:25:08 +02:00
|
|
|
while(i != NULL) {
|
|
|
|
if(lv_obj_get_hidden(i) == true) break;
|
|
|
|
i = lv_obj_get_parent(i);
|
|
|
|
}
|
|
|
|
/*No parent found with hidden == true*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(i == NULL) found_p = obj;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return found_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-10-07 11:15:46 +02:00
|
|
|
* Handle the dragging of dispi_p->act_obj
|
2016-06-08 07:25:08 +02:00
|
|
|
* @param dispi_p pointer to a display input
|
|
|
|
*/
|
|
|
|
static void dispi_drag(lv_dispi_t * dispi_p)
|
|
|
|
{
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * drag_obj = dispi_p->act_obj;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-12-17 10:50:28 +01:00
|
|
|
/*If drag parent is active check recursively the drag_parent attribute*/
|
|
|
|
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
|
|
|
drag_obj != NULL) {
|
|
|
|
drag_obj = lv_obj_get_parent(drag_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(drag_obj == NULL) return;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
if(lv_obj_get_drag(drag_obj) == false) return;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*If still there is no drag then count the movement*/
|
|
|
|
if(dispi_p->drag_in_prog == 0) {
|
|
|
|
dispi_p->vect_sum.x += dispi_p->vect.x;
|
|
|
|
dispi_p->vect_sum.y += dispi_p->vect.y;
|
|
|
|
|
|
|
|
/*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
|
2017-01-02 14:10:32 +01:00
|
|
|
if(MATH_ABS(dispi_p->vect_sum.x) >= LV_DISPI_DRAG_LIMIT ||
|
|
|
|
MATH_ABS(dispi_p->vect_sum.y) >= LV_DISPI_DRAG_LIMIT)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
|
|
|
dispi_p->drag_in_prog = 1;
|
2016-10-07 11:15:46 +02:00
|
|
|
drag_obj->signal_f(drag_obj,
|
2016-06-08 07:25:08 +02:00
|
|
|
LV_SIGNAL_DRAG_BEGIN, dispi_p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*If the drag limit is stepped over then handle the dragging*/
|
|
|
|
if(dispi_p->drag_in_prog != 0) {
|
|
|
|
/*Set new position if the vector is not zero*/
|
|
|
|
if(dispi_p->vect.x != 0 ||
|
|
|
|
dispi_p->vect.y != 0) {
|
|
|
|
/*Get the coordinates of the object end modify them*/
|
2016-10-07 11:15:46 +02:00
|
|
|
cord_t act_x = lv_obj_get_x(drag_obj) + dispi_p->vect.x;
|
|
|
|
cord_t act_y = lv_obj_get_y(drag_obj) + dispi_p->vect.y;
|
|
|
|
lv_obj_set_pos(drag_obj, act_x, act_y);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle throwing by drag if the drag is ended
|
|
|
|
* @param dispi_p pointer to a display input
|
|
|
|
*/
|
|
|
|
static void dispi_drag_throw(lv_dispi_t * dispi_p)
|
|
|
|
{
|
2016-07-11 16:16:53 +02:00
|
|
|
if(dispi_p->drag_in_prog == 0) return;
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*Set new position if the vector is not zero*/
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_obj_t * drag_obj = dispi_p->last_obj;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-12-17 10:50:28 +01:00
|
|
|
/*If drag parent is active check recursively the drag_parent attribute*/
|
|
|
|
|
|
|
|
while(lv_obj_get_drag_parent(drag_obj) != false &&
|
|
|
|
drag_obj != NULL) {
|
|
|
|
drag_obj = lv_obj_get_parent(drag_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(drag_obj == NULL) return;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*Return if the drag throw is not enabled*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(lv_obj_get_drag_throw(drag_obj) == false ){
|
2016-06-08 07:25:08 +02:00
|
|
|
dispi_p->drag_in_prog = 0;
|
2016-10-07 11:15:46 +02:00
|
|
|
drag_obj->signal_f(drag_obj, LV_SIGNAL_DRAG_END, dispi_p);
|
2016-06-08 07:25:08 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Reduce the vectors*/
|
|
|
|
dispi_p->vect.x = dispi_p->vect.x * (100 -LV_DISPI_DRAG_THROW) / 100;
|
|
|
|
dispi_p->vect.y = dispi_p->vect.y * (100 -LV_DISPI_DRAG_THROW) / 100;
|
|
|
|
|
|
|
|
if(dispi_p->vect.x != 0 ||
|
|
|
|
dispi_p->vect.y != 0)
|
|
|
|
{
|
|
|
|
/*Get the coordinates and modify them*/
|
2016-10-07 11:15:46 +02:00
|
|
|
cord_t act_x = lv_obj_get_x(drag_obj) + dispi_p->vect.x;
|
|
|
|
cord_t act_y = lv_obj_get_y(drag_obj) + dispi_p->vect.y;
|
|
|
|
lv_obj_set_pos(drag_obj, act_x, act_y);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
/*If the vectors become 0 -> drag_in_prog = 0 and send a drag end signal*/
|
|
|
|
else {
|
|
|
|
dispi_p->drag_in_prog = 0;
|
2016-10-07 11:15:46 +02:00
|
|
|
drag_obj->signal_f(drag_obj, LV_SIGNAL_DRAG_END, dispi_p);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
}
|