Complete control with three physical buttons on M5stack

Good,day! I am a LVGL beginner. I want you to be kind.

Description

Is it possible to move and select objects with three physical buttons for complete control?

What MCU/Processor/Board and compiler are you using?

M5stack gray,ArduinoIDE

What do you want to achieve?

1.Moving the focus.
2.An event to the object being focused.(For example, the click of a button)
3.These clever ways.

What have you tried so far?

If the physical button is pressed, it simulates a button click.
Move and select the focus within a click event.

Code to reproduce

Add the relevant code snippets here.

The code block(s) should be between ```c and ``` tags:

bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data)
{
    //Click on a button in the screen according to the physical button that is pressed.
    if(digitalRead(btn_A)==1){
      data->point.x = 10;
      data->point.y = screenHeight-10;
    }else if(digitalRead(btn_B)==1 ){
      data->point.x = screenWidth/2;
      data->point.y = screenHeight-10;
    }else if(digitalRead(btn_C)==1){
      data->point.x = screenWidth-10;
      data->point.y = screenHeight-10;
    }else{
      data->state =LV_INDEV_STATE_REL;
      return false;
    }
    
    data->state =LV_INDEV_STATE_PR;
      return false; /*Return `false` because we are not buffering and no more data to read*/

      
}
static void win_btn_event_handler(lv_obj_t * btn, lv_event_t event)
{
 //Focus processing in the in-screen button event handler.
  if(event != LV_EVENT_CLICKED){
    return;
  }
  
  if(btn == obj_btn_L){
    Serial.println("L");
    lv_group_focus_prev(g);
    return;
  }else if(btn == obj_btn_C){
    Serial.println("C");
    lv_group_send_data(g,LV_KEY_ENTER);
    return;
  }else if(btn == obj_btn_R){
    Serial.println("R");
    lv_group_focus_next(g);
    return;
  }else{
    Serial.println("ex");
  }
}

Screenshot and/or video

Because the M5stack not yet arrived, it is a M5stack-style ESP32.

Thank you!

Take look at this PR:

1 Like

Thank you.
I’ll take that as a reference.

1 Like

I could have accomplished that!
Thank you!!
focus

2 Likes