feat(indev) change the prototype of indev read_cb

Instead of returning bool to indicate that there is more data to read
set data->continue_reading = true.
It's less error porne because if the user doesn't set the flag the indev will be read once
which is usually the inteded behaviour.
This commit is contained in:
Gabor Kiss-Vamosi
2021-05-12 14:21:27 +02:00
parent 0117320c30
commit 039ed0baa6
4 changed files with 19 additions and 40 deletions
+9 -24
View File
@@ -24,17 +24,17 @@
**********************/
static void touchpad_init(void);
static bool 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 bool touchpad_is_pressed(void);
static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y);
static void mouse_init(void);
static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static bool mouse_is_pressed(void);
static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y);
static void keypad_init(void);
static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static uint32_t keypad_get_key(void);
static void encoder_init(void);
@@ -42,7 +42,7 @@ static bool encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static void encoder_handler(void);
static void button_init(void);
static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
static int8_t button_get_pressed_id(void);
static bool button_is_pressed(uint8_t id);
@@ -185,7 +185,7 @@ static void touchpad_init(void)
}
/*Will be called by the library to read the touchpad*/
static bool 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;
@@ -201,9 +201,6 @@ static bool touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
/*Set the last pressed coordinates*/
data->point.x = last_x;
data->point.y = last_y;
/*Return `false` because we are not buffering and no more data to read*/
return false;
}
/*Return true is the touchpad is pressed*/
@@ -234,7 +231,7 @@ static void mouse_init(void)
}
/*Will be called by the library to read the mouse*/
static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
/*Get the current x and y coordinates*/
mouse_get_xy(&data->point.x, &data->point.y);
@@ -245,9 +242,6 @@ static bool mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
} else {
data->state = LV_INDEV_STATE_REL;
}
/*Return `false` because we are not buffering and no more data to read*/
return false;
}
/*Return true is the mouse button is pressed*/
@@ -278,7 +272,7 @@ static void keypad_init(void)
}
/*Will be called by the library to read the mouse*/
static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
static uint32_t last_key = 0;
@@ -315,9 +309,6 @@ static bool keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
}
data->key = last_key;
/*Return `false` because we are not buffering and no more data to read*/
return false;
}
/*Get the currently being pressed key. 0 if no key is pressed*/
@@ -339,14 +330,11 @@ static void encoder_init(void)
}
/*Will be called by the library to read the encoder*/
static bool encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
data->enc_diff = encoder_diff;
data->state = encoder_state;
/*Return `false` because we are not buffering and no more data to read*/
return false;
}
/*Call this function in an interrupt to process encoder events (turn, press)*/
@@ -369,7 +357,7 @@ static void button_init(void)
}
/*Will be called by the library to read the button*/
static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
static uint8_t last_btn = 0;
@@ -386,9 +374,6 @@ static bool button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
/*Save the last pressed button's ID*/
data->btn_id = last_btn;
/*Return `false` because we are not buffering and no more data to read*/
return false;
}
/*Get ID (0, 1, 2 ..) of the pressed button*/