<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Rotary encoder: lv_group_add_obj operation crashes sometimes in GUI Guider</title>
    <link>https://community.nxp.com/t5/GUI-Guider/Rotary-encoder-lv-group-add-obj-operation-crashes-sometimes/m-p/1466546#M85</link>
    <description>&lt;P&gt;Good Morning Everyone!&lt;/P&gt;&lt;P&gt;I have a weird crash in my program ( I suspect a memory leak somewhere), dealing with adding objects to a rotary encoder group with lv_group_add_obj&lt;/P&gt;&lt;P&gt;LPC55S69 // GuiGuider V1.3.1-GA //&amp;nbsp;MCUXpresso V11.4.0 build 6237 //&amp;nbsp;LvGL 8.2.0 &amp;amp; 8.0.2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have set up 3 screens in GuiGuider&amp;nbsp;(Dashboard, Config, Charts) basically in a circle, each with 2 buttons.&lt;/P&gt;&lt;P&gt;Left button loads previous screen, Right button loads next screen&lt;/P&gt;&lt;P&gt;E.G. repeatedly clicking the right button will take you : Dashboard -&amp;gt; Config -&amp;gt; Charts -&amp;gt; Dashboard again&lt;/P&gt;&lt;P&gt;And repeatedly clicking on the left button will take you in the opposite sequence.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using a rotary encoder and in the driver I basically send back to LvGL the following&amp;nbsp;&lt;/P&gt;&lt;P&gt;data-&amp;gt;enc_diff = lvgl_RotaryEncoder_Diff; //+1 for a clockwise step, -1 for a CCW step&lt;BR /&gt;data-&amp;gt;state = LV_INDEV_STATE_PRESSED;&lt;BR /&gt;data-&amp;gt;state = LV_INDEV_STATE_RELEASED;&lt;/P&gt;&lt;P&gt;The above all works fine, screens render nicely, and responds to the users input via the rotary encoder . . . .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my events_init.c, in the events_init function I've added code to create the lv_group thats required for the Rotary Encoder events to be processed, as well as linking the group to my rotary encoder&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And on each button click event in events_init.c I remove all objects from the group before running the code to load the new screen with : lv_group_remove_all_objs(rotary_encoder_focused_objects_group);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And then I add the newly created screen's buttons to the group with :&amp;nbsp; lv_group_add_obj(rotary_encoder_focused_objects_group, guider_ui.Charts_btn_left);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This all works fine, except after about the 6th+n screen changes there is an inevitable crash in lv_group_add_obj, see the attached lvgl_crash_info.txt&lt;/P&gt;&lt;P&gt;I've also attached some source file in the .zip file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ive tried:&lt;/P&gt;&lt;P&gt;1. different versions of lvgl 7.1 8.0.2, 8.2.0&lt;/P&gt;&lt;P&gt;2. deleting the group and creating a new one on each screen change&lt;/P&gt;&lt;P&gt;3. setting the group to default&lt;/P&gt;&lt;P&gt;4. Consulting caffeine and spending endless late hours and early mornings looking at the code&lt;/P&gt;&lt;P&gt;But sadly, all to no avail&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Gert&lt;/P&gt;</description>
    <pubDate>Tue, 31 May 2022 05:40:47 GMT</pubDate>
    <dc:creator>gertvb</dc:creator>
    <dc:date>2022-05-31T05:40:47Z</dc:date>
    <item>
      <title>Rotary encoder: lv_group_add_obj operation crashes sometimes</title>
      <link>https://community.nxp.com/t5/GUI-Guider/Rotary-encoder-lv-group-add-obj-operation-crashes-sometimes/m-p/1466546#M85</link>
      <description>&lt;P&gt;Good Morning Everyone!&lt;/P&gt;&lt;P&gt;I have a weird crash in my program ( I suspect a memory leak somewhere), dealing with adding objects to a rotary encoder group with lv_group_add_obj&lt;/P&gt;&lt;P&gt;LPC55S69 // GuiGuider V1.3.1-GA //&amp;nbsp;MCUXpresso V11.4.0 build 6237 //&amp;nbsp;LvGL 8.2.0 &amp;amp; 8.0.2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have set up 3 screens in GuiGuider&amp;nbsp;(Dashboard, Config, Charts) basically in a circle, each with 2 buttons.&lt;/P&gt;&lt;P&gt;Left button loads previous screen, Right button loads next screen&lt;/P&gt;&lt;P&gt;E.G. repeatedly clicking the right button will take you : Dashboard -&amp;gt; Config -&amp;gt; Charts -&amp;gt; Dashboard again&lt;/P&gt;&lt;P&gt;And repeatedly clicking on the left button will take you in the opposite sequence.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using a rotary encoder and in the driver I basically send back to LvGL the following&amp;nbsp;&lt;/P&gt;&lt;P&gt;data-&amp;gt;enc_diff = lvgl_RotaryEncoder_Diff; //+1 for a clockwise step, -1 for a CCW step&lt;BR /&gt;data-&amp;gt;state = LV_INDEV_STATE_PRESSED;&lt;BR /&gt;data-&amp;gt;state = LV_INDEV_STATE_RELEASED;&lt;/P&gt;&lt;P&gt;The above all works fine, screens render nicely, and responds to the users input via the rotary encoder . . . .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my events_init.c, in the events_init function I've added code to create the lv_group thats required for the Rotary Encoder events to be processed, as well as linking the group to my rotary encoder&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And on each button click event in events_init.c I remove all objects from the group before running the code to load the new screen with : lv_group_remove_all_objs(rotary_encoder_focused_objects_group);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And then I add the newly created screen's buttons to the group with :&amp;nbsp; lv_group_add_obj(rotary_encoder_focused_objects_group, guider_ui.Charts_btn_left);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This all works fine, except after about the 6th+n screen changes there is an inevitable crash in lv_group_add_obj, see the attached lvgl_crash_info.txt&lt;/P&gt;&lt;P&gt;I've also attached some source file in the .zip file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ive tried:&lt;/P&gt;&lt;P&gt;1. different versions of lvgl 7.1 8.0.2, 8.2.0&lt;/P&gt;&lt;P&gt;2. deleting the group and creating a new one on each screen change&lt;/P&gt;&lt;P&gt;3. setting the group to default&lt;/P&gt;&lt;P&gt;4. Consulting caffeine and spending endless late hours and early mornings looking at the code&lt;/P&gt;&lt;P&gt;But sadly, all to no avail&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Gert&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 05:40:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/GUI-Guider/Rotary-encoder-lv-group-add-obj-operation-crashes-sometimes/m-p/1466546#M85</guid>
      <dc:creator>gertvb</dc:creator>
      <dc:date>2022-05-31T05:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Rotary encoder: lv_group_add_obj operation crashes sometimes</title>
      <link>https://community.nxp.com/t5/GUI-Guider/Rotary-encoder-lv-group-add-obj-operation-crashes-sometimes/m-p/1466873#M86</link>
      <description>&lt;P&gt;I changed the screen load from :&amp;nbsp;lv_scr_load_anim(guider_ui.Charts, LV_SCR_LOAD_ANIM_NONE, 0, 0, true);&lt;/P&gt;&lt;P&gt;To :&amp;nbsp;lv_disp_load_scr(guider_ui.Charts);&lt;/P&gt;&lt;P&gt;And the problem disappeared!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ran the GUI in the GUIGuider simulator, and it also crashed there after a few screen switches, only thing different is that in the GUIGuider simulator there is no group for the encoder, so I figured the problem was in the screen load&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 14:53:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/GUI-Guider/Rotary-encoder-lv-group-add-obj-operation-crashes-sometimes/m-p/1466873#M86</guid>
      <dc:creator>gertvb</dc:creator>
      <dc:date>2022-05-31T14:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rotary encoder: lv_group_add_obj operation crashes sometimes</title>
      <link>https://community.nxp.com/t5/GUI-Guider/Rotary-encoder-lv-group-add-obj-operation-crashes-sometimes/m-p/1470452#M87</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;gertvb,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yes, the issue is caused by screen load. When loading a new screen by lv_scr_load_anim() and enabling auto-delete previous screen by setting last parameter to "true", the variable of old screen still points to previous memory address even if the used memory is freed, when loading back to the old screen, lv_obj_is_valid is used to validate the old screen by just checking if the screen variable points to a memory address, then the application will be crash. This bug will be fixed in GUI Guider v1.4.0. the following code can be used in events_init.c is the workaround.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;static void Screen_btn_screen_to_screen2_event_handler(lv_event_t *e)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; lv_event_code_t code = lv_event_get_code(e);&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; switch (code)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; case LV_EVENT_CLICKED:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lv_disp_t * d = lv_obj_get_disp(lv_scr_act());&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (d-&amp;gt;prev_scr == NULL &amp;amp;&amp;amp; d-&amp;gt;scr_to_load == NULL)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setup_scr_screen2(&amp;amp;guider_ui);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lv_scr_load_anim(guider_ui.screen2, LV_SCR_LOAD_ANIM_NONE, 1, 0, true);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; default:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Zhenhua&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 08:04:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/GUI-Guider/Rotary-encoder-lv-group-add-obj-operation-crashes-sometimes/m-p/1470452#M87</guid>
      <dc:creator>zhenhualuo</dc:creator>
      <dc:date>2022-06-08T08:04:27Z</dc:date>
    </item>
  </channel>
</rss>

