Button matrix causes reset

Description

i just made a custom button matrix that seems to cause resetting of the esp32.

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

esp32 dev module

What do you experience?

there are times when i press on the matrix i notice that the hardware is resetting. idk if its the pressure or dragging from the btnm but it frequently happens

What do you expect?

Code to reproduce

Add a code snippet to reproduce the issue in the simulator. It should contain only the relevant code which can be compiled. Bug reports without code snippets or with erroneous code snippets will not be reviewed.

   static const char * btnmJob_map[]= {LV_SYMBOL_PLAY, "\n", LV_SYMBOL_PAUSE, LV_SYMBOL_STOP, ""};
    lv_obj_t *btnmJobControl = lv_btnm_create(tab1,NULL);
    lv_btnm_set_map (btnmJobControl, btnmJob_map);
    lv_obj_set_size(btnmJobControl,100,100);
    lv_obj_align(btnmJobControl, NULL, LV_ALIGN_CENTER, 180,-87);
    
static const char * btnmKB_map[]= {"1","2","3","\n", 
                                       "4","5","6","\n", 
                                       "7","8","9","\n", 
                                       "0","   ","\n",
                                       "X","Y","Z","\n", 
                                       "G","M","F","\n",
                                       "Send",""};
    lv_obj_t *btnmKB = lv_btnm_create(tab1,NULL);
    lv_btnm_set_map (btnmKB, btnmKB_map);
    lv_obj_set_size(btnmKB,100,240);
    lv_obj_align(btnmKB, NULL, LV_ALIGN_CENTER, -180,16);
 
    lv_obj_set_event_cb(btnmKB, [](lv_obj_t *obj, lv_event_t event) {
      if (event == LV_EVENT_CLICKED) {
        const char* txt = lv_btnm_get_active_btn_text(obj);
        printf("%s was pressed\n", txt);
        //send text to text area taGC
        //lv_ta_set_text(taGC, txt);
      }
    });

    lv_obj_t *taGC = lv_ta_create(tab1, NULL);
    lv_obj_set_size(taGC, 250,28);
    lv_obj_align(taGC, NULL, LV_ALIGN_CENTER, 0, -90);
    lv_ta_set_text(taGC, "");
    

Screenshot and/or videoPreformatted text

[“https://drive.google.com/file/d/1SpctLxkFPmqeivuJQwjagaqvZYcqP2vu/preview” width=“640” height=“480”](“https://drive.google.com/file/d/1SpctLxkFPmqeivuJQwjagaqvZYcqP2vu/preview” width=“640” height=“480”)

Insert this if checking before printf

if(txt != NULL) printf("%s was pressed\n", txt);

BTW you should use LV_EVENT_VALUE_CHANGED instead of LV_EVENT_CLICKED
for your button-matrix.

I’ve tested it and it worked well for me.

As @TridentTD mentioned printf might fail if you click between the buttons and txt is NULL

Wow that just solved it! Big thanks to both of you. Everything is ok now.
That just shows how i’m really not a programmer and how easy using littlevgl is to layout a GUI for non programmers. :smiley:
Now any tip on how i can send the text to the text area beside it? :stuck_out_tongue:

Use lv_kb instead of button-matrix.

lv_kb is a button-matrix but with api to connect to a text-area.

You can set keyboard map like button-matrix by lv_kb_set_map(..)
and then link the keyboard to a text-area by lv_kb_set_ta(..).
And then when you type by the keyboard, the pressed-key’s character will
be shown on the text-area automatically.

Learn the lvgl’s keyboard (lv_kb) at

https://docs.littlevgl.com/en/html/object-types/kb.html

1 Like