Description
I am currently facing an issue with using array of point in indev_button implementations
What MCU/Processor/Board and compiler are you using?
i am using a esp32s3 M5Dial
What LVGL version are you using?
8.3
What do you want to achieve?
So as M5Dial has 1 inbuilt button(encoder button ) i want to use the button for navigation. The event of shortpress and longpress. The problem is when i pass the array of points it only simulates the 1st index and doesnt take the other ones. Is there something i am missing or is there another way to do the longpress event.
What have you tried so far?
I have tried giving it the complete array, but since it is not takking the first value i have constantly update the 1st index and do a workaround through that
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
static lv_point_t btn_points[2] ;
static int8_t button_get_pressed_id_1(void) {
// Check if the button on the M5Dial is pressed
if (M5.BtnA.isPressed()) {
return 0; // The button is pressed, return button ID as 0
}
return -1;// No button is pressed
}
void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) {
static uint8_t last_btn = 0; /*Store the last pressed button*/
int8_t btn_act = button_get_pressed_id_1(); /*Get the ID (0,1,2...) of the pressed button*/
if (btn_act >= 0) { /*Is there a button press? (E.g. -1 indicated no button was pressed)*/
last_btn = btn_act; /*Save the ID of the pressed button*/
data->state = LV_INDEV_STATE_PR; /*Set the pressed state*/
} else {
data->state = LV_INDEV_STATE_REL; /*Set the released state*/
}
data->btn_id = last_btn; /*Save the last button*/
}
if (params_mode) {
lv_indev_set_group(encoder_indev, groups.params_nav);
lv_indev_set_group(touch_indev, groups.params_nav);
lv_indev_set_group(button_indev, groups.params_nav);
if (millis() - lastPressTime > timeout_duration) {
if (!isBlinking) {
btn_points[0].x = 63;
btn_points[0].y = 186;
updateLEDs(0, 0, 0, 33, 131, 146, 0, 0, 0);
} else {
btn_points[0].x = 121;
btn_points[0].y = 186;
if (blink) {
updateLEDs(0, 0, 0, 0, 0, 0, 0, 0, 0); // Turn off LEDs
} else {
updateLEDs(0, 0, 0, 0, 0, 255, 0, 0, 0); // Turn on LED 7
}
}
lastPressTime = millis(); // Update the last press time
}
} else {
// When not in params_mode and not blinking
if (!isBlinking) {
lv_indev_set_group(encoder_indev, groups.main_nav);
lv_indev_set_group(touch_indev, groups.main_nav);
lv_indev_set_group(button_indev, groups.main_nav);
updateLEDs(0, 0, 0, 100, 0, 0, 0, 0, 0);
btn_points[0].x = 120;
btn_points[0].y = 120;
}
}
this is functional but i want to add another coordinate
i have tried
btn_points{1].x = 110;
btn_points[1].y = 10;
but doesnt work
in documention there is a mention of this
const lv_point_t points_array[] = { {12,30},{60,90}, ...}
i wonder if i am using the same thing or not