THEME AND FONT
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG lvgl_RB FastPWM millis
Diff: main.cpp
- Revision:
- 4:6a3d12663549
- Parent:
- 3:78125a86a357
- Child:
- 5:cab3e2179cbf
--- a/main.cpp Fri Jan 17 06:32:53 2020 +0000 +++ b/main.cpp Sun Jan 26 16:19:54 2020 +0000 @@ -6,6 +6,9 @@ #include "millis.h" #include "FastPWM.h" #include <string> +#include "lv_i18n.h" + +#include "lv_theme_rb.h" //GABOR Ticker ticker; //Initialize system tick LCD_DISCO_F746NG lcd; //Initialize display driver @@ -22,10 +25,15 @@ //PWM FastPWM fastpwm(D12,1); //steup pwm output on pin d12 with a prescaler of 1 - + +//MARCHE POMPE +DigitalOut DO_POMPE(D13); + //COMPTEUR IMPULSION DigitalIn DI_CPTPuls(D7); //InterruptIn DI_CPTPuls(D7); // + + /********************** * VARIABLES GENERALES @@ -41,8 +49,6 @@ bool Top1min; char text[100]; char text2[100]; -int Langue=1; -char* Message(int Num); float TensionBat; float MoyTensBat[101]; @@ -80,6 +86,7 @@ int hres = 480; int vres = 272; +bool CDA_POMPE; uint64_t test=0; @@ -95,8 +102,11 @@ static lv_obj_t * SousMenu; static void AFFSousMenu(int Num); static lv_obj_t * Page; +int PageAff=0; +int MemPageAff=0; static void AFFPage(int Num); + static lv_obj_t * PopupMDP; static void AFFPopupMDP(); @@ -143,14 +153,11 @@ static lv_obj_t * SM103; static lv_obj_t * SM104; static lv_obj_t * SM105; -static lv_obj_t * SM106; static lv_obj_t * SM201; static lv_obj_t * SM202; -static lv_obj_t * SM203; -static lv_obj_t * SM204; -static lv_obj_t * SM205; -static lv_obj_t * SM206; + +static lv_obj_t * SM301; //FONCTIONS ASSOCIEES static void M100_ACT(lv_obj_t * btn, lv_event_t event); @@ -169,8 +176,8 @@ static void SM201_ACT(lv_obj_t * btn, lv_event_t event); static void SM202_ACT(lv_obj_t * btn, lv_event_t event); static void SM203_ACT(lv_obj_t * btn, lv_event_t event); -static void SM204_ACT(lv_obj_t * btn, lv_event_t event); -static void SM205_ACT(lv_obj_t * btn, lv_event_t event); + +static void SM301_ACT(lv_obj_t * btn, lv_event_t event); /********************* * OBJETS @@ -195,7 +202,12 @@ static lv_style_t Style_BPSMInactif; static lv_style_t Style_BP; - +/********************* + * MULTILANGUE + *********************/ +int Langue=1; +static void LANGUE_FR_ACT(lv_obj_t * btn, lv_event_t event); +static void LANGUE_EN_ACT(lv_obj_t * btn, lv_event_t event); /********************* * FONCTION @@ -204,6 +216,7 @@ void interruptCompteur(); static void BPRAZ_ACT(lv_obj_t * btn, lv_event_t event); +static void BPPOMPE_ACT(lv_obj_t * btn, lv_event_t event); static lv_theme_t * th_act; static lv_obj_t * label; static lv_obj_t * label1; @@ -219,8 +232,9 @@ static lv_obj_t * AffTpsMaxEntre2Puls; static lv_obj_t * AffVolume; static lv_obj_t * BPRAZ; +static lv_obj_t * BPPOMPE; -uint8_t NumSousMenu=1; +int NumSousMenu=1; LV_FONT_DECLARE(arial_20) //Declare a font @@ -282,42 +296,6 @@ int NumCouleur=0; -lv_obj_t * th_roller ; - - - -static const char * th_options = { -#if LV_USE_THEME_DEFAULT - "Default" -#endif - -#if LV_USE_THEME_NIGHT - "\nNight" -#endif - -#if LV_USE_THEME_MATERIAL - "\nMaterial" -#endif - -#if LV_USE_THEME_ALIEN - "\nAlien" -#endif - -#if LV_USE_THEME_ZEN - "\nZen" -#endif - -#if LV_USE_THEME_NEMO - "\nNemo" -#endif - -#if LV_USE_THEME_MONO - "\nMono" -#endif - - - "" -}; static lv_theme_t * themes[8]; @@ -354,10 +332,14 @@ indev_drv.read_cb = my_touchpad_read; //Set your driver function lv_indev_drv_register(&indev_drv); //Finally register the driver + //INITIALISATION MULTILANGUE + lv_i18n_init(lv_i18n_language_pack); + lv_i18n_set_locale("fr"); + lv_i18n_set_locale("en-GB"); initialisation(); AFFBandeauHaut(0); - AFFPage(0); + AFFPage(101); //demarrage tempo générale tempo.start(); @@ -382,25 +364,31 @@ TpsCy=1000000000/CalcTpsCy; TpsCy=TpsCy/1000; test=CalcTpsCy; - CalcTpsCy=0; + CalcTpsCy=0; } //Raffraichissement affichage toutes les 10ms if (Top10ms){ lv_task_handler(); } - + //MISE A JOUR DES VARIABLES AFFICHEES - if (Top1s){ - // serial.printf("MICROS %d \r\n",Micros); - sprintf(text, "Temps de cycle = %3.3f us",TpsCy); lv_label_set_text(AffTpsCy, text); - sprintf(text, "Tension= %3.3f V ",TensionBat ); lv_label_set_text(AffTensionBat, text); - sprintf(text, "Nombre d'impulsion= %d ",CptPuls ); lv_label_set_text(AffCptPuls, text); - sprintf(text, "Volume = %3.3f L",Volume ); lv_label_set_text(AffVolume, text); - sprintf(text, "Debit= %3.3f L/min ",Debit ); lv_label_set_text(AffDebit, text); - sprintf(text, "%3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f ",TpsEntre2Puls[1],TpsEntre2Puls[2],TpsEntre2Puls[3],TpsEntre2Puls[4],TpsEntre2Puls[5],TpsEntre2Puls[6],TpsEntre2Puls[7],TpsEntre2Puls[8]); lv_label_set_text(Aff1TpsEntre2Puls, text); - sprintf(text, "%3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f ",TpsEntre2Puls[9],TpsEntre2Puls[10],TpsEntre2Puls[11],TpsEntre2Puls[12],TpsEntre2Puls[13],TpsEntre2Puls[14],TpsEntre2Puls[15],TpsEntre2Puls[16]); lv_label_set_text(Aff2TpsEntre2Puls, text); - sprintf(text, "Temps mini entre 2 impulsions = %d ",Micros ); lv_label_set_text(AffTpsMinEntre2Puls, text); - sprintf(text, "Temps maxi entre 2 impulsions = %d",test ); lv_label_set_text(AffTpsMaxEntre2Puls, text); + if (Top1s or MemPageAff!=PageAff){ + MemPageAff=PageAff; + if (PageAff==101){ + sprintf(text, _("Temps de cycle = %3.3f us"),TpsCy); lv_label_set_text(AffTpsCy, text); + sprintf(text, _("Tension= %3.3f V "),TensionBat ); lv_label_set_text(AffTensionBat, text); + sprintf(text, "Nombre d'impulsion= %d ",CptPuls ); lv_label_set_text(AffCptPuls, text); + sprintf(text, "Volume = %3.3f L",Volume ); lv_label_set_text(AffVolume, text); + sprintf(text, "Debit= %3.3f L/min ",Debit ); lv_label_set_text(AffDebit, text); + sprintf(text, "%3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f ",TpsEntre2Puls[1],TpsEntre2Puls[2],TpsEntre2Puls[3],TpsEntre2Puls[4],TpsEntre2Puls[5],TpsEntre2Puls[6],TpsEntre2Puls[7],TpsEntre2Puls[8]); lv_label_set_text(Aff1TpsEntre2Puls, text); + sprintf(text, "%3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f / %3.0f ",TpsEntre2Puls[9],TpsEntre2Puls[10],TpsEntre2Puls[11],TpsEntre2Puls[12],TpsEntre2Puls[13],TpsEntre2Puls[14],TpsEntre2Puls[15],TpsEntre2Puls[16]); lv_label_set_text(Aff2TpsEntre2Puls, text); + sprintf(text, "Temps mini entre 2 impulsions = %d ",Micros ); lv_label_set_text(AffTpsMinEntre2Puls, text); + sprintf(text, "Temps maxi entre 2 impulsions = %d",test ); lv_label_set_text(AffTpsMaxEntre2Puls, text); + } + if (PageAff==301){ + + } + } //DETECTION IMPULSION @@ -413,7 +401,7 @@ //MESURE TENSION BATTERIE if (Top10ms){ - MoyTensBat[0]=AI_TENSION_BAT.read()*3.3*2; + MoyTensBat[0]=AI_TENSION_BAT.read()*3.3*2+0.018; TensionBat=0; for (int i=100;i>0;i--){ MoyTensBat[i]=MoyTensBat[i-1]; @@ -428,6 +416,7 @@ fastpwm.period_ticks (10000); //setup the period for 100Khz fastpwm.pulsewidth_ticks(CsgPompe);//setup duty cycle to 50% } + //RAZ MOT DE PASSE if (TpsMdpEnCours>0 and Top1s){ TpsMdpEnCours--; @@ -529,35 +518,17 @@ void initialisation(void) { - // By doing this, we hide the first (empty) option. - if(th_options[0] == '\n') { - th_options++; - } - - init_all_themes(0); - th_act = themes[0]; + //CHARGEMENT DU THEME + th_act = lv_theme_rb_init(0, NULL); //Gabor: When i change something in my Theme nothing's happen. Can you see in /lvgl_RB/lv_theme_rb.c + // th_act = lv_theme_night_init(0, NULL); lv_theme_set_current(th_act); lv_obj_t * scr = lv_obj_create(NULL, NULL); lv_disp_load_scr(scr); - - // CREATION OBJET BANDEAU HAUT - BandeauHaut = lv_cont_create(lv_disp_get_scr_act(NULL), NULL); - lv_obj_set_size(BandeauHaut,900,40); - lv_cont_set_fit2(BandeauHaut,LV_FIT_TIGHT, LV_FIT_NONE); - lv_obj_set_pos(BandeauHaut, 50, 0); - lv_obj_set_drag_dir(BandeauHaut, LV_DRAG_DIR_HOR); - lv_obj_set_drag_throw(BandeauHaut, true); - - // CREATION PAGE CONTENU - Page = lv_page_create(lv_disp_get_scr_act(NULL), NULL); - lv_obj_set_size(Page, hres, vres); - lv_obj_set_pos(Page, 0, 40); - + //INITIALISATION TABLEAU UTILISATEUR - User[1].Nom="Romain BECAN"; User[1].MDP="1234"; User[1].Niveau=3; User[1].Tps=1; + User[1].Nom="Romain BECAN"; User[1].MDP="1234"; User[1].Niveau=3; User[1].Tps=1; User[2].Nom="Guy HERVE"; User[2].MDP="5678"; User[2].Niveau=2; User[2].Tps=120; - User[3].Nom="Gabor KISS VAMOSI"; User[3].MDP="4321"; User[3].Niveau=3; User[3].Tps=2; User[31].Nom="OPERATEUR 1"; User[31].MDP="4321"; User[31].Niveau=1; User[31].Tps=1; User[32].Nom="OPERATEUR 2"; User[32].MDP="4321"; User[32].Niveau=1; User[32].Tps=60; User[33].Nom="OPERATEUR 3"; User[33].MDP="4321"; User[33].Niveau=1; User[33].Tps=40; @@ -571,15 +542,26 @@ static void AFFBandeauHaut(int Num) { - - lv_obj_clean(BandeauHaut); + if(BandeauHaut) { + lv_obj_del(BandeauHaut); + BandeauHaut = NULL; + } + + // CREATION OBJET BANDEAU HAUT + BandeauHaut = lv_cont_create(lv_scr_act(), NULL); + lv_obj_set_size(BandeauHaut,900,40); + lv_cont_set_fit2(BandeauHaut,LV_FIT_TIGHT, LV_FIT_NONE); + lv_obj_set_pos(BandeauHaut, 50, 0); + lv_obj_set_drag_dir(BandeauHaut, LV_DRAG_DIR_HOR); + lv_obj_set_drag_throw(BandeauHaut, true); + //MENU 1 M100 = lv_btn_create(BandeauHaut, NULL); lv_btn_set_ink_in_time(M100, 200); lv_btn_set_ink_wait_time(M100, 100); lv_btn_set_ink_out_time(M100, 500); lv_obj_t * label = lv_label_create(M100, NULL); - lv_label_set_text(label, "Mesures"); + lv_label_set_text(label, _("M100")); lv_obj_set_size(M100,100,40); lv_obj_set_drag_parent(M100, true); lv_obj_set_event_cb(M100, M100_ACT); @@ -590,7 +572,7 @@ lv_btn_set_ink_wait_time(M200, 100); lv_btn_set_ink_out_time(M200, 500); label = lv_label_create(M200, NULL); - lv_label_set_text(label, "Parametres"); + lv_label_set_text(label, _("M200")); lv_obj_set_size(M200,100,40); //lv_btn_set_toggle(M200, true); // lv_btn_toggle(M200); @@ -602,7 +584,7 @@ //MENU 3 M300 = lv_btn_create(BandeauHaut, NULL); label = lv_label_create(M300, NULL); - lv_label_set_text(label, "BPMENU3"); + lv_label_set_text(label, _("M300")); lv_obj_set_size(M300,100,40); lv_obj_align(M300, M200, LV_ALIGN_OUT_RIGHT_MID, 0, 0); lv_obj_set_drag_parent(M300, true); @@ -611,7 +593,7 @@ //MENU 4 M400 = lv_btn_create(BandeauHaut, NULL); label = lv_label_create(M400, NULL); - lv_label_set_text(label, "BPMENU4"); + lv_label_set_text(label, _("M400")); lv_obj_set_size(M400,100,40); lv_obj_align(M400, M300, LV_ALIGN_OUT_RIGHT_MID, 0, 0); lv_obj_set_drag_parent(M400, true); @@ -620,7 +602,7 @@ //MENU 5 M500 = lv_btn_create(BandeauHaut, NULL); label = lv_label_create(M500, NULL); - lv_label_set_text(label, "BPMENU5"); + lv_label_set_text(label, _("M500")); lv_obj_set_size(M500,100,40); lv_obj_align(M500, M400, LV_ALIGN_OUT_RIGHT_MID, 0, 0); lv_obj_set_drag_parent(M500, true); @@ -629,7 +611,7 @@ //BP BPMENU6 M600 = lv_btn_create(BandeauHaut, NULL); label = lv_label_create(M600, NULL); - lv_label_set_text(label, "BPMENU6"); + lv_label_set_text(label, _("M600")); lv_obj_set_size(M600,100,40); lv_obj_align(M600, M500, LV_ALIGN_OUT_RIGHT_MID, 0, 0); lv_obj_set_drag_parent(M600, true); @@ -645,10 +627,7 @@ 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) - //Something like: if(GetObjExist(SousMenu)==1){lv_obj_del(SousMenu);} - //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 - + /*Create a list*/ SousMenu = lv_list_create(lv_scr_act(), NULL); lv_obj_set_size(SousMenu, 100, 100); @@ -659,7 +638,7 @@ Style_BPSM.body.main_color = LV_COLOR_RED; 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 ? + // G/ABOR: 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 // Your intention with looked good you just need to apply it with lv_btn_set_style(SM101, LV_BTN_STYLE_REL, &Style_BPSM); @@ -668,6 +647,7 @@ AnimSousMenu=200;//TAILLE FENETRE SM101 = lv_list_add_btn(SousMenu, NULL, "SM101"); lv_btn_set_style(SM101, LV_BTN_STYLE_REL, &Style_BPSM); + lv_btn_set_style(SM101, LV_BTN_STYLE_PR, &Style_BPSM); if (UserEC.Niveau<0){lv_btn_set_state(SM101, LV_BTN_STATE_INA );} lv_obj_set_event_cb(SM101, SM101_ACT); @@ -700,143 +680,163 @@ lv_obj_set_event_cb(SM202, SM202_ACT); } + //SOUS MENU 300 + if (Num==300){ + AnimSousMenu=300;//TAILLE FENETRE + SM301 = lv_list_add_btn(SousMenu, NULL, _("SM301")); + if (UserEC.Niveau<0){lv_btn_set_state(SM301, LV_BTN_STATE_INA );} + lv_obj_set_event_cb(SM301, SM301_ACT); + } } static void AFFPage(int Num) { - - // lv_obj_clean(Page); + if(Page) { + lv_obj_del(Page); + // lv_obj_clean(Page); + Page = NULL; + } + //MEMORISATION PAGE AFFICHEE + PageAff=Num; + + Page = lv_page_create(lv_scr_act(), NULL); + lv_obj_set_size(Page, hres, vres); + lv_obj_set_pos(Page, 0, 40); + lv_page_set_scrl_layout(Page, LV_LAYOUT_OFF); lv_page_set_scrl_fit2(Page, LV_FIT_FLOOD, LV_FIT_TIGHT); - lv_coord_t max_w = lv_page_get_fit_width(Page); - //affichage données - int i=0; - AffTensionBat = lv_label_create(Page, NULL); - lv_obj_set_pos(AffTensionBat, 50, i); - - AffTpsCy = lv_label_create(Page, NULL); - i=i+16;lv_obj_set_pos(AffTpsCy, 50, i); - - AffCptPuls = lv_label_create(Page, NULL); - i=i+16;lv_obj_set_pos(AffCptPuls, 50, i); - - AffVolume = lv_label_create(Page, NULL); - i=i+16;lv_obj_set_pos(AffVolume, 50, i); - - AffDebit = lv_label_create(Page, NULL); - i=i+16;lv_obj_set_pos(AffDebit, 50, i); + // PAGE 101: Mesures + if (Num==101){ + + //affichage données + int i=0; + AffTensionBat = lv_label_create(Page, NULL); + lv_obj_set_pos(AffTensionBat, 50, i); + + AffTpsCy = lv_label_create(Page, NULL); + i=i+16;lv_obj_set_pos(AffTpsCy, 50, i); + + AffCptPuls = lv_label_create(Page, NULL); + i=i+16;lv_obj_set_pos(AffCptPuls, 50, i); + + AffVolume = lv_label_create(Page, NULL); + i=i+16;lv_obj_set_pos(AffVolume, 50, i); + + AffDebit = lv_label_create(Page, NULL); + i=i+16;lv_obj_set_pos(AffDebit, 50, i); + + Aff1TpsEntre2Puls = lv_label_create(Page, NULL); + i=i+16;lv_obj_set_pos(Aff1TpsEntre2Puls, 50, i); + + Aff2TpsEntre2Puls = lv_label_create(Page, NULL); + i=i+16;lv_obj_set_pos(Aff2TpsEntre2Puls, 50, i); + + AffTpsMinEntre2Puls = lv_label_create(Page, NULL); + i=i+16;lv_obj_set_pos(AffTpsMinEntre2Puls, 50, i); - Aff1TpsEntre2Puls = lv_label_create(Page, NULL); - i=i+16;lv_obj_set_pos(Aff1TpsEntre2Puls, 50, i); - - Aff2TpsEntre2Puls = lv_label_create(Page, NULL); - i=i+16;lv_obj_set_pos(Aff2TpsEntre2Puls, 50, i); - - AffTpsMinEntre2Puls = lv_label_create(Page, NULL); - i=i+16;lv_obj_set_pos(AffTpsMinEntre2Puls, 50, i); + AffTpsMaxEntre2Puls = lv_label_create(Page, NULL); + i=i+16;lv_obj_set_pos(AffTpsMaxEntre2Puls, 50, i); + + //BP RAZ + BPRAZ = lv_btn_create(Page, NULL); + i=i+30;lv_obj_set_pos(BPRAZ, 50, i); + label = lv_label_create(BPRAZ, NULL); + lv_label_set_text(label, "RAZ"); + lv_obj_set_size(BPRAZ,60,40); + lv_obj_set_event_cb(BPRAZ, BPRAZ_ACT); + + //BP POMPE + BPPOMPE = lv_btn_create(Page, NULL); + lv_obj_set_pos(BPPOMPE, 150, i); + label = lv_label_create(BPPOMPE, NULL); + lv_label_set_text(label, "POMPE"); + lv_obj_set_size(BPPOMPE,90,40); + lv_btn_set_toggle(BPPOMPE, true); + lv_obj_set_event_cb(BPPOMPE, BPPOMPE_ACT); + + // SLIDER + static lv_style_t style_bg,style_knob; + static lv_style_t style_indic_R; - AffTpsMaxEntre2Puls = lv_label_create(Page, NULL); - i=i+16;lv_obj_set_pos(AffTpsMaxEntre2Puls, 50, i); - //BP BPMENU4 - BPRAZ = lv_btn_create(Page, NULL); - i=i+30;lv_obj_set_pos(BPRAZ, 50, i); - label = lv_label_create(BPRAZ, NULL); - lv_label_set_text(label, "RAZ"); - lv_obj_set_size(BPRAZ,60,40); - lv_obj_set_event_cb(BPRAZ, BPRAZ_ACT); + lv_style_copy(&style_bg, &lv_style_pretty); + style_bg.body.main_color = LV_COLOR_BLACK; + style_bg.body.grad_color = LV_COLOR_BLACK; + style_bg.body.radius = LV_RADIUS_CIRCLE; + style_bg.body.border.color = LV_COLOR_SILVER; - // SLIDER - static lv_style_t style_bg,style_knob; - static lv_style_t style_indic_R; - - - lv_style_copy(&style_bg, &lv_style_pretty); - style_bg.body.main_color = LV_COLOR_BLACK; - style_bg.body.grad_color = LV_COLOR_BLACK; - style_bg.body.radius = LV_RADIUS_CIRCLE; - style_bg.body.border.color = LV_COLOR_SILVER; - - lv_style_copy(&style_indic_R, &lv_style_pretty_color); - style_indic_R.body.main_color = LV_COLOR_RED; - style_indic_R.body.grad_color = LV_COLOR_RED; - style_indic_R.body.radius = LV_RADIUS_CIRCLE; - style_indic_R.body.shadow.width = 4; - style_indic_R.body.shadow.color = LV_COLOR_RED; - style_indic_R.body.padding.left = 3; - style_indic_R.body.padding.right = 3; - style_indic_R.body.padding.top = 3; - style_indic_R.body.padding.bottom = 3; - - lv_style_copy(&style_knob, &lv_style_pretty); - style_knob.body.radius = LV_RADIUS_CIRCLE; - style_knob.body.opa = LV_OPA_70; - style_knob.body.padding.top = 10 ; - style_knob.body.padding.bottom = 10 ; - - /*Create a slider ROUGE*/ - R = lv_slider_create(Page, NULL); - lv_obj_set_pos(R, 10, 40); - lv_obj_set_width(R, 30); - lv_obj_set_height(R, 180); - lv_slider_set_range(R, 0, 10000); - lv_slider_set_value(R, Reglage_R, false); - style_indic_R.body.main_color = LV_COLOR_RED; - style_indic_R.body.grad_color = LV_COLOR_RED; - style_indic_R.body.shadow.color = LV_COLOR_RED; - lv_slider_set_style(R, LV_SLIDER_STYLE_BG, &style_bg); - lv_slider_set_style(R, LV_SLIDER_STYLE_INDIC,&style_indic_R); - lv_slider_set_style(R, LV_SLIDER_STYLE_KNOB, &style_knob); - lv_obj_set_event_cb(R, Reglage_R_RGB); - Val_R = lv_label_create(Page, NULL); - lv_obj_align(Val_R, R, LV_ALIGN_OUT_TOP_MID, 0, -5); - sprintf(text, " %d ", lv_slider_get_value(R)); - lv_label_set_text(Val_R, text); - + lv_style_copy(&style_indic_R, &lv_style_pretty_color); + style_indic_R.body.main_color = LV_COLOR_RED; + style_indic_R.body.grad_color = LV_COLOR_RED; + style_indic_R.body.radius = LV_RADIUS_CIRCLE; + style_indic_R.body.shadow.width = 4; + style_indic_R.body.shadow.color = LV_COLOR_RED; + style_indic_R.body.padding.left = 3; + style_indic_R.body.padding.right = 3; + style_indic_R.body.padding.top = 3; + style_indic_R.body.padding.bottom = 3; + + lv_style_copy(&style_knob, &lv_style_pretty); + style_knob.body.radius = LV_RADIUS_CIRCLE; + style_knob.body.opa = LV_OPA_70; + style_knob.body.padding.top = 10 ; + style_knob.body.padding.bottom = 10 ; + + /*Create a slider ROUGE*/ + R = lv_slider_create(Page, NULL); + lv_obj_set_pos(R, 10, 40); + lv_obj_set_width(R, 30); + lv_obj_set_height(R, 180); + lv_slider_set_range(R, 0, 10000); + lv_slider_set_value(R, Reglage_R, false); + style_indic_R.body.main_color = LV_COLOR_RED; + style_indic_R.body.grad_color = LV_COLOR_RED; + style_indic_R.body.shadow.color = LV_COLOR_RED; + lv_slider_set_style(R, LV_SLIDER_STYLE_BG, &style_bg); + lv_slider_set_style(R, LV_SLIDER_STYLE_INDIC,&style_indic_R); + lv_slider_set_style(R, LV_SLIDER_STYLE_KNOB, &style_knob); + lv_obj_set_event_cb(R, Reglage_R_RGB); + Val_R = lv_label_create(Page, NULL); + lv_obj_align(Val_R, R, LV_ALIGN_OUT_TOP_MID, 0, -5); + sprintf(text, " %d ", lv_slider_get_value(R)); + lv_label_set_text(Val_R, text); + } + + //PAGE 301 SELECTION LANGUE + if (Num==301){ + //TITRE + label = lv_label_create(Page, NULL); + lv_label_set_text(label, _("SELECTION LANGUE")); + lv_obj_align(label, Page, LV_ALIGN_IN_TOP_MID, 0, 5); + + //BP SELECTION LANGUE: FRANCAIS + lv_obj_t * LANGUE_FR = lv_btn_create(Page, NULL); + lv_obj_align(LANGUE_FR, Page, LV_ALIGN_IN_TOP_MID, -80, 50); + label = lv_label_create(LANGUE_FR, NULL); + lv_label_set_text(label, _("Francais")); + lv_obj_set_size(LANGUE_FR,100,40); + lv_obj_set_event_cb(LANGUE_FR, LANGUE_FR_ACT); + + //BP SELECTION LANGUE: ANGLAIS + lv_obj_t * LANGUE_EN = lv_btn_create(Page, NULL); + lv_obj_align(LANGUE_EN, Page, LV_ALIGN_IN_TOP_MID, 80, 50); + label = lv_label_create(LANGUE_EN, NULL); + lv_label_set_text(label, _("English")); + lv_obj_set_size(LANGUE_EN,100,40); + lv_obj_set_event_cb(LANGUE_EN, LANGUE_EN_ACT); + } + } -static void init_all_themes(uint16_t hue) -{ - // NOTE: This must be adjusted if more themes are added. - int i = 0; -#if LV_USE_THEME_DEFAULT - themes[i++] = lv_theme_default_init(hue, NULL); -#endif -#if LV_USE_THEME_NIGHT - themes[i++] = lv_theme_night_init(hue, NULL); -#endif - -#if LV_USE_THEME_MATERIAL - themes[i++] = lv_theme_material_init(hue, NULL); -#endif - -#if LV_USE_THEME_ALIEN - themes[i++] = lv_theme_alien_init(hue, NULL); -#endif - -#if LV_USE_THEME_ZEN - themes[i++] = lv_theme_zen_init(hue, NULL); -#endif - -#if LV_USE_THEME_NEMO - themes[i++] = lv_theme_nemo_init(hue, NULL); -#endif - -#if LV_USE_THEME_MONO - themes[i++] = lv_theme_mono_init(hue, NULL); -#endif - - -} //******************** // POPUP CONNEXION MDP //******************** @@ -861,13 +861,13 @@ //TITRE label = lv_label_create(PopupMDP, NULL); - lv_label_set_text(label, "IDENTIFICATION"); + lv_label_set_text(label, _("IDENTIFICATION")); lv_obj_align(label, PopupMDP, LV_ALIGN_IN_TOP_MID, 0, 3); lv_obj_set_opa_scale_enable(label, true); lv_obj_set_opa_scale(label, LV_OPA_COVER); //CREATION LISTE UTILISATEUR POUR AFFICHAGE - //GABOR: Mabye you have a better solution than: + //G/ABOR: Mabye you have a better solution than: //ROMAIN: There is no much better way, but I have a few comments int i; int j; @@ -908,8 +908,6 @@ lv_roller_set_visible_row_count(SelectID, 9); 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); @@ -967,35 +965,7 @@ lv_obj_set_size(BpAnnulMDP,100,30); lv_obj_align(BpAnnulMDP, PopupMDP, LV_ALIGN_IN_BOTTOM_MID, 60, -5); label = lv_label_create(BpAnnulMDP, NULL); - //lv_label_set_text(label, "Annuler"); - - //GABOR: Multiligual : see the function "message" - //ROMAIN: lvgl has lv_i18n module for internationalization: https://github.com/littlevgl/lv_i18n - // - It's a script which automatically 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_label_set_text(label, _("Annuler")); lv_obj_set_drag_parent(BpAnnulMDP, true); lv_obj_set_event_cb(BpAnnulMDP, BpAnnulMDP_ACT); @@ -1105,6 +1075,28 @@ } } } +static void BPPOMPE_ACT(lv_obj_t * btn, lv_event_t event) +{ + if(event == LV_EVENT_CLICKED) { + DO_POMPE=!DO_POMPE; + } +} +static void LANGUE_FR_ACT(lv_obj_t * btn, lv_event_t event) +{ + if(event == LV_EVENT_CLICKED) { + lv_i18n_set_locale("fr"); + AFFBandeauHaut(0); + AFFPage(PageAff); + } +} +static void LANGUE_EN_ACT(lv_obj_t * btn, lv_event_t event) +{ + if(event == LV_EVENT_CLICKED) { + lv_i18n_set_locale("en-GB"); + AFFBandeauHaut(0); + AFFPage(PageAff); + } +} static void M100_ACT(lv_obj_t * btn, lv_event_t event) { if(event == LV_EVENT_CLICKED) { @@ -1172,6 +1164,7 @@ } else{ TpsAvFermSousMenu=0; + AFFPage(101); } } } @@ -1255,7 +1248,9 @@ } } } -static void SM203_ACT(lv_obj_t * btn, lv_event_t event) + + +static void SM301_ACT(lv_obj_t * btn, lv_event_t event) { if(event == LV_EVENT_CLICKED) { //VERIFICATION AUTORISATION ACCES @@ -1264,50 +1259,12 @@ AFFPopupMDP(); } else{ - TpsAvFermSousMenu=0; + TpsAvFermSousMenu=0; + AFFPage(301); } } } -//GABOR: is it a Good way to make a multilingual application? -//******************** -// MULTILANGUE -//******************** -//Message multilangue -char * Message(int Num){ - if (Num<900){ - if (Langue==1){Num=Num+1000;}//FRANCAIS - if (Langue==2){Num=Num+2000;}//ANGLAIS - if (Langue==3){Num=Num+3000;}//????? - if (Langue==4){Num=Num+4000;}//????? - } - - switch (Num) { - //FRANCAIS// //ANGLAIS// //????// //????// - case 1000: return "";break; case 2000: return "";break; case 3000: return "";break; case 4000: return "";break; - case 1001: return "ANNULER";break; case 2001: return "CANCEL";break; case 3001: return "VOLUME";break; case 4001: return "VOLUME MESURE";break; - case 1002: return "TEMPERATURE 1";break; case 2002: return "TEMPERATURE 1";break; case 3002: return "TEMPERATURE 1";break; case 4002: return "TEMPERATURE 1";break; - case 1003: return "PRESSION 1";break; case 2003: return "VOLUME";break; case 3003: return "VOLUME";break; case 4003: return "VOLUME MESURE";break; - case 1004: return "HYGROMETRIE 1";break; case 2004: return "VOLUME";break; case 3004: return "VOLUME";break; case 4004: return "VOLUME MESURE";break; - case 1005: return "Masse volumique calculee (T1 P1 H1)";break; case 2005: return "VOLUME";break; case 3005: return "VOLUME";break; case 4005: return "VOLUME MESURE";break; - case 1006: return "Debit massique calcule(1 tour): /";break; case 2006: return "VOLUME";break; case 3006: return "VOLUME";break; case 4006: return "VOLUME MESURE";break; - case 1007: return "Normolitre/min: (DIN1343)";break; case 2007: return "VOLUME";break; case 3007: return "VOLUME";break; case 4007: return "VOLUME MESURE";break; - case 1008: return "Normolitre/min: (ISO2533)";break; case 2008: return "VOLUME";break; case 3008: return "VOLUME";break; case 4008: return "VOLUME MESURE";break; - case 1009: return "Normolitre/min: (Ref Personnalisee)";break; case 2009: return "VOLUME";break; case 3009: return "VOLUME";break; case 4009: return "VOLUME MESURE";break; - case 1010: return "Debit massique calcule(10 tours): / 10";break; case 2010: return "VOLUME";break; case 3010: return "VOLUME";break; case 4010: return "VOLUME MESURE";break; - case 1011: return "DEBIT MASSIQUE MESURE";break; case 2011: return "VOLUME";break; case 3011: return "VOLUME";break; case 4011: return "VOLUME MESURE";break; - case 1012: return "Masse calculee";break; case 2012: return "VOLUME";break; case 3012: return "VOLUME";break; case 4012: return "VOLUME MESURE";break; - case 1013: return "TEMPERATURE 2";break; case 2013: return "VOLUME";break; case 3013: return "VOLUME";break; case 4013: return "VOLUME MESURE";break; - case 1014: return "PRESSION 2";break; case 2014: return "VOLUME";break; case 3014: return "VOLUME";break; case 4014: return "VOLUME MESURE";break; - case 1015: return "HYGROMETRIE 2";break; case 2015: return "VOLUME";break; case 3015: return "VOLUME";break; case 4015: return "VOLUME MESURE";break; - case 1016: return "Masse volumique calculee (T2 P2 H2)";break; case 2016: return "VOLUME";break; case 3016: return "VOLUME";break; case 4016: return "VOLUME MESURE";break; - case 1017: return "Debit volumique calcule (T2 P2 H2)";break; case 2017: return "VOLUME";break; case 3017: return "VOLUME";break; case 4017: return "VOLUME MESURE";break; - case 1018: return "NOMBRE D'IMPULSIONS";break; case 2018: return "VOLUME";break; case 3018: return "VOLUME";break; case 4018: return "VOLUME MESURE";break; - case 1019: return "TOTALISATEUR";break; case 2019: return "VOLUME";break; case 3019: return "VOLUME";break; case 4019: return "VOLUME";break; - case 1020: return "RAZ VOLUME EN COURS";break; case 2020: return "VOLUME";break; case 3020: return "VOLUME";break; case 4020: return "VOLUME MESURE";break; - case 1021: return "RAZ VOLUME EN COURS ET TOTALISATEUR";break; case 2021: return "VOLUME";break; case 3021: return "VOLUME";break; case 4021: return "VOLUME MESURE";break; -} -} //******************** // FONCTIONS GENERALES