TEST
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG lvgl_RB FastPWM millis
Diff: main.cpp
- Revision:
- 1:404ee28a0b60
- Parent:
- 0:cf6b1eca3e67
- Child:
- 2:0ded70ebbc36
--- a/main.cpp Wed Jan 15 19:23:14 2020 +0000 +++ b/main.cpp Fri Jan 17 06:03:24 2020 +0000 @@ -242,7 +242,6 @@ int PosY_AnimSousMenu = 0; int AnimSousMenu=0; int TpsAvFermSousMenu=2000; -bool SousMenuActif; static void Reglage_R_RGB(lv_obj_t * obj, lv_event_t event); @@ -469,19 +468,21 @@ PosY_AnimSousMenu=PosY_AnimSousMenu+2; lv_obj_set_size(SousMenu, 100, PosY_AnimSousMenu); if (PosY_AnimSousMenu>=AnimSousMenu){AnimSousMenu=0;} - TpsAvFermSousMenu=4000; - SousMenuActif=true; + TpsAvFermSousMenu=4000; } //TEMPS AVANT FERMEURE - if (SousMenuActif==true and TpsAvFermSousMenu>0){TpsAvFermSousMenu--;} + if (SousMenu and TpsAvFermSousMenu>0){TpsAvFermSousMenu--;} //FERMETURE SOUS MENU - if (SousMenuActif==true and TpsAvFermSousMenu<=0) { + if (SousMenu and TpsAvFermSousMenu<=0) { PosY_AnimSousMenu=PosY_AnimSousMenu-2; lv_obj_set_size(SousMenu, 100, PosY_AnimSousMenu); - if (PosY_AnimSousMenu<=0){SousMenuActif=false;lv_obj_del_async(SousMenu); } + if (PosY_AnimSousMenu<=0){ + lv_obj_del_async(SousMenu); + SousMenu=NULL; + } } } - if (SousMenuActif and X>0){TpsAvFermSousMenu=4000;} + if (SousMenu and X>0){TpsAvFermSousMenu=4000;} /**/ }//FIN BOUCLE @@ -640,8 +641,12 @@ static void AFFSousMenu(int Num) { //SI SOUS MENU DEJA AFFICHE : SUPPRIMER PAGE AVANT CREATION NOUVELLE - if(SousMenuActif){lv_obj_del(SousMenu);} + if(SousMenu) { + lv_obj_del(SousMenu); + SousMenu = NULL; + } //GABOR: How to test if the object "SousMenu" already exist? I Think it will be a better way than i did it.(SET/RESET with a Bit) + //ROMAIN: You can set SousMenu to NULL when deleted. WHen created it will be not NULL. So SousMenu == NULL will indicate that if it's deleted. See my modifications //Something like: if(GetObjExist(SousMenu)==1){lv_obj_del(SousMenu);} /*Create a list*/ @@ -654,6 +659,7 @@ // Style_BPSM.body.padding.top = LV_DPI / 40; // Style_BPSM.body.padding.bottom = LV_DPI / 40; // GABOR: How to change the height of button in a list ? + // ROMAIN: You need to modify the paddings. See here: https://docs.littlevgl.com/en/html/object-types/list.html#style-usage //SOUS MENU 100 if (Num==100){ @@ -859,14 +865,26 @@ //CREATION LISTE UTILISATEUR POUR AFFICHAGE //GABOR: Mabye you have a better solution than: + //ROMAIN: There is no much better way, but I have a few comments int i; int j; int k=0; char p[2200]; - for (i = 1; i < 2200; i++) { p[i]=='\0';} - for (i = 1; i < 100; i++) { + + //ROMAIN: + // - p[i]=='\0'; it should be p[i]='\0'; isn't it? + // - If so why not start from i = 0 to initalize? + // - memset(p, '\0', sizeof(p)) can be a clearer option to initialize + for (i = 1; i < 2200; i++) { p[i]=='\0';} + + for (i = 1; i < 100; i++) { //ROMAIN: Why start from 1? string s=User[i].Nom; if (s.length()>0){ + //ROMAIN: I suggest using memcpy instead + // memcpy(&p[k], s, s.length()) + // k += s.length(); + // p[k] = '\n'; + // k++; for (j = 0; j < s.length(); j++) { p[k] = s[j]; k++; @@ -875,6 +893,9 @@ k++; } } + //ROMAIN: + // - you alraedy incremented k, so it should p[k] = '\0', shouldn't it? + // - and you initialized p to '\0' so it's not required p[k+1]='\0'; char * ListeUser= p ; @@ -885,6 +906,7 @@ lv_roller_set_fix_width(SelectID, 170); lv_obj_align(SelectID, PopupMDP, LV_ALIGN_IN_TOP_LEFT, 10, 20); //GABOR: is it possible to put the selection on the second line of the roller , not at the middle ? + //ROMAIN: unfortunatelly not. //CHAMPS MOT DE PASSE MDP = lv_ta_create(PopupMDP, NULL); @@ -943,7 +965,34 @@ lv_obj_align(BpAnnulMDP, PopupMDP, LV_ALIGN_IN_BOTTOM_MID, 60, -5); label = lv_label_create(BpAnnulMDP, NULL); //lv_label_set_text(label, "Annuler"); - lv_label_set_text(label, Message(1)); //GABOR: Multiligual : see the function "message" + + //GABOR: Multiligual : see the function "message" + //ROMAIN: lvgl has lv_i18n modul to so internationalization: https://github.com/littlevgl/lv_i18n + // - It's a script which autmatically extracts the strings to translate from you code + // - However to run the script you need the code offline + // - An other option is to manually create the internationalization file + // - I've added lv_i18n.c/h as a reference + // - You can test it like this + // lv_i18n_init(lv_i18n_language_pack); + // lv_i18n_set_locale("en-GB"); + // printf(_("dog")); + // printf("\n"); + // + // lv_i18n_set_locale("fr"); + // printf(_("dog")); + // printf("\n"); + // + // - '_' is a function which get the translated version of "dog" and "cat" in the given local + // - You can use it with labels: lv_label_set_text(label, _("dog")) + // - Translation with prinf-like format characters are also possible. E.g. + // - In lv_i18n.c: {"user_count", "There are %d users"}, + // - Usage: + // char buf[128]; + // sprintf(buf, _("user_count"), 55); + // + // - Or: + // lv_label_set_text_fmt(label, _("user_count"), 55); + lv_label_set_text(label, Message(1)); lv_obj_set_drag_parent(BpAnnulMDP, true); lv_obj_set_event_cb(BpAnnulMDP, BpAnnulMDP_ACT);