THEME AND FONT
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG lvgl_RB FastPWM millis
main.cpp@1:404ee28a0b60, 2020-01-17 (annotated)
- Committer:
- kisvegabor
- Date:
- Fri Jan 17 06:03:24 2020 +0000
- Revision:
- 1:404ee28a0b60
- Parent:
- 0:cf6b1eca3e67
- Child:
- 2:0ded70ebbc36
Gabor added comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
becanromain | 0:cf6b1eca3e67 | 1 | #include "mbed.h" |
becanromain | 0:cf6b1eca3e67 | 2 | #include "TS_DISCO_F746NG.h" |
becanromain | 0:cf6b1eca3e67 | 3 | #include "LCD_DISCO_F746NG.h" |
becanromain | 0:cf6b1eca3e67 | 4 | #include "lvgl/lvgl.h" |
becanromain | 0:cf6b1eca3e67 | 5 | #include "lv_conf.h" |
becanromain | 0:cf6b1eca3e67 | 6 | #include "millis.h" |
becanromain | 0:cf6b1eca3e67 | 7 | #include "FastPWM.h" |
becanromain | 0:cf6b1eca3e67 | 8 | #include <string> |
becanromain | 0:cf6b1eca3e67 | 9 | |
becanromain | 0:cf6b1eca3e67 | 10 | Ticker ticker; //Initialize system tick |
becanromain | 0:cf6b1eca3e67 | 11 | LCD_DISCO_F746NG lcd; //Initialize display driver |
becanromain | 0:cf6b1eca3e67 | 12 | TS_DISCO_F746NG ts; //Initialize touchpad driver |
becanromain | 0:cf6b1eca3e67 | 13 | TS_StateTypeDef TS_State; //Initialize touch state sctruct |
becanromain | 0:cf6b1eca3e67 | 14 | |
becanromain | 0:cf6b1eca3e67 | 15 | Serial serial(USBTX, USBRX); |
becanromain | 0:cf6b1eca3e67 | 16 | |
becanromain | 0:cf6b1eca3e67 | 17 | /********************* |
becanromain | 0:cf6b1eca3e67 | 18 | * ENTREES SORTIES |
becanromain | 0:cf6b1eca3e67 | 19 | *********************/ |
becanromain | 0:cf6b1eca3e67 | 20 | //TENSION BATTERIE |
becanromain | 0:cf6b1eca3e67 | 21 | AnalogIn AI_TENSION_BAT(A4); |
becanromain | 0:cf6b1eca3e67 | 22 | |
becanromain | 0:cf6b1eca3e67 | 23 | //PWM |
becanromain | 0:cf6b1eca3e67 | 24 | FastPWM fastpwm(D12,1); //steup pwm output on pin d12 with a prescaler of 1 |
becanromain | 0:cf6b1eca3e67 | 25 | |
becanromain | 0:cf6b1eca3e67 | 26 | //COMPTEUR IMPULSION |
becanromain | 0:cf6b1eca3e67 | 27 | DigitalIn DI_CPTPuls(D7); |
becanromain | 0:cf6b1eca3e67 | 28 | //InterruptIn DI_CPTPuls(D7); // |
becanromain | 0:cf6b1eca3e67 | 29 | |
becanromain | 0:cf6b1eca3e67 | 30 | /********************** |
becanromain | 0:cf6b1eca3e67 | 31 | * VARIABLES GENERALES |
becanromain | 0:cf6b1eca3e67 | 32 | **********************/ |
becanromain | 0:cf6b1eca3e67 | 33 | int X; |
becanromain | 0:cf6b1eca3e67 | 34 | int Y; |
becanromain | 0:cf6b1eca3e67 | 35 | Timer tempo; |
becanromain | 0:cf6b1eca3e67 | 36 | bool Top1ms; |
becanromain | 0:cf6b1eca3e67 | 37 | bool Top10ms; |
becanromain | 0:cf6b1eca3e67 | 38 | bool Top100ms; |
becanromain | 0:cf6b1eca3e67 | 39 | bool Top1s; |
becanromain | 0:cf6b1eca3e67 | 40 | bool Top5s; |
becanromain | 0:cf6b1eca3e67 | 41 | bool Top1min; |
becanromain | 0:cf6b1eca3e67 | 42 | char text[100]; |
becanromain | 0:cf6b1eca3e67 | 43 | char text2[100]; |
becanromain | 0:cf6b1eca3e67 | 44 | int Langue=1; |
becanromain | 0:cf6b1eca3e67 | 45 | char* Message(int Num); |
becanromain | 0:cf6b1eca3e67 | 46 | |
becanromain | 0:cf6b1eca3e67 | 47 | float TensionBat; |
becanromain | 0:cf6b1eca3e67 | 48 | float MoyTensBat[101]; |
becanromain | 0:cf6b1eca3e67 | 49 | int CsgPompe=0; |
becanromain | 0:cf6b1eca3e67 | 50 | |
becanromain | 0:cf6b1eca3e67 | 51 | uint64_t Micros=0; |
becanromain | 0:cf6b1eca3e67 | 52 | uint64_t CalcTpsCy=0; |
becanromain | 0:cf6b1eca3e67 | 53 | float TpsCy=0; |
becanromain | 0:cf6b1eca3e67 | 54 | |
becanromain | 0:cf6b1eca3e67 | 55 | uint64_t MemMicros0=0; |
becanromain | 0:cf6b1eca3e67 | 56 | uint64_t MemMicros1=0; |
becanromain | 0:cf6b1eca3e67 | 57 | uint64_t MemMicros2=0; |
becanromain | 0:cf6b1eca3e67 | 58 | uint64_t MemMicros3=0; |
becanromain | 0:cf6b1eca3e67 | 59 | uint64_t MemMicros4=0; |
becanromain | 0:cf6b1eca3e67 | 60 | uint64_t MemMicros5=0; |
becanromain | 0:cf6b1eca3e67 | 61 | |
becanromain | 0:cf6b1eca3e67 | 62 | |
becanromain | 0:cf6b1eca3e67 | 63 | int CalcFmPuls; |
becanromain | 0:cf6b1eca3e67 | 64 | int CalcFdPuls; |
becanromain | 0:cf6b1eca3e67 | 65 | bool FmCPTPuls; |
becanromain | 0:cf6b1eca3e67 | 66 | uint64_t TimerPuls=0; |
becanromain | 0:cf6b1eca3e67 | 67 | uint64_t TpsPuls=0; |
becanromain | 0:cf6b1eca3e67 | 68 | float Calcul=0; |
becanromain | 0:cf6b1eca3e67 | 69 | uint64_t MemTpsPuls=0; |
becanromain | 0:cf6b1eca3e67 | 70 | uint64_t MemTps16Puls=0; |
becanromain | 0:cf6b1eca3e67 | 71 | int NumDent=0; |
becanromain | 0:cf6b1eca3e67 | 72 | uint64_t CptPuls=0; |
becanromain | 0:cf6b1eca3e67 | 73 | uint64_t CalcDebit=0; |
becanromain | 0:cf6b1eca3e67 | 74 | float Debit; |
becanromain | 0:cf6b1eca3e67 | 75 | float TpsEntre2Puls[20]; |
becanromain | 0:cf6b1eca3e67 | 76 | float TpsMinEntre2Puls; |
becanromain | 0:cf6b1eca3e67 | 77 | float TpsMaxEntre2Puls; |
becanromain | 0:cf6b1eca3e67 | 78 | float Volume; |
becanromain | 0:cf6b1eca3e67 | 79 | float VolParTour=1200;//en ml |
becanromain | 0:cf6b1eca3e67 | 80 | |
becanromain | 0:cf6b1eca3e67 | 81 | int hres = 480; |
becanromain | 0:cf6b1eca3e67 | 82 | int vres = 272; |
becanromain | 0:cf6b1eca3e67 | 83 | |
becanromain | 0:cf6b1eca3e67 | 84 | |
becanromain | 0:cf6b1eca3e67 | 85 | uint64_t test=0; |
becanromain | 0:cf6b1eca3e67 | 86 | |
becanromain | 0:cf6b1eca3e67 | 87 | //VARIABLES GESTION MOT DE PASSE |
becanromain | 0:cf6b1eca3e67 | 88 | |
becanromain | 0:cf6b1eca3e67 | 89 | |
becanromain | 0:cf6b1eca3e67 | 90 | /********************* |
becanromain | 0:cf6b1eca3e67 | 91 | * OBJET PAGES |
becanromain | 0:cf6b1eca3e67 | 92 | *********************/ |
becanromain | 0:cf6b1eca3e67 | 93 | static lv_obj_t * BandeauHaut; |
becanromain | 0:cf6b1eca3e67 | 94 | static void AFFBandeauHaut(int Num); |
becanromain | 0:cf6b1eca3e67 | 95 | static lv_obj_t * SousMenu; |
becanromain | 0:cf6b1eca3e67 | 96 | static void AFFSousMenu(int Num); |
becanromain | 0:cf6b1eca3e67 | 97 | static lv_obj_t * Page; |
becanromain | 0:cf6b1eca3e67 | 98 | static void AFFPage(int Num); |
becanromain | 0:cf6b1eca3e67 | 99 | |
becanromain | 0:cf6b1eca3e67 | 100 | static lv_obj_t * PopupMDP; |
becanromain | 0:cf6b1eca3e67 | 101 | static void AFFPopupMDP(); |
becanromain | 0:cf6b1eca3e67 | 102 | |
becanromain | 0:cf6b1eca3e67 | 103 | static void init_all_themes(uint16_t hue); |
becanromain | 0:cf6b1eca3e67 | 104 | |
becanromain | 0:cf6b1eca3e67 | 105 | /********************* |
becanromain | 0:cf6b1eca3e67 | 106 | * OBJET GENERAUX |
becanromain | 0:cf6b1eca3e67 | 107 | *********************/ |
becanromain | 0:cf6b1eca3e67 | 108 | static lv_obj_t *mbox; |
becanromain | 0:cf6b1eca3e67 | 109 | |
becanromain | 0:cf6b1eca3e67 | 110 | /***************************** |
becanromain | 0:cf6b1eca3e67 | 111 | * VARIABLES/OBJETS CONNEXION |
becanromain | 0:cf6b1eca3e67 | 112 | *****************************/ |
becanromain | 0:cf6b1eca3e67 | 113 | static lv_obj_t * SelectID; |
becanromain | 0:cf6b1eca3e67 | 114 | static lv_obj_t * MDP; |
becanromain | 0:cf6b1eca3e67 | 115 | static void SelectID_ACT(lv_obj_t * obj, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 116 | uint32_t TpsMdpEnCours=0; |
becanromain | 0:cf6b1eca3e67 | 117 | struct Personne |
becanromain | 0:cf6b1eca3e67 | 118 | { |
becanromain | 0:cf6b1eca3e67 | 119 | string Nom; |
becanromain | 0:cf6b1eca3e67 | 120 | string MDP; //mot de passe à 4 chiffres |
becanromain | 0:cf6b1eca3e67 | 121 | int Niveau; //0:aucun 1:Opérateur 2:superviseur 3:constructeur |
becanromain | 0:cf6b1eca3e67 | 122 | int Tps; //Temps de connexion |
becanromain | 0:cf6b1eca3e67 | 123 | }; |
becanromain | 0:cf6b1eca3e67 | 124 | Personne User[100]; |
becanromain | 0:cf6b1eca3e67 | 125 | Personne UserEC; |
becanromain | 0:cf6b1eca3e67 | 126 | static void BpValidMDP_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 127 | static void BpAnnulMDP_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 128 | static void mboxMdp_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 129 | static void mboxMdp_ACT2(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 130 | |
becanromain | 0:cf6b1eca3e67 | 131 | /********************* |
becanromain | 0:cf6b1eca3e67 | 132 | * OBJETS BP MENU |
becanromain | 0:cf6b1eca3e67 | 133 | *********************/ |
becanromain | 0:cf6b1eca3e67 | 134 | static lv_obj_t * M100; |
becanromain | 0:cf6b1eca3e67 | 135 | static lv_obj_t * M200; |
becanromain | 0:cf6b1eca3e67 | 136 | static lv_obj_t * M300; |
becanromain | 0:cf6b1eca3e67 | 137 | static lv_obj_t * M400; |
becanromain | 0:cf6b1eca3e67 | 138 | static lv_obj_t * M500; |
becanromain | 0:cf6b1eca3e67 | 139 | static lv_obj_t * M600; |
becanromain | 0:cf6b1eca3e67 | 140 | |
becanromain | 0:cf6b1eca3e67 | 141 | static lv_obj_t * SM101; |
becanromain | 0:cf6b1eca3e67 | 142 | static lv_obj_t * SM102; |
becanromain | 0:cf6b1eca3e67 | 143 | static lv_obj_t * SM103; |
becanromain | 0:cf6b1eca3e67 | 144 | static lv_obj_t * SM104; |
becanromain | 0:cf6b1eca3e67 | 145 | static lv_obj_t * SM105; |
becanromain | 0:cf6b1eca3e67 | 146 | static lv_obj_t * SM106; |
becanromain | 0:cf6b1eca3e67 | 147 | |
becanromain | 0:cf6b1eca3e67 | 148 | static lv_obj_t * SM201; |
becanromain | 0:cf6b1eca3e67 | 149 | static lv_obj_t * SM202; |
becanromain | 0:cf6b1eca3e67 | 150 | static lv_obj_t * SM203; |
becanromain | 0:cf6b1eca3e67 | 151 | static lv_obj_t * SM204; |
becanromain | 0:cf6b1eca3e67 | 152 | static lv_obj_t * SM205; |
becanromain | 0:cf6b1eca3e67 | 153 | static lv_obj_t * SM206; |
becanromain | 0:cf6b1eca3e67 | 154 | |
becanromain | 0:cf6b1eca3e67 | 155 | //FONCTIONS ASSOCIEES |
becanromain | 0:cf6b1eca3e67 | 156 | static void M100_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 157 | static void M200_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 158 | static void M300_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 159 | static void M400_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 160 | static void M500_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 161 | static void M600_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 162 | |
becanromain | 0:cf6b1eca3e67 | 163 | static void SM101_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 164 | static void SM102_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 165 | static void SM103_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 166 | static void SM104_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 167 | static void SM105_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 168 | |
becanromain | 0:cf6b1eca3e67 | 169 | static void SM201_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 170 | static void SM202_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 171 | static void SM203_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 172 | static void SM204_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 173 | static void SM205_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 174 | |
becanromain | 0:cf6b1eca3e67 | 175 | /********************* |
becanromain | 0:cf6b1eca3e67 | 176 | * OBJETS |
becanromain | 0:cf6b1eca3e67 | 177 | *********************/ |
becanromain | 0:cf6b1eca3e67 | 178 | static lv_obj_t *FondGris ; |
becanromain | 0:cf6b1eca3e67 | 179 | static lv_obj_t *FondGris2 ; |
becanromain | 0:cf6b1eca3e67 | 180 | |
becanromain | 0:cf6b1eca3e67 | 181 | /********************* |
becanromain | 0:cf6b1eca3e67 | 182 | * MATRICE DE BOUTONS |
becanromain | 0:cf6b1eca3e67 | 183 | *********************/ |
becanromain | 0:cf6b1eca3e67 | 184 | static const char * PAVE_NUMERIQUE_MAP[] = {"7", "8", "9","\n", |
becanromain | 0:cf6b1eca3e67 | 185 | "4", "5","6", "\n", |
becanromain | 0:cf6b1eca3e67 | 186 | "1", "2", "3","\n", |
becanromain | 0:cf6b1eca3e67 | 187 | "0", LV_SYMBOL_BACKSPACE, ""}; |
becanromain | 0:cf6b1eca3e67 | 188 | /********************* |
becanromain | 0:cf6b1eca3e67 | 189 | * STYLES |
becanromain | 0:cf6b1eca3e67 | 190 | *********************/ |
becanromain | 0:cf6b1eca3e67 | 191 | static lv_style_t Style_texte1; |
becanromain | 0:cf6b1eca3e67 | 192 | static lv_style_t Style_texte2; |
becanromain | 0:cf6b1eca3e67 | 193 | static lv_style_t Style_BPM; |
becanromain | 0:cf6b1eca3e67 | 194 | static lv_style_t Style_BPSM; |
becanromain | 0:cf6b1eca3e67 | 195 | static lv_style_t Style_BPSMInactif; |
becanromain | 0:cf6b1eca3e67 | 196 | static lv_style_t Style_BP; |
becanromain | 0:cf6b1eca3e67 | 197 | |
becanromain | 0:cf6b1eca3e67 | 198 | |
becanromain | 0:cf6b1eca3e67 | 199 | |
becanromain | 0:cf6b1eca3e67 | 200 | /********************* |
becanromain | 0:cf6b1eca3e67 | 201 | * FONCTION |
becanromain | 0:cf6b1eca3e67 | 202 | *********************/ |
becanromain | 0:cf6b1eca3e67 | 203 | void initialisation(); |
becanromain | 0:cf6b1eca3e67 | 204 | void interruptCompteur(); |
becanromain | 0:cf6b1eca3e67 | 205 | |
becanromain | 0:cf6b1eca3e67 | 206 | static void BPRAZ_ACT(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 207 | static lv_theme_t * th_act; |
becanromain | 0:cf6b1eca3e67 | 208 | static lv_obj_t * label; |
becanromain | 0:cf6b1eca3e67 | 209 | static lv_obj_t * label1; |
becanromain | 0:cf6b1eca3e67 | 210 | |
becanromain | 0:cf6b1eca3e67 | 211 | |
becanromain | 0:cf6b1eca3e67 | 212 | static lv_obj_t * AffTensionBat; |
becanromain | 0:cf6b1eca3e67 | 213 | static lv_obj_t * AffTpsCy; |
becanromain | 0:cf6b1eca3e67 | 214 | static lv_obj_t * AffCptPuls; |
becanromain | 0:cf6b1eca3e67 | 215 | static lv_obj_t * AffDebit; |
becanromain | 0:cf6b1eca3e67 | 216 | static lv_obj_t * Aff1TpsEntre2Puls; |
becanromain | 0:cf6b1eca3e67 | 217 | static lv_obj_t * Aff2TpsEntre2Puls; |
becanromain | 0:cf6b1eca3e67 | 218 | static lv_obj_t * AffTpsMinEntre2Puls; |
becanromain | 0:cf6b1eca3e67 | 219 | static lv_obj_t * AffTpsMaxEntre2Puls; |
becanromain | 0:cf6b1eca3e67 | 220 | static lv_obj_t * AffVolume; |
becanromain | 0:cf6b1eca3e67 | 221 | static lv_obj_t * BPRAZ; |
becanromain | 0:cf6b1eca3e67 | 222 | |
becanromain | 0:cf6b1eca3e67 | 223 | uint8_t NumSousMenu=1; |
becanromain | 0:cf6b1eca3e67 | 224 | |
becanromain | 0:cf6b1eca3e67 | 225 | LV_FONT_DECLARE(arial_20) //Declare a font |
becanromain | 0:cf6b1eca3e67 | 226 | |
becanromain | 0:cf6b1eca3e67 | 227 | void lv_ticker_func(); |
becanromain | 0:cf6b1eca3e67 | 228 | void my_disp_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_t* color_p); |
becanromain | 0:cf6b1eca3e67 | 229 | bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data); |
becanromain | 0:cf6b1eca3e67 | 230 | static void event_handler(lv_obj_t * obj, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 231 | //void btn_event_cb(lv_obj_t * btn, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 232 | |
becanromain | 0:cf6b1eca3e67 | 233 | |
becanromain | 0:cf6b1eca3e67 | 234 | |
becanromain | 0:cf6b1eca3e67 | 235 | static void ddlist_event_cb(lv_obj_t * ddlist, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 236 | static lv_obj_t * slider; |
becanromain | 0:cf6b1eca3e67 | 237 | |
becanromain | 0:cf6b1eca3e67 | 238 | int PosX_MenuDepart = 0; |
becanromain | 0:cf6b1eca3e67 | 239 | int PosX_MenuCible = 0; |
becanromain | 0:cf6b1eca3e67 | 240 | bool DdeAlignMenu = 0; |
becanromain | 0:cf6b1eca3e67 | 241 | |
becanromain | 0:cf6b1eca3e67 | 242 | int PosY_AnimSousMenu = 0; |
becanromain | 0:cf6b1eca3e67 | 243 | int AnimSousMenu=0; |
becanromain | 0:cf6b1eca3e67 | 244 | int TpsAvFermSousMenu=2000; |
becanromain | 0:cf6b1eca3e67 | 245 | |
becanromain | 0:cf6b1eca3e67 | 246 | static void Reglage_R_RGB(lv_obj_t * obj, lv_event_t event); |
becanromain | 0:cf6b1eca3e67 | 247 | |
becanromain | 0:cf6b1eca3e67 | 248 | int TestAff = 0; |
becanromain | 0:cf6b1eca3e67 | 249 | |
becanromain | 0:cf6b1eca3e67 | 250 | |
becanromain | 0:cf6b1eca3e67 | 251 | static lv_obj_t * Val_R; |
becanromain | 0:cf6b1eca3e67 | 252 | |
becanromain | 0:cf6b1eca3e67 | 253 | static lv_obj_t * R; |
becanromain | 0:cf6b1eca3e67 | 254 | |
becanromain | 0:cf6b1eca3e67 | 255 | |
becanromain | 0:cf6b1eca3e67 | 256 | int Reglage_R; |
becanromain | 0:cf6b1eca3e67 | 257 | uint8_t Reglage_G; |
becanromain | 0:cf6b1eca3e67 | 258 | uint8_t Reglage_B; |
becanromain | 0:cf6b1eca3e67 | 259 | uint32_t Reglage_RGB; |
becanromain | 0:cf6b1eca3e67 | 260 | |
becanromain | 0:cf6b1eca3e67 | 261 | |
becanromain | 0:cf6b1eca3e67 | 262 | uint8_t R1=255,G1=255,B1=255, |
becanromain | 0:cf6b1eca3e67 | 263 | R2=0 ,G2=0 ,B2=0, |
becanromain | 0:cf6b1eca3e67 | 264 | R3=255 ,G3=255 ,B3=255, |
becanromain | 0:cf6b1eca3e67 | 265 | R4=0,G4=0,B4=0, |
becanromain | 0:cf6b1eca3e67 | 266 | R5=145,G5=145,B5=145, |
becanromain | 0:cf6b1eca3e67 | 267 | R6=255,G6=255,B6=255, |
becanromain | 0:cf6b1eca3e67 | 268 | R7=0,G7=0,B7=0, |
becanromain | 0:cf6b1eca3e67 | 269 | R8=73,G8=143,B8=64, |
becanromain | 0:cf6b1eca3e67 | 270 | R9=0,G9=255,B9=0, |
becanromain | 0:cf6b1eca3e67 | 271 | R10=155,G10=238,B10=131, |
becanromain | 0:cf6b1eca3e67 | 272 | R11=145,G11=145,B11=145, |
becanromain | 0:cf6b1eca3e67 | 273 | R12=51,G12=37,B12=22, |
becanromain | 0:cf6b1eca3e67 | 274 | R13=255,G13=255,B13=255, |
becanromain | 0:cf6b1eca3e67 | 275 | R14=153,G14=158,B14=117, |
becanromain | 0:cf6b1eca3e67 | 276 | R15=107,G15=154,B15=199, |
becanromain | 0:cf6b1eca3e67 | 277 | R16=107,G16=154,B16=199, |
becanromain | 0:cf6b1eca3e67 | 278 | R17=107,G17=154,B17=199, |
becanromain | 0:cf6b1eca3e67 | 279 | R18=107,G18=154,B18=199, |
becanromain | 0:cf6b1eca3e67 | 280 | R19=107,G19=154,B19=199; |
becanromain | 0:cf6b1eca3e67 | 281 | |
becanromain | 0:cf6b1eca3e67 | 282 | |
becanromain | 0:cf6b1eca3e67 | 283 | int NumCouleur=0; |
becanromain | 0:cf6b1eca3e67 | 284 | |
becanromain | 0:cf6b1eca3e67 | 285 | lv_obj_t * th_roller ; |
becanromain | 0:cf6b1eca3e67 | 286 | |
becanromain | 0:cf6b1eca3e67 | 287 | |
becanromain | 0:cf6b1eca3e67 | 288 | |
becanromain | 0:cf6b1eca3e67 | 289 | static const char * th_options = { |
becanromain | 0:cf6b1eca3e67 | 290 | #if LV_USE_THEME_DEFAULT |
becanromain | 0:cf6b1eca3e67 | 291 | "Default" |
becanromain | 0:cf6b1eca3e67 | 292 | #endif |
becanromain | 0:cf6b1eca3e67 | 293 | |
becanromain | 0:cf6b1eca3e67 | 294 | #if LV_USE_THEME_NIGHT |
becanromain | 0:cf6b1eca3e67 | 295 | "\nNight" |
becanromain | 0:cf6b1eca3e67 | 296 | #endif |
becanromain | 0:cf6b1eca3e67 | 297 | |
becanromain | 0:cf6b1eca3e67 | 298 | #if LV_USE_THEME_MATERIAL |
becanromain | 0:cf6b1eca3e67 | 299 | "\nMaterial" |
becanromain | 0:cf6b1eca3e67 | 300 | #endif |
becanromain | 0:cf6b1eca3e67 | 301 | |
becanromain | 0:cf6b1eca3e67 | 302 | #if LV_USE_THEME_ALIEN |
becanromain | 0:cf6b1eca3e67 | 303 | "\nAlien" |
becanromain | 0:cf6b1eca3e67 | 304 | #endif |
becanromain | 0:cf6b1eca3e67 | 305 | |
becanromain | 0:cf6b1eca3e67 | 306 | #if LV_USE_THEME_ZEN |
becanromain | 0:cf6b1eca3e67 | 307 | "\nZen" |
becanromain | 0:cf6b1eca3e67 | 308 | #endif |
becanromain | 0:cf6b1eca3e67 | 309 | |
becanromain | 0:cf6b1eca3e67 | 310 | #if LV_USE_THEME_NEMO |
becanromain | 0:cf6b1eca3e67 | 311 | "\nNemo" |
becanromain | 0:cf6b1eca3e67 | 312 | #endif |
becanromain | 0:cf6b1eca3e67 | 313 | |
becanromain | 0:cf6b1eca3e67 | 314 | #if LV_USE_THEME_MONO |
becanromain | 0:cf6b1eca3e67 | 315 | "\nMono" |
becanromain | 0:cf6b1eca3e67 | 316 | #endif |
becanromain | 0:cf6b1eca3e67 | 317 | |
becanromain | 0:cf6b1eca3e67 | 318 | |
becanromain | 0:cf6b1eca3e67 | 319 | "" |
becanromain | 0:cf6b1eca3e67 | 320 | }; |
becanromain | 0:cf6b1eca3e67 | 321 | |
becanromain | 0:cf6b1eca3e67 | 322 | static lv_theme_t * themes[8]; |
becanromain | 0:cf6b1eca3e67 | 323 | |
becanromain | 0:cf6b1eca3e67 | 324 | |
becanromain | 0:cf6b1eca3e67 | 325 | int main() |
becanromain | 0:cf6b1eca3e67 | 326 | { |
becanromain | 0:cf6b1eca3e67 | 327 | //demarrage communication avec PC |
becanromain | 0:cf6b1eca3e67 | 328 | serial.baud(9600); |
becanromain | 0:cf6b1eca3e67 | 329 | serial.printf("DEBUT DE PROGRAMME\r\n"); |
becanromain | 0:cf6b1eca3e67 | 330 | //Entree impulsion |
becanromain | 0:cf6b1eca3e67 | 331 | DI_CPTPuls.mode(PullUp); |
becanromain | 0:cf6b1eca3e67 | 332 | |
becanromain | 0:cf6b1eca3e67 | 333 | //lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"LittlevGL DEMO", CENTER_MODE); |
becanromain | 0:cf6b1eca3e67 | 334 | ticker.attach(&lv_ticker_func,0.005);// Appel de la fonction LittlVGL toutes les 5ms |
becanromain | 0:cf6b1eca3e67 | 335 | wait(0.5); |
becanromain | 0:cf6b1eca3e67 | 336 | lv_init(); //Initialize the LittlevGL |
becanromain | 0:cf6b1eca3e67 | 337 | |
becanromain | 0:cf6b1eca3e67 | 338 | static lv_disp_buf_t disp_buf; |
becanromain | 0:cf6b1eca3e67 | 339 | static lv_color_t buf[LV_HOR_RES_MAX * 10]; //Declare a buffer for 10 lines |
becanromain | 0:cf6b1eca3e67 | 340 | lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); //Initialize the display buffer |
becanromain | 0:cf6b1eca3e67 | 341 | |
becanromain | 0:cf6b1eca3e67 | 342 | //Implement and register a function which can copy a pixel array to an area of your display |
becanromain | 0:cf6b1eca3e67 | 343 | lv_disp_drv_t disp_drv; //Descriptor of a display driver |
becanromain | 0:cf6b1eca3e67 | 344 | lv_disp_drv_init(&disp_drv); //Basic initialization |
becanromain | 0:cf6b1eca3e67 | 345 | disp_drv.flush_cb = my_disp_flush; //Set your driver function |
becanromain | 0:cf6b1eca3e67 | 346 | disp_drv.buffer = &disp_buf; //Assign the buffer to the display |
becanromain | 0:cf6b1eca3e67 | 347 | lv_disp_drv_register(&disp_drv); //Finally register the driver |
becanromain | 0:cf6b1eca3e67 | 348 | |
becanromain | 0:cf6b1eca3e67 | 349 | //Implement and register a function which can read an input device. E.g. for a touch pad |
becanromain | 0:cf6b1eca3e67 | 350 | ts.Init(lcd.GetXSize(), lcd.GetYSize()); //ST touch initialization |
becanromain | 0:cf6b1eca3e67 | 351 | lv_indev_drv_t indev_drv; //Descriptor of a input device driver |
becanromain | 0:cf6b1eca3e67 | 352 | lv_indev_drv_init(&indev_drv); //Basic initialization |
becanromain | 0:cf6b1eca3e67 | 353 | indev_drv.type = LV_INDEV_TYPE_POINTER; //Touch pad is a pointer-like device |
becanromain | 0:cf6b1eca3e67 | 354 | indev_drv.read_cb = my_touchpad_read; //Set your driver function |
becanromain | 0:cf6b1eca3e67 | 355 | lv_indev_drv_register(&indev_drv); //Finally register the driver |
becanromain | 0:cf6b1eca3e67 | 356 | |
becanromain | 0:cf6b1eca3e67 | 357 | |
becanromain | 0:cf6b1eca3e67 | 358 | initialisation(); |
becanromain | 0:cf6b1eca3e67 | 359 | AFFBandeauHaut(0); |
becanromain | 0:cf6b1eca3e67 | 360 | AFFPage(0); |
becanromain | 0:cf6b1eca3e67 | 361 | |
becanromain | 0:cf6b1eca3e67 | 362 | //demarrage tempo générale |
becanromain | 0:cf6b1eca3e67 | 363 | tempo.start(); |
becanromain | 0:cf6b1eca3e67 | 364 | //Interruption compteur |
becanromain | 0:cf6b1eca3e67 | 365 | // DI_CPTPuls.rise(&interruptCompteur); |
becanromain | 0:cf6b1eca3e67 | 366 | |
becanromain | 0:cf6b1eca3e67 | 367 | while(1) { |
becanromain | 0:cf6b1eca3e67 | 368 | |
becanromain | 0:cf6b1eca3e67 | 369 | //TEMPO GENERALE |
becanromain | 0:cf6b1eca3e67 | 370 | Micros=tempo.read_high_resolution_us(); |
becanromain | 0:cf6b1eca3e67 | 371 | //TOP base de temps |
becanromain | 0:cf6b1eca3e67 | 372 | Top1ms=false; if (Micros>=MemMicros0+1000) { Top1ms=true; MemMicros0=MemMicros0+1000; } |
becanromain | 0:cf6b1eca3e67 | 373 | Top10ms=false; if (Micros>=MemMicros1+10000) { Top10ms=true; MemMicros1=MemMicros1+10000; } |
becanromain | 0:cf6b1eca3e67 | 374 | Top100ms=false; if (Micros>=MemMicros2+100000) { Top100ms=true; MemMicros2=MemMicros2+100000; } |
becanromain | 0:cf6b1eca3e67 | 375 | Top1s=false; if (Micros>=MemMicros3+1000000) { Top1s=true; MemMicros3=MemMicros3+1000000; } |
becanromain | 0:cf6b1eca3e67 | 376 | Top5s=false; if (Micros>=MemMicros4+5000000) { Top5s=true; MemMicros4=MemMicros4+5000000; } |
becanromain | 0:cf6b1eca3e67 | 377 | Top1min=false; if (Micros>=MemMicros5+60000000) { Top1min=true; MemMicros5=MemMicros5+60000000; } |
becanromain | 0:cf6b1eca3e67 | 378 | |
becanromain | 0:cf6b1eca3e67 | 379 | //CALCUL TEMPS DE CYCLE |
becanromain | 0:cf6b1eca3e67 | 380 | CalcTpsCy++; |
becanromain | 0:cf6b1eca3e67 | 381 | if (Top1s){ |
becanromain | 0:cf6b1eca3e67 | 382 | TpsCy=1000000000/CalcTpsCy; |
becanromain | 0:cf6b1eca3e67 | 383 | TpsCy=TpsCy/1000; |
becanromain | 0:cf6b1eca3e67 | 384 | test=CalcTpsCy; |
becanromain | 0:cf6b1eca3e67 | 385 | CalcTpsCy=0; |
becanromain | 0:cf6b1eca3e67 | 386 | } |
becanromain | 0:cf6b1eca3e67 | 387 | //Raffraichissement affichage toutes les 10ms |
becanromain | 0:cf6b1eca3e67 | 388 | if (Top10ms){ |
becanromain | 0:cf6b1eca3e67 | 389 | lv_task_handler(); |
becanromain | 0:cf6b1eca3e67 | 390 | } |
becanromain | 0:cf6b1eca3e67 | 391 | |
becanromain | 0:cf6b1eca3e67 | 392 | //MISE A JOUR DES VARIABLES AFFICHEES |
becanromain | 0:cf6b1eca3e67 | 393 | if (Top1s){ |
becanromain | 0:cf6b1eca3e67 | 394 | // serial.printf("MICROS %d \r\n",Micros); |
becanromain | 0:cf6b1eca3e67 | 395 | sprintf(text, "Temps de cycle = %3.3f us",TpsCy); lv_label_set_text(AffTpsCy, text); |
becanromain | 0:cf6b1eca3e67 | 396 | sprintf(text, "Tension= %3.3f V ",TensionBat ); lv_label_set_text(AffTensionBat, text); |
becanromain | 0:cf6b1eca3e67 | 397 | sprintf(text, "Nombre d'impulsion= %d ",CptPuls ); lv_label_set_text(AffCptPuls, text); |
becanromain | 0:cf6b1eca3e67 | 398 | sprintf(text, "Volume = %3.3f L",Volume ); lv_label_set_text(AffVolume, text); |
becanromain | 0:cf6b1eca3e67 | 399 | sprintf(text, "Debit= %3.3f L/min ",Debit ); lv_label_set_text(AffDebit, text); |
becanromain | 0:cf6b1eca3e67 | 400 | 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); |
becanromain | 0:cf6b1eca3e67 | 401 | 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); |
becanromain | 0:cf6b1eca3e67 | 402 | sprintf(text, "Temps mini entre 2 impulsions = %d ",Micros ); lv_label_set_text(AffTpsMinEntre2Puls, text); |
becanromain | 0:cf6b1eca3e67 | 403 | sprintf(text, "Temps maxi entre 2 impulsions = %d",test ); lv_label_set_text(AffTpsMaxEntre2Puls, text); |
becanromain | 0:cf6b1eca3e67 | 404 | } |
becanromain | 0:cf6b1eca3e67 | 405 | |
becanromain | 0:cf6b1eca3e67 | 406 | //DETECTION IMPULSION |
becanromain | 0:cf6b1eca3e67 | 407 | if (DI_CPTPuls and Top1ms){ CalcFdPuls=0;CalcFmPuls++;} |
becanromain | 0:cf6b1eca3e67 | 408 | if (not DI_CPTPuls and Top1ms){ CalcFmPuls=0;CalcFdPuls++;} |
becanromain | 0:cf6b1eca3e67 | 409 | if (CalcFmPuls>20 and not FmCPTPuls){interruptCompteur();FmCPTPuls=true;} |
becanromain | 0:cf6b1eca3e67 | 410 | if (CalcFdPuls>20 and FmCPTPuls){FmCPTPuls=false;} |
becanromain | 0:cf6b1eca3e67 | 411 | if (CalcFmPuls>500){CalcFmPuls=500;} |
becanromain | 0:cf6b1eca3e67 | 412 | if (CalcFdPuls>500){CalcFdPuls=500;} |
becanromain | 0:cf6b1eca3e67 | 413 | |
becanromain | 0:cf6b1eca3e67 | 414 | //MESURE TENSION BATTERIE |
becanromain | 0:cf6b1eca3e67 | 415 | if (Top10ms){ |
becanromain | 0:cf6b1eca3e67 | 416 | MoyTensBat[0]=AI_TENSION_BAT.read()*3.3*2; |
becanromain | 0:cf6b1eca3e67 | 417 | TensionBat=0; |
becanromain | 0:cf6b1eca3e67 | 418 | for (int i=100;i>0;i--){ |
becanromain | 0:cf6b1eca3e67 | 419 | MoyTensBat[i]=MoyTensBat[i-1]; |
becanromain | 0:cf6b1eca3e67 | 420 | TensionBat=TensionBat+MoyTensBat[i]; |
becanromain | 0:cf6b1eca3e67 | 421 | } |
becanromain | 0:cf6b1eca3e67 | 422 | TensionBat=TensionBat/100; |
becanromain | 0:cf6b1eca3e67 | 423 | } |
becanromain | 0:cf6b1eca3e67 | 424 | |
becanromain | 0:cf6b1eca3e67 | 425 | //COMMANDE POMPE PWM |
becanromain | 0:cf6b1eca3e67 | 426 | if (Top100ms){ |
becanromain | 0:cf6b1eca3e67 | 427 | CsgPompe=Reglage_R; |
becanromain | 0:cf6b1eca3e67 | 428 | fastpwm.period_ticks (10000); //setup the period for 100Khz |
becanromain | 0:cf6b1eca3e67 | 429 | fastpwm.pulsewidth_ticks(CsgPompe);//setup duty cycle to 50% |
becanromain | 0:cf6b1eca3e67 | 430 | } |
becanromain | 0:cf6b1eca3e67 | 431 | //RAZ MOT DE PASSE |
becanromain | 0:cf6b1eca3e67 | 432 | if (TpsMdpEnCours>0 and Top1s){ |
becanromain | 0:cf6b1eca3e67 | 433 | TpsMdpEnCours--; |
becanromain | 0:cf6b1eca3e67 | 434 | if (TpsMdpEnCours==0){ |
becanromain | 0:cf6b1eca3e67 | 435 | mbox=lv_mbox_create(lv_disp_get_scr_act(NULL), NULL); |
becanromain | 0:cf6b1eca3e67 | 436 | sprintf(text, "Fin de connexion pour %s",UserEC.Nom ); |
becanromain | 0:cf6b1eca3e67 | 437 | lv_mbox_set_text(mbox, text); |
becanromain | 0:cf6b1eca3e67 | 438 | lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 439 | lv_mbox_start_auto_close(mbox, 3000); |
becanromain | 0:cf6b1eca3e67 | 440 | UserEC.Nom=""; |
becanromain | 0:cf6b1eca3e67 | 441 | UserEC.Niveau=0; |
becanromain | 0:cf6b1eca3e67 | 442 | } |
becanromain | 0:cf6b1eca3e67 | 443 | } |
becanromain | 0:cf6b1eca3e67 | 444 | |
becanromain | 0:cf6b1eca3e67 | 445 | //ANIMATION MENU |
becanromain | 0:cf6b1eca3e67 | 446 | if (Top1ms){ |
becanromain | 0:cf6b1eca3e67 | 447 | if (DdeAlignMenu) { |
becanromain | 0:cf6b1eca3e67 | 448 | if (PosX_MenuDepart>PosX_MenuCible) { |
becanromain | 0:cf6b1eca3e67 | 449 | PosX_MenuDepart=PosX_MenuDepart-1; |
becanromain | 0:cf6b1eca3e67 | 450 | lv_obj_set_pos(BandeauHaut, PosX_MenuDepart, 0); |
becanromain | 0:cf6b1eca3e67 | 451 | } |
becanromain | 0:cf6b1eca3e67 | 452 | if (PosX_MenuDepart<PosX_MenuCible) { |
becanromain | 0:cf6b1eca3e67 | 453 | PosX_MenuDepart=PosX_MenuDepart+1; |
becanromain | 0:cf6b1eca3e67 | 454 | lv_obj_set_pos(BandeauHaut, PosX_MenuDepart, 0); |
becanromain | 0:cf6b1eca3e67 | 455 | } |
becanromain | 0:cf6b1eca3e67 | 456 | if (PosX_MenuDepart==PosX_MenuCible) { |
becanromain | 0:cf6b1eca3e67 | 457 | DdeAlignMenu=0; |
becanromain | 0:cf6b1eca3e67 | 458 | AFFSousMenu(NumSousMenu);//affichage page sous menu |
becanromain | 0:cf6b1eca3e67 | 459 | } |
becanromain | 0:cf6b1eca3e67 | 460 | } |
becanromain | 0:cf6b1eca3e67 | 461 | } |
becanromain | 0:cf6b1eca3e67 | 462 | |
becanromain | 0:cf6b1eca3e67 | 463 | //ANIMATION SOUS MENU |
becanromain | 0:cf6b1eca3e67 | 464 | if (Top1ms){ |
becanromain | 0:cf6b1eca3e67 | 465 | |
becanromain | 0:cf6b1eca3e67 | 466 | //OUVERTURE SOUS MENU |
becanromain | 0:cf6b1eca3e67 | 467 | if (AnimSousMenu>0) { |
becanromain | 0:cf6b1eca3e67 | 468 | PosY_AnimSousMenu=PosY_AnimSousMenu+2; |
becanromain | 0:cf6b1eca3e67 | 469 | lv_obj_set_size(SousMenu, 100, PosY_AnimSousMenu); |
becanromain | 0:cf6b1eca3e67 | 470 | if (PosY_AnimSousMenu>=AnimSousMenu){AnimSousMenu=0;} |
kisvegabor | 1:404ee28a0b60 | 471 | TpsAvFermSousMenu=4000; |
becanromain | 0:cf6b1eca3e67 | 472 | } |
becanromain | 0:cf6b1eca3e67 | 473 | //TEMPS AVANT FERMEURE |
kisvegabor | 1:404ee28a0b60 | 474 | if (SousMenu and TpsAvFermSousMenu>0){TpsAvFermSousMenu--;} |
becanromain | 0:cf6b1eca3e67 | 475 | //FERMETURE SOUS MENU |
kisvegabor | 1:404ee28a0b60 | 476 | if (SousMenu and TpsAvFermSousMenu<=0) { |
becanromain | 0:cf6b1eca3e67 | 477 | PosY_AnimSousMenu=PosY_AnimSousMenu-2; |
becanromain | 0:cf6b1eca3e67 | 478 | lv_obj_set_size(SousMenu, 100, PosY_AnimSousMenu); |
kisvegabor | 1:404ee28a0b60 | 479 | if (PosY_AnimSousMenu<=0){ |
kisvegabor | 1:404ee28a0b60 | 480 | lv_obj_del_async(SousMenu); |
kisvegabor | 1:404ee28a0b60 | 481 | SousMenu=NULL; |
kisvegabor | 1:404ee28a0b60 | 482 | } |
becanromain | 0:cf6b1eca3e67 | 483 | } |
becanromain | 0:cf6b1eca3e67 | 484 | } |
kisvegabor | 1:404ee28a0b60 | 485 | if (SousMenu and X>0){TpsAvFermSousMenu=4000;} |
becanromain | 0:cf6b1eca3e67 | 486 | |
becanromain | 0:cf6b1eca3e67 | 487 | /**/ |
becanromain | 0:cf6b1eca3e67 | 488 | }//FIN BOUCLE |
becanromain | 0:cf6b1eca3e67 | 489 | }//FIN MAIN |
becanromain | 0:cf6b1eca3e67 | 490 | |
becanromain | 0:cf6b1eca3e67 | 491 | |
becanromain | 0:cf6b1eca3e67 | 492 | //FONCTION INTERRUPTION COMPTEUR D'IMPULSION |
becanromain | 0:cf6b1eca3e67 | 493 | void interruptCompteur() |
becanromain | 0:cf6b1eca3e67 | 494 | { |
becanromain | 0:cf6b1eca3e67 | 495 | //Timestamp pulsation |
becanromain | 0:cf6b1eca3e67 | 496 | TimerPuls=tempo.read_high_resolution_us(); |
becanromain | 0:cf6b1eca3e67 | 497 | |
becanromain | 0:cf6b1eca3e67 | 498 | // Calcul temps entre 2 impulsions |
becanromain | 0:cf6b1eca3e67 | 499 | TpsPuls=TimerPuls-MemTpsPuls; |
becanromain | 0:cf6b1eca3e67 | 500 | MemTpsPuls=TimerPuls; |
becanromain | 0:cf6b1eca3e67 | 501 | |
becanromain | 0:cf6b1eca3e67 | 502 | //Incrementation numéro de dent roue |
becanromain | 0:cf6b1eca3e67 | 503 | NumDent++; |
becanromain | 0:cf6b1eca3e67 | 504 | |
becanromain | 0:cf6b1eca3e67 | 505 | //Memorisation ecart entre chaque impulsion et Calcul des Min Max |
becanromain | 0:cf6b1eca3e67 | 506 | Calcul=TpsPuls; |
becanromain | 0:cf6b1eca3e67 | 507 | Calcul=Calcul/1000; |
becanromain | 0:cf6b1eca3e67 | 508 | TpsEntre2Puls[NumDent]=Calcul; |
becanromain | 0:cf6b1eca3e67 | 509 | if (Calcul<TpsMinEntre2Puls){TpsMinEntre2Puls=Calcul;} |
becanromain | 0:cf6b1eca3e67 | 510 | if (Calcul>TpsMaxEntre2Puls){TpsMaxEntre2Puls=Calcul;} |
becanromain | 0:cf6b1eca3e67 | 511 | |
becanromain | 0:cf6b1eca3e67 | 512 | //Calcul débit |
becanromain | 0:cf6b1eca3e67 | 513 | if (NumDent>=16){ |
becanromain | 0:cf6b1eca3e67 | 514 | CalcDebit=VolParTour; |
becanromain | 0:cf6b1eca3e67 | 515 | CalcDebit=60000000*CalcDebit/(TimerPuls-MemTps16Puls); |
becanromain | 0:cf6b1eca3e67 | 516 | Debit=CalcDebit; |
becanromain | 0:cf6b1eca3e67 | 517 | Debit=Debit/1000; |
becanromain | 0:cf6b1eca3e67 | 518 | MemTps16Puls=TimerPuls; |
becanromain | 0:cf6b1eca3e67 | 519 | NumDent=0; |
becanromain | 0:cf6b1eca3e67 | 520 | } |
becanromain | 0:cf6b1eca3e67 | 521 | |
becanromain | 0:cf6b1eca3e67 | 522 | //Nombre d'impulsion total |
becanromain | 0:cf6b1eca3e67 | 523 | CptPuls++; |
becanromain | 0:cf6b1eca3e67 | 524 | |
becanromain | 0:cf6b1eca3e67 | 525 | //Calcul Volume |
becanromain | 0:cf6b1eca3e67 | 526 | Volume=CptPuls*VolParTour/16000; |
becanromain | 0:cf6b1eca3e67 | 527 | |
becanromain | 0:cf6b1eca3e67 | 528 | } |
becanromain | 0:cf6b1eca3e67 | 529 | |
becanromain | 0:cf6b1eca3e67 | 530 | void initialisation(void) |
becanromain | 0:cf6b1eca3e67 | 531 | { |
becanromain | 0:cf6b1eca3e67 | 532 | // By doing this, we hide the first (empty) option. |
becanromain | 0:cf6b1eca3e67 | 533 | if(th_options[0] == '\n') { |
becanromain | 0:cf6b1eca3e67 | 534 | th_options++; |
becanromain | 0:cf6b1eca3e67 | 535 | } |
becanromain | 0:cf6b1eca3e67 | 536 | |
becanromain | 0:cf6b1eca3e67 | 537 | init_all_themes(0); |
becanromain | 0:cf6b1eca3e67 | 538 | th_act = themes[0]; |
becanromain | 0:cf6b1eca3e67 | 539 | lv_theme_set_current(th_act); |
becanromain | 0:cf6b1eca3e67 | 540 | |
becanromain | 0:cf6b1eca3e67 | 541 | lv_obj_t * scr = lv_obj_create(NULL, NULL); |
becanromain | 0:cf6b1eca3e67 | 542 | lv_disp_load_scr(scr); |
becanromain | 0:cf6b1eca3e67 | 543 | |
becanromain | 0:cf6b1eca3e67 | 544 | // CREATION OBJET BANDEAU HAUT |
becanromain | 0:cf6b1eca3e67 | 545 | BandeauHaut = lv_cont_create(lv_disp_get_scr_act(NULL), NULL); |
becanromain | 0:cf6b1eca3e67 | 546 | lv_obj_set_size(BandeauHaut,900,40); |
becanromain | 0:cf6b1eca3e67 | 547 | lv_cont_set_fit2(BandeauHaut,LV_FIT_TIGHT, LV_FIT_NONE); |
becanromain | 0:cf6b1eca3e67 | 548 | lv_obj_set_pos(BandeauHaut, 50, 0); |
becanromain | 0:cf6b1eca3e67 | 549 | lv_obj_set_drag_dir(BandeauHaut, LV_DRAG_DIR_HOR); |
becanromain | 0:cf6b1eca3e67 | 550 | lv_obj_set_drag_throw(BandeauHaut, true); |
becanromain | 0:cf6b1eca3e67 | 551 | |
becanromain | 0:cf6b1eca3e67 | 552 | // CREATION PAGE CONTENU |
becanromain | 0:cf6b1eca3e67 | 553 | Page = lv_page_create(lv_disp_get_scr_act(NULL), NULL); |
becanromain | 0:cf6b1eca3e67 | 554 | lv_obj_set_size(Page, hres, vres); |
becanromain | 0:cf6b1eca3e67 | 555 | lv_obj_set_pos(Page, 0, 40); |
becanromain | 0:cf6b1eca3e67 | 556 | |
becanromain | 0:cf6b1eca3e67 | 557 | //INITIALISATION TABLEAU UTILISATEUR |
becanromain | 0:cf6b1eca3e67 | 558 | User[1].Nom="Romain BECAN"; User[1].MDP="1234"; User[1].Niveau=3; User[1].Tps=1; |
becanromain | 0:cf6b1eca3e67 | 559 | User[2].Nom="Guy HERVE"; User[2].MDP="5678"; User[2].Niveau=2; User[2].Tps=120; |
becanromain | 0:cf6b1eca3e67 | 560 | User[3].Nom="Gabor KISS VAMOSI"; User[3].MDP="4321"; User[3].Niveau=3; User[3].Tps=2; |
becanromain | 0:cf6b1eca3e67 | 561 | User[31].Nom="OPERATEUR 1"; User[31].MDP="4321"; User[31].Niveau=1; User[31].Tps=1; |
becanromain | 0:cf6b1eca3e67 | 562 | User[32].Nom="OPERATEUR 2"; User[32].MDP="4321"; User[32].Niveau=1; User[32].Tps=60; |
becanromain | 0:cf6b1eca3e67 | 563 | User[33].Nom="OPERATEUR 3"; User[33].MDP="4321"; User[33].Niveau=1; User[33].Tps=40; |
becanromain | 0:cf6b1eca3e67 | 564 | User[34].Nom="OPERATEUR 4"; User[34].MDP="4321"; User[34].Niveau=1; User[34].Tps=30; |
becanromain | 0:cf6b1eca3e67 | 565 | User[35].Nom="OPERATEUR 5"; User[35].MDP="4321"; User[35].Niveau=3; User[35].Tps=30; |
becanromain | 0:cf6b1eca3e67 | 566 | User[36].Nom="OPERATEUR 6"; User[36].MDP="4321"; User[36].Niveau=3; User[36].Tps=30; |
becanromain | 0:cf6b1eca3e67 | 567 | User[99].Nom="OPERATEUR 100"; User[99].MDP="4321"; User[99].Niveau=3; User[99].Tps=30; |
becanromain | 0:cf6b1eca3e67 | 568 | } |
becanromain | 0:cf6b1eca3e67 | 569 | |
becanromain | 0:cf6b1eca3e67 | 570 | |
becanromain | 0:cf6b1eca3e67 | 571 | |
becanromain | 0:cf6b1eca3e67 | 572 | static void AFFBandeauHaut(int Num) |
becanromain | 0:cf6b1eca3e67 | 573 | { |
becanromain | 0:cf6b1eca3e67 | 574 | |
becanromain | 0:cf6b1eca3e67 | 575 | lv_obj_clean(BandeauHaut); |
becanromain | 0:cf6b1eca3e67 | 576 | //MENU 1 |
becanromain | 0:cf6b1eca3e67 | 577 | M100 = lv_btn_create(BandeauHaut, NULL); |
becanromain | 0:cf6b1eca3e67 | 578 | lv_btn_set_ink_in_time(M100, 200); |
becanromain | 0:cf6b1eca3e67 | 579 | lv_btn_set_ink_wait_time(M100, 100); |
becanromain | 0:cf6b1eca3e67 | 580 | lv_btn_set_ink_out_time(M100, 500); |
becanromain | 0:cf6b1eca3e67 | 581 | lv_obj_t * label = lv_label_create(M100, NULL); |
becanromain | 0:cf6b1eca3e67 | 582 | lv_label_set_text(label, "Mesures"); |
becanromain | 0:cf6b1eca3e67 | 583 | lv_obj_set_size(M100,100,40); |
becanromain | 0:cf6b1eca3e67 | 584 | lv_obj_set_drag_parent(M100, true); |
becanromain | 0:cf6b1eca3e67 | 585 | lv_obj_set_event_cb(M100, M100_ACT); |
becanromain | 0:cf6b1eca3e67 | 586 | |
becanromain | 0:cf6b1eca3e67 | 587 | //MENU 2 |
becanromain | 0:cf6b1eca3e67 | 588 | M200 = lv_btn_create(BandeauHaut, NULL); |
becanromain | 0:cf6b1eca3e67 | 589 | lv_btn_set_ink_in_time(M200, 200); |
becanromain | 0:cf6b1eca3e67 | 590 | lv_btn_set_ink_wait_time(M200, 100); |
becanromain | 0:cf6b1eca3e67 | 591 | lv_btn_set_ink_out_time(M200, 500); |
becanromain | 0:cf6b1eca3e67 | 592 | label = lv_label_create(M200, NULL); |
becanromain | 0:cf6b1eca3e67 | 593 | lv_label_set_text(label, "Parametres"); |
becanromain | 0:cf6b1eca3e67 | 594 | lv_obj_set_size(M200,100,40); |
becanromain | 0:cf6b1eca3e67 | 595 | //lv_btn_set_toggle(M200, true); |
becanromain | 0:cf6b1eca3e67 | 596 | // lv_btn_toggle(M200); |
becanromain | 0:cf6b1eca3e67 | 597 | // lv_obj_set_drag(M200, true); |
becanromain | 0:cf6b1eca3e67 | 598 | lv_obj_align(M200, M100, LV_ALIGN_OUT_RIGHT_MID, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 599 | lv_obj_set_drag_parent(M200, true); |
becanromain | 0:cf6b1eca3e67 | 600 | lv_obj_set_event_cb(M200, M200_ACT); |
becanromain | 0:cf6b1eca3e67 | 601 | |
becanromain | 0:cf6b1eca3e67 | 602 | //MENU 3 |
becanromain | 0:cf6b1eca3e67 | 603 | M300 = lv_btn_create(BandeauHaut, NULL); |
becanromain | 0:cf6b1eca3e67 | 604 | label = lv_label_create(M300, NULL); |
becanromain | 0:cf6b1eca3e67 | 605 | lv_label_set_text(label, "BPMENU3"); |
becanromain | 0:cf6b1eca3e67 | 606 | lv_obj_set_size(M300,100,40); |
becanromain | 0:cf6b1eca3e67 | 607 | lv_obj_align(M300, M200, LV_ALIGN_OUT_RIGHT_MID, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 608 | lv_obj_set_drag_parent(M300, true); |
becanromain | 0:cf6b1eca3e67 | 609 | lv_obj_set_event_cb(M300, M300_ACT); |
becanromain | 0:cf6b1eca3e67 | 610 | |
becanromain | 0:cf6b1eca3e67 | 611 | //MENU 4 |
becanromain | 0:cf6b1eca3e67 | 612 | M400 = lv_btn_create(BandeauHaut, NULL); |
becanromain | 0:cf6b1eca3e67 | 613 | label = lv_label_create(M400, NULL); |
becanromain | 0:cf6b1eca3e67 | 614 | lv_label_set_text(label, "BPMENU4"); |
becanromain | 0:cf6b1eca3e67 | 615 | lv_obj_set_size(M400,100,40); |
becanromain | 0:cf6b1eca3e67 | 616 | lv_obj_align(M400, M300, LV_ALIGN_OUT_RIGHT_MID, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 617 | lv_obj_set_drag_parent(M400, true); |
becanromain | 0:cf6b1eca3e67 | 618 | lv_obj_set_event_cb(M400, M400_ACT); |
becanromain | 0:cf6b1eca3e67 | 619 | |
becanromain | 0:cf6b1eca3e67 | 620 | //MENU 5 |
becanromain | 0:cf6b1eca3e67 | 621 | M500 = lv_btn_create(BandeauHaut, NULL); |
becanromain | 0:cf6b1eca3e67 | 622 | label = lv_label_create(M500, NULL); |
becanromain | 0:cf6b1eca3e67 | 623 | lv_label_set_text(label, "BPMENU5"); |
becanromain | 0:cf6b1eca3e67 | 624 | lv_obj_set_size(M500,100,40); |
becanromain | 0:cf6b1eca3e67 | 625 | lv_obj_align(M500, M400, LV_ALIGN_OUT_RIGHT_MID, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 626 | lv_obj_set_drag_parent(M500, true); |
becanromain | 0:cf6b1eca3e67 | 627 | lv_obj_set_event_cb(M500, M500_ACT); |
becanromain | 0:cf6b1eca3e67 | 628 | |
becanromain | 0:cf6b1eca3e67 | 629 | //BP BPMENU6 |
becanromain | 0:cf6b1eca3e67 | 630 | M600 = lv_btn_create(BandeauHaut, NULL); |
becanromain | 0:cf6b1eca3e67 | 631 | label = lv_label_create(M600, NULL); |
becanromain | 0:cf6b1eca3e67 | 632 | lv_label_set_text(label, "BPMENU6"); |
becanromain | 0:cf6b1eca3e67 | 633 | lv_obj_set_size(M600,100,40); |
becanromain | 0:cf6b1eca3e67 | 634 | lv_obj_align(M600, M500, LV_ALIGN_OUT_RIGHT_MID, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 635 | lv_obj_set_drag_parent(M600, true); |
becanromain | 0:cf6b1eca3e67 | 636 | lv_obj_set_event_cb(M600, M600_ACT); |
becanromain | 0:cf6b1eca3e67 | 637 | |
becanromain | 0:cf6b1eca3e67 | 638 | } |
becanromain | 0:cf6b1eca3e67 | 639 | |
becanromain | 0:cf6b1eca3e67 | 640 | |
becanromain | 0:cf6b1eca3e67 | 641 | static void AFFSousMenu(int Num) |
becanromain | 0:cf6b1eca3e67 | 642 | { |
becanromain | 0:cf6b1eca3e67 | 643 | //SI SOUS MENU DEJA AFFICHE : SUPPRIMER PAGE AVANT CREATION NOUVELLE |
kisvegabor | 1:404ee28a0b60 | 644 | if(SousMenu) { |
kisvegabor | 1:404ee28a0b60 | 645 | lv_obj_del(SousMenu); |
kisvegabor | 1:404ee28a0b60 | 646 | SousMenu = NULL; |
kisvegabor | 1:404ee28a0b60 | 647 | } |
becanromain | 0:cf6b1eca3e67 | 648 | //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) |
kisvegabor | 1:404ee28a0b60 | 649 | //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 |
becanromain | 0:cf6b1eca3e67 | 650 | //Something like: if(GetObjExist(SousMenu)==1){lv_obj_del(SousMenu);} |
becanromain | 0:cf6b1eca3e67 | 651 | |
becanromain | 0:cf6b1eca3e67 | 652 | /*Create a list*/ |
becanromain | 0:cf6b1eca3e67 | 653 | SousMenu = lv_list_create(lv_scr_act(), NULL); |
becanromain | 0:cf6b1eca3e67 | 654 | lv_obj_set_size(SousMenu, 100, 100); |
becanromain | 0:cf6b1eca3e67 | 655 | lv_obj_set_pos(SousMenu, 0, 40); |
becanromain | 0:cf6b1eca3e67 | 656 | |
becanromain | 0:cf6b1eca3e67 | 657 | lv_style_copy(&Style_BPSM, &lv_style_btn_rel); |
becanromain | 0:cf6b1eca3e67 | 658 | // Style_BPSM.text.font = &lv_font_roboto_12; |
becanromain | 0:cf6b1eca3e67 | 659 | // Style_BPSM.body.padding.top = LV_DPI / 40; |
becanromain | 0:cf6b1eca3e67 | 660 | // Style_BPSM.body.padding.bottom = LV_DPI / 40; |
becanromain | 0:cf6b1eca3e67 | 661 | // GABOR: How to change the height of button in a list ? |
kisvegabor | 1:404ee28a0b60 | 662 | // ROMAIN: You need to modify the paddings. See here: https://docs.littlevgl.com/en/html/object-types/list.html#style-usage |
becanromain | 0:cf6b1eca3e67 | 663 | |
becanromain | 0:cf6b1eca3e67 | 664 | //SOUS MENU 100 |
becanromain | 0:cf6b1eca3e67 | 665 | if (Num==100){ |
becanromain | 0:cf6b1eca3e67 | 666 | AnimSousMenu=200;//TAILLE FENETRE |
becanromain | 0:cf6b1eca3e67 | 667 | SM101 = lv_list_add_btn(SousMenu, NULL, "SM101"); |
becanromain | 0:cf6b1eca3e67 | 668 | if (UserEC.Niveau<0){lv_btn_set_state(SM101, LV_BTN_STATE_INA );} |
becanromain | 0:cf6b1eca3e67 | 669 | lv_obj_set_event_cb(SM101, SM101_ACT); |
becanromain | 0:cf6b1eca3e67 | 670 | |
becanromain | 0:cf6b1eca3e67 | 671 | SM102 = lv_list_add_btn(SousMenu, NULL, "SM102"); |
becanromain | 0:cf6b1eca3e67 | 672 | if (UserEC.Niveau<0){lv_btn_set_state(SM102, LV_BTN_STATE_INA );} |
becanromain | 0:cf6b1eca3e67 | 673 | lv_obj_set_event_cb(SM102, SM102_ACT); |
becanromain | 0:cf6b1eca3e67 | 674 | |
becanromain | 0:cf6b1eca3e67 | 675 | SM103 = lv_list_add_btn(SousMenu, NULL, "SM103"); |
becanromain | 0:cf6b1eca3e67 | 676 | if (UserEC.Niveau<1){lv_btn_set_state(SM103, LV_BTN_STATE_INA );} |
becanromain | 0:cf6b1eca3e67 | 677 | lv_obj_set_event_cb(SM103, SM103_ACT); |
becanromain | 0:cf6b1eca3e67 | 678 | |
becanromain | 0:cf6b1eca3e67 | 679 | SM104 = lv_list_add_btn(SousMenu, NULL, "NOM DE MENU LONG"); |
becanromain | 0:cf6b1eca3e67 | 680 | if (UserEC.Niveau<0){lv_btn_set_state(SM104, LV_BTN_STATE_INA );} |
becanromain | 0:cf6b1eca3e67 | 681 | lv_obj_set_event_cb(SM104, SM104_ACT); |
becanromain | 0:cf6b1eca3e67 | 682 | |
becanromain | 0:cf6b1eca3e67 | 683 | SM105 = lv_list_add_btn(SousMenu, NULL, "SM104"); |
becanromain | 0:cf6b1eca3e67 | 684 | if (UserEC.Niveau<0){lv_btn_set_state(SM105, LV_BTN_STATE_INA );} |
becanromain | 0:cf6b1eca3e67 | 685 | lv_obj_set_event_cb(SM105, SM105_ACT); |
becanromain | 0:cf6b1eca3e67 | 686 | } |
becanromain | 0:cf6b1eca3e67 | 687 | |
becanromain | 0:cf6b1eca3e67 | 688 | //SOUS MENU 200 |
becanromain | 0:cf6b1eca3e67 | 689 | if (Num==200){ |
becanromain | 0:cf6b1eca3e67 | 690 | AnimSousMenu=100;//TAILLE FENETRE |
becanromain | 0:cf6b1eca3e67 | 691 | SM201 = lv_list_add_btn(SousMenu, NULL, "SM201"); |
becanromain | 0:cf6b1eca3e67 | 692 | if (UserEC.Niveau<0){lv_btn_set_state(SM201, LV_BTN_STATE_INA );} |
becanromain | 0:cf6b1eca3e67 | 693 | lv_obj_set_event_cb(SM201, SM201_ACT); |
becanromain | 0:cf6b1eca3e67 | 694 | |
becanromain | 0:cf6b1eca3e67 | 695 | SM202 = lv_list_add_btn(SousMenu, NULL, "SM202"); |
becanromain | 0:cf6b1eca3e67 | 696 | if (UserEC.Niveau<0){lv_btn_set_state(SM202, LV_BTN_STATE_INA );} |
becanromain | 0:cf6b1eca3e67 | 697 | lv_obj_set_event_cb(SM202, SM202_ACT); |
becanromain | 0:cf6b1eca3e67 | 698 | |
becanromain | 0:cf6b1eca3e67 | 699 | } |
becanromain | 0:cf6b1eca3e67 | 700 | |
becanromain | 0:cf6b1eca3e67 | 701 | } |
becanromain | 0:cf6b1eca3e67 | 702 | |
becanromain | 0:cf6b1eca3e67 | 703 | |
becanromain | 0:cf6b1eca3e67 | 704 | static void AFFPage(int Num) |
becanromain | 0:cf6b1eca3e67 | 705 | { |
becanromain | 0:cf6b1eca3e67 | 706 | |
becanromain | 0:cf6b1eca3e67 | 707 | // lv_obj_clean(Page); |
becanromain | 0:cf6b1eca3e67 | 708 | |
becanromain | 0:cf6b1eca3e67 | 709 | lv_page_set_scrl_layout(Page, LV_LAYOUT_OFF); |
becanromain | 0:cf6b1eca3e67 | 710 | lv_page_set_scrl_fit2(Page, LV_FIT_FLOOD, LV_FIT_TIGHT); |
becanromain | 0:cf6b1eca3e67 | 711 | |
becanromain | 0:cf6b1eca3e67 | 712 | lv_coord_t max_w = lv_page_get_fit_width(Page); |
becanromain | 0:cf6b1eca3e67 | 713 | |
becanromain | 0:cf6b1eca3e67 | 714 | //affichage données |
becanromain | 0:cf6b1eca3e67 | 715 | int i=0; |
becanromain | 0:cf6b1eca3e67 | 716 | AffTensionBat = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 717 | lv_obj_set_pos(AffTensionBat, 50, i); |
becanromain | 0:cf6b1eca3e67 | 718 | |
becanromain | 0:cf6b1eca3e67 | 719 | AffTpsCy = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 720 | i=i+16;lv_obj_set_pos(AffTpsCy, 50, i); |
becanromain | 0:cf6b1eca3e67 | 721 | |
becanromain | 0:cf6b1eca3e67 | 722 | AffCptPuls = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 723 | i=i+16;lv_obj_set_pos(AffCptPuls, 50, i); |
becanromain | 0:cf6b1eca3e67 | 724 | |
becanromain | 0:cf6b1eca3e67 | 725 | AffVolume = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 726 | i=i+16;lv_obj_set_pos(AffVolume, 50, i); |
becanromain | 0:cf6b1eca3e67 | 727 | |
becanromain | 0:cf6b1eca3e67 | 728 | AffDebit = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 729 | i=i+16;lv_obj_set_pos(AffDebit, 50, i); |
becanromain | 0:cf6b1eca3e67 | 730 | |
becanromain | 0:cf6b1eca3e67 | 731 | Aff1TpsEntre2Puls = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 732 | i=i+16;lv_obj_set_pos(Aff1TpsEntre2Puls, 50, i); |
becanromain | 0:cf6b1eca3e67 | 733 | |
becanromain | 0:cf6b1eca3e67 | 734 | Aff2TpsEntre2Puls = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 735 | i=i+16;lv_obj_set_pos(Aff2TpsEntre2Puls, 50, i); |
becanromain | 0:cf6b1eca3e67 | 736 | |
becanromain | 0:cf6b1eca3e67 | 737 | AffTpsMinEntre2Puls = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 738 | i=i+16;lv_obj_set_pos(AffTpsMinEntre2Puls, 50, i); |
becanromain | 0:cf6b1eca3e67 | 739 | |
becanromain | 0:cf6b1eca3e67 | 740 | AffTpsMaxEntre2Puls = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 741 | i=i+16;lv_obj_set_pos(AffTpsMaxEntre2Puls, 50, i); |
becanromain | 0:cf6b1eca3e67 | 742 | |
becanromain | 0:cf6b1eca3e67 | 743 | //BP BPMENU4 |
becanromain | 0:cf6b1eca3e67 | 744 | BPRAZ = lv_btn_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 745 | i=i+30;lv_obj_set_pos(BPRAZ, 50, i); |
becanromain | 0:cf6b1eca3e67 | 746 | label = lv_label_create(BPRAZ, NULL); |
becanromain | 0:cf6b1eca3e67 | 747 | lv_label_set_text(label, "RAZ"); |
becanromain | 0:cf6b1eca3e67 | 748 | lv_obj_set_size(BPRAZ,60,40); |
becanromain | 0:cf6b1eca3e67 | 749 | lv_obj_set_event_cb(BPRAZ, BPRAZ_ACT); |
becanromain | 0:cf6b1eca3e67 | 750 | |
becanromain | 0:cf6b1eca3e67 | 751 | // SLIDER |
becanromain | 0:cf6b1eca3e67 | 752 | static lv_style_t style_bg,style_knob; |
becanromain | 0:cf6b1eca3e67 | 753 | static lv_style_t style_indic_R; |
becanromain | 0:cf6b1eca3e67 | 754 | |
becanromain | 0:cf6b1eca3e67 | 755 | |
becanromain | 0:cf6b1eca3e67 | 756 | lv_style_copy(&style_bg, &lv_style_pretty); |
becanromain | 0:cf6b1eca3e67 | 757 | style_bg.body.main_color = LV_COLOR_BLACK; |
becanromain | 0:cf6b1eca3e67 | 758 | style_bg.body.grad_color = LV_COLOR_BLACK; |
becanromain | 0:cf6b1eca3e67 | 759 | style_bg.body.radius = LV_RADIUS_CIRCLE; |
becanromain | 0:cf6b1eca3e67 | 760 | style_bg.body.border.color = LV_COLOR_SILVER; |
becanromain | 0:cf6b1eca3e67 | 761 | |
becanromain | 0:cf6b1eca3e67 | 762 | lv_style_copy(&style_indic_R, &lv_style_pretty_color); |
becanromain | 0:cf6b1eca3e67 | 763 | style_indic_R.body.main_color = LV_COLOR_RED; |
becanromain | 0:cf6b1eca3e67 | 764 | style_indic_R.body.grad_color = LV_COLOR_RED; |
becanromain | 0:cf6b1eca3e67 | 765 | style_indic_R.body.radius = LV_RADIUS_CIRCLE; |
becanromain | 0:cf6b1eca3e67 | 766 | style_indic_R.body.shadow.width = 4; |
becanromain | 0:cf6b1eca3e67 | 767 | style_indic_R.body.shadow.color = LV_COLOR_RED; |
becanromain | 0:cf6b1eca3e67 | 768 | style_indic_R.body.padding.left = 3; |
becanromain | 0:cf6b1eca3e67 | 769 | style_indic_R.body.padding.right = 3; |
becanromain | 0:cf6b1eca3e67 | 770 | style_indic_R.body.padding.top = 3; |
becanromain | 0:cf6b1eca3e67 | 771 | style_indic_R.body.padding.bottom = 3; |
becanromain | 0:cf6b1eca3e67 | 772 | |
becanromain | 0:cf6b1eca3e67 | 773 | lv_style_copy(&style_knob, &lv_style_pretty); |
becanromain | 0:cf6b1eca3e67 | 774 | style_knob.body.radius = LV_RADIUS_CIRCLE; |
becanromain | 0:cf6b1eca3e67 | 775 | style_knob.body.opa = LV_OPA_70; |
becanromain | 0:cf6b1eca3e67 | 776 | style_knob.body.padding.top = 10 ; |
becanromain | 0:cf6b1eca3e67 | 777 | style_knob.body.padding.bottom = 10 ; |
becanromain | 0:cf6b1eca3e67 | 778 | |
becanromain | 0:cf6b1eca3e67 | 779 | /*Create a slider ROUGE*/ |
becanromain | 0:cf6b1eca3e67 | 780 | R = lv_slider_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 781 | lv_obj_set_pos(R, 10, 40); |
becanromain | 0:cf6b1eca3e67 | 782 | lv_obj_set_width(R, 30); |
becanromain | 0:cf6b1eca3e67 | 783 | lv_obj_set_height(R, 180); |
becanromain | 0:cf6b1eca3e67 | 784 | lv_slider_set_range(R, 0, 10000); |
becanromain | 0:cf6b1eca3e67 | 785 | lv_slider_set_value(R, Reglage_R, false); |
becanromain | 0:cf6b1eca3e67 | 786 | style_indic_R.body.main_color = LV_COLOR_RED; |
becanromain | 0:cf6b1eca3e67 | 787 | style_indic_R.body.grad_color = LV_COLOR_RED; |
becanromain | 0:cf6b1eca3e67 | 788 | style_indic_R.body.shadow.color = LV_COLOR_RED; |
becanromain | 0:cf6b1eca3e67 | 789 | lv_slider_set_style(R, LV_SLIDER_STYLE_BG, &style_bg); |
becanromain | 0:cf6b1eca3e67 | 790 | lv_slider_set_style(R, LV_SLIDER_STYLE_INDIC,&style_indic_R); |
becanromain | 0:cf6b1eca3e67 | 791 | lv_slider_set_style(R, LV_SLIDER_STYLE_KNOB, &style_knob); |
becanromain | 0:cf6b1eca3e67 | 792 | lv_obj_set_event_cb(R, Reglage_R_RGB); |
becanromain | 0:cf6b1eca3e67 | 793 | Val_R = lv_label_create(Page, NULL); |
becanromain | 0:cf6b1eca3e67 | 794 | lv_obj_align(Val_R, R, LV_ALIGN_OUT_TOP_MID, 0, -5); |
becanromain | 0:cf6b1eca3e67 | 795 | sprintf(text, " %d ", lv_slider_get_value(R)); |
becanromain | 0:cf6b1eca3e67 | 796 | lv_label_set_text(Val_R, text); |
becanromain | 0:cf6b1eca3e67 | 797 | |
becanromain | 0:cf6b1eca3e67 | 798 | |
becanromain | 0:cf6b1eca3e67 | 799 | } |
becanromain | 0:cf6b1eca3e67 | 800 | |
becanromain | 0:cf6b1eca3e67 | 801 | |
becanromain | 0:cf6b1eca3e67 | 802 | |
becanromain | 0:cf6b1eca3e67 | 803 | static void init_all_themes(uint16_t hue) |
becanromain | 0:cf6b1eca3e67 | 804 | { |
becanromain | 0:cf6b1eca3e67 | 805 | // NOTE: This must be adjusted if more themes are added. |
becanromain | 0:cf6b1eca3e67 | 806 | int i = 0; |
becanromain | 0:cf6b1eca3e67 | 807 | #if LV_USE_THEME_DEFAULT |
becanromain | 0:cf6b1eca3e67 | 808 | themes[i++] = lv_theme_default_init(hue, NULL); |
becanromain | 0:cf6b1eca3e67 | 809 | #endif |
becanromain | 0:cf6b1eca3e67 | 810 | |
becanromain | 0:cf6b1eca3e67 | 811 | #if LV_USE_THEME_NIGHT |
becanromain | 0:cf6b1eca3e67 | 812 | themes[i++] = lv_theme_night_init(hue, NULL); |
becanromain | 0:cf6b1eca3e67 | 813 | #endif |
becanromain | 0:cf6b1eca3e67 | 814 | |
becanromain | 0:cf6b1eca3e67 | 815 | #if LV_USE_THEME_MATERIAL |
becanromain | 0:cf6b1eca3e67 | 816 | themes[i++] = lv_theme_material_init(hue, NULL); |
becanromain | 0:cf6b1eca3e67 | 817 | #endif |
becanromain | 0:cf6b1eca3e67 | 818 | |
becanromain | 0:cf6b1eca3e67 | 819 | #if LV_USE_THEME_ALIEN |
becanromain | 0:cf6b1eca3e67 | 820 | themes[i++] = lv_theme_alien_init(hue, NULL); |
becanromain | 0:cf6b1eca3e67 | 821 | #endif |
becanromain | 0:cf6b1eca3e67 | 822 | |
becanromain | 0:cf6b1eca3e67 | 823 | #if LV_USE_THEME_ZEN |
becanromain | 0:cf6b1eca3e67 | 824 | themes[i++] = lv_theme_zen_init(hue, NULL); |
becanromain | 0:cf6b1eca3e67 | 825 | #endif |
becanromain | 0:cf6b1eca3e67 | 826 | |
becanromain | 0:cf6b1eca3e67 | 827 | #if LV_USE_THEME_NEMO |
becanromain | 0:cf6b1eca3e67 | 828 | themes[i++] = lv_theme_nemo_init(hue, NULL); |
becanromain | 0:cf6b1eca3e67 | 829 | #endif |
becanromain | 0:cf6b1eca3e67 | 830 | |
becanromain | 0:cf6b1eca3e67 | 831 | #if LV_USE_THEME_MONO |
becanromain | 0:cf6b1eca3e67 | 832 | themes[i++] = lv_theme_mono_init(hue, NULL); |
becanromain | 0:cf6b1eca3e67 | 833 | #endif |
becanromain | 0:cf6b1eca3e67 | 834 | |
becanromain | 0:cf6b1eca3e67 | 835 | |
becanromain | 0:cf6b1eca3e67 | 836 | } |
becanromain | 0:cf6b1eca3e67 | 837 | //******************** |
becanromain | 0:cf6b1eca3e67 | 838 | // POPUP CONNEXION MDP |
becanromain | 0:cf6b1eca3e67 | 839 | //******************** |
becanromain | 0:cf6b1eca3e67 | 840 | static void AFFPopupMDP(){ |
becanromain | 0:cf6b1eca3e67 | 841 | //FOND GRISE |
becanromain | 0:cf6b1eca3e67 | 842 | static lv_style_t modal_style; |
becanromain | 0:cf6b1eca3e67 | 843 | lv_style_copy(&modal_style, &lv_style_plain_color); |
becanromain | 0:cf6b1eca3e67 | 844 | modal_style.body.main_color = modal_style.body.grad_color = LV_COLOR_BLACK; |
becanromain | 0:cf6b1eca3e67 | 845 | modal_style.body.opa = LV_OPA_50; |
becanromain | 0:cf6b1eca3e67 | 846 | FondGris = lv_obj_create(lv_scr_act(), NULL); |
becanromain | 0:cf6b1eca3e67 | 847 | lv_obj_set_style(FondGris, &modal_style); |
becanromain | 0:cf6b1eca3e67 | 848 | lv_obj_set_pos(FondGris, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 849 | lv_obj_set_size(FondGris, LV_HOR_RES, LV_VER_RES); |
becanromain | 0:cf6b1eca3e67 | 850 | lv_obj_set_opa_scale_enable(FondGris, true); |
becanromain | 0:cf6b1eca3e67 | 851 | |
becanromain | 0:cf6b1eca3e67 | 852 | // CREATION POPUP CONNEXION MDP |
becanromain | 0:cf6b1eca3e67 | 853 | PopupMDP = lv_obj_create(FondGris, NULL); |
becanromain | 0:cf6b1eca3e67 | 854 | lv_obj_set_size(PopupMDP,400,260); |
becanromain | 0:cf6b1eca3e67 | 855 | lv_obj_align(PopupMDP, FondGris, LV_ALIGN_CENTER, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 856 | lv_obj_set_opa_scale_enable(PopupMDP, true); |
becanromain | 0:cf6b1eca3e67 | 857 | lv_obj_set_opa_scale(PopupMDP, 240); |
becanromain | 0:cf6b1eca3e67 | 858 | |
becanromain | 0:cf6b1eca3e67 | 859 | //TITRE |
becanromain | 0:cf6b1eca3e67 | 860 | label = lv_label_create(PopupMDP, NULL); |
becanromain | 0:cf6b1eca3e67 | 861 | lv_label_set_text(label, "IDENTIFICATION"); |
becanromain | 0:cf6b1eca3e67 | 862 | lv_obj_align(label, PopupMDP, LV_ALIGN_IN_TOP_MID, 0, 3); |
becanromain | 0:cf6b1eca3e67 | 863 | lv_obj_set_opa_scale_enable(label, true); |
becanromain | 0:cf6b1eca3e67 | 864 | lv_obj_set_opa_scale(label, LV_OPA_COVER); |
becanromain | 0:cf6b1eca3e67 | 865 | |
becanromain | 0:cf6b1eca3e67 | 866 | //CREATION LISTE UTILISATEUR POUR AFFICHAGE |
becanromain | 0:cf6b1eca3e67 | 867 | //GABOR: Mabye you have a better solution than: |
kisvegabor | 1:404ee28a0b60 | 868 | //ROMAIN: There is no much better way, but I have a few comments |
becanromain | 0:cf6b1eca3e67 | 869 | int i; |
becanromain | 0:cf6b1eca3e67 | 870 | int j; |
becanromain | 0:cf6b1eca3e67 | 871 | int k=0; |
becanromain | 0:cf6b1eca3e67 | 872 | char p[2200]; |
kisvegabor | 1:404ee28a0b60 | 873 | |
kisvegabor | 1:404ee28a0b60 | 874 | //ROMAIN: |
kisvegabor | 1:404ee28a0b60 | 875 | // - p[i]=='\0'; it should be p[i]='\0'; isn't it? |
kisvegabor | 1:404ee28a0b60 | 876 | // - If so why not start from i = 0 to initalize? |
kisvegabor | 1:404ee28a0b60 | 877 | // - memset(p, '\0', sizeof(p)) can be a clearer option to initialize |
kisvegabor | 1:404ee28a0b60 | 878 | for (i = 1; i < 2200; i++) { p[i]=='\0';} |
kisvegabor | 1:404ee28a0b60 | 879 | |
kisvegabor | 1:404ee28a0b60 | 880 | for (i = 1; i < 100; i++) { //ROMAIN: Why start from 1? |
becanromain | 0:cf6b1eca3e67 | 881 | string s=User[i].Nom; |
becanromain | 0:cf6b1eca3e67 | 882 | if (s.length()>0){ |
kisvegabor | 1:404ee28a0b60 | 883 | //ROMAIN: I suggest using memcpy instead |
kisvegabor | 1:404ee28a0b60 | 884 | // memcpy(&p[k], s, s.length()) |
kisvegabor | 1:404ee28a0b60 | 885 | // k += s.length(); |
kisvegabor | 1:404ee28a0b60 | 886 | // p[k] = '\n'; |
kisvegabor | 1:404ee28a0b60 | 887 | // k++; |
becanromain | 0:cf6b1eca3e67 | 888 | for (j = 0; j < s.length(); j++) { |
becanromain | 0:cf6b1eca3e67 | 889 | p[k] = s[j]; |
becanromain | 0:cf6b1eca3e67 | 890 | k++; |
becanromain | 0:cf6b1eca3e67 | 891 | } |
becanromain | 0:cf6b1eca3e67 | 892 | p[k]='\n'; |
becanromain | 0:cf6b1eca3e67 | 893 | k++; |
becanromain | 0:cf6b1eca3e67 | 894 | } |
becanromain | 0:cf6b1eca3e67 | 895 | } |
kisvegabor | 1:404ee28a0b60 | 896 | //ROMAIN: |
kisvegabor | 1:404ee28a0b60 | 897 | // - you alraedy incremented k, so it should p[k] = '\0', shouldn't it? |
kisvegabor | 1:404ee28a0b60 | 898 | // - and you initialized p to '\0' so it's not required |
becanromain | 0:cf6b1eca3e67 | 899 | p[k+1]='\0'; |
becanromain | 0:cf6b1eca3e67 | 900 | char * ListeUser= p ; |
becanromain | 0:cf6b1eca3e67 | 901 | |
becanromain | 0:cf6b1eca3e67 | 902 | //SELECTEUR UTILISATEUR |
becanromain | 0:cf6b1eca3e67 | 903 | SelectID = lv_roller_create(PopupMDP, NULL); |
becanromain | 0:cf6b1eca3e67 | 904 | lv_roller_set_options(SelectID,ListeUser,LV_ROLLER_MODE_NORMAL); |
becanromain | 0:cf6b1eca3e67 | 905 | lv_roller_set_visible_row_count(SelectID, 9); |
becanromain | 0:cf6b1eca3e67 | 906 | lv_roller_set_fix_width(SelectID, 170); |
becanromain | 0:cf6b1eca3e67 | 907 | lv_obj_align(SelectID, PopupMDP, LV_ALIGN_IN_TOP_LEFT, 10, 20); |
becanromain | 0:cf6b1eca3e67 | 908 | //GABOR: is it possible to put the selection on the second line of the roller , not at the middle ? |
kisvegabor | 1:404ee28a0b60 | 909 | //ROMAIN: unfortunatelly not. |
becanromain | 0:cf6b1eca3e67 | 910 | |
becanromain | 0:cf6b1eca3e67 | 911 | //CHAMPS MOT DE PASSE |
becanromain | 0:cf6b1eca3e67 | 912 | MDP = lv_ta_create(PopupMDP, NULL); |
becanromain | 0:cf6b1eca3e67 | 913 | lv_ta_set_text(MDP, ""); |
becanromain | 0:cf6b1eca3e67 | 914 | lv_ta_set_pwd_mode(MDP, true); |
becanromain | 0:cf6b1eca3e67 | 915 | lv_ta_set_one_line(MDP, true); |
becanromain | 0:cf6b1eca3e67 | 916 | lv_obj_set_width(MDP, 170); |
becanromain | 0:cf6b1eca3e67 | 917 | lv_obj_align(MDP, PopupMDP, LV_ALIGN_IN_TOP_RIGHT, -10, 20); |
becanromain | 0:cf6b1eca3e67 | 918 | lv_obj_set_opa_scale_enable(MDP, true); |
becanromain | 0:cf6b1eca3e67 | 919 | lv_obj_set_opa_scale(MDP, LV_OPA_COVER); |
becanromain | 0:cf6b1eca3e67 | 920 | lv_ta_set_max_length(MDP, 4); |
becanromain | 0:cf6b1eca3e67 | 921 | |
becanromain | 0:cf6b1eca3e67 | 922 | // PAVE NUMERIQUE SAISIE MOT DE PASSE |
becanromain | 0:cf6b1eca3e67 | 923 | static lv_style_t rel_style, pr_style; //STYLE CLAVIER |
becanromain | 0:cf6b1eca3e67 | 924 | lv_style_copy(&rel_style, &lv_style_btn_rel); |
becanromain | 0:cf6b1eca3e67 | 925 | rel_style.body.radius = 0; |
becanromain | 0:cf6b1eca3e67 | 926 | rel_style.body.border.width = 1; |
becanromain | 0:cf6b1eca3e67 | 927 | lv_style_copy(&pr_style, &lv_style_btn_pr); |
becanromain | 0:cf6b1eca3e67 | 928 | pr_style.body.radius = 0; |
becanromain | 0:cf6b1eca3e67 | 929 | pr_style.body.border.width = 1; |
becanromain | 0:cf6b1eca3e67 | 930 | |
becanromain | 0:cf6b1eca3e67 | 931 | lv_obj_t * PaveNumerique = lv_kb_create(PopupMDP, NULL); |
becanromain | 0:cf6b1eca3e67 | 932 | lv_obj_set_size(PaveNumerique,170,170); |
becanromain | 0:cf6b1eca3e67 | 933 | lv_btnm_set_map(PaveNumerique, PAVE_NUMERIQUE_MAP); |
becanromain | 0:cf6b1eca3e67 | 934 | lv_btnm_set_btn_width(PaveNumerique, 10, 2); |
becanromain | 0:cf6b1eca3e67 | 935 | lv_obj_align(PaveNumerique, PopupMDP, LV_ALIGN_IN_TOP_RIGHT, -10, 50); |
becanromain | 0:cf6b1eca3e67 | 936 | lv_obj_set_opa_scale_enable(PaveNumerique, true); |
becanromain | 0:cf6b1eca3e67 | 937 | lv_obj_set_opa_scale(PaveNumerique, LV_OPA_COVER); |
becanromain | 0:cf6b1eca3e67 | 938 | lv_kb_set_cursor_manage(PaveNumerique, true); |
becanromain | 0:cf6b1eca3e67 | 939 | lv_kb_set_style(PaveNumerique, LV_KB_STYLE_BG, &lv_style_transp_tight); |
becanromain | 0:cf6b1eca3e67 | 940 | lv_kb_set_style(PaveNumerique, LV_KB_STYLE_BTN_REL, &rel_style); |
becanromain | 0:cf6b1eca3e67 | 941 | lv_kb_set_style(PaveNumerique, LV_KB_STYLE_BTN_PR, &pr_style); |
becanromain | 0:cf6b1eca3e67 | 942 | lv_kb_set_ta(PaveNumerique, MDP); //ASSOCIATION CLAVIER ET CHAMPS MDP |
becanromain | 0:cf6b1eca3e67 | 943 | |
becanromain | 0:cf6b1eca3e67 | 944 | // STYLE DES BOUTONS |
becanromain | 0:cf6b1eca3e67 | 945 | lv_style_copy(&Style_BP, &lv_style_btn_rel); |
becanromain | 0:cf6b1eca3e67 | 946 | Style_BP.text.font = &lv_font_roboto_12; |
becanromain | 0:cf6b1eca3e67 | 947 | Style_BP.body.main_color = LV_COLOR_MAKE(R3, G3, B3); |
becanromain | 0:cf6b1eca3e67 | 948 | |
becanromain | 0:cf6b1eca3e67 | 949 | //BP VALIDER |
becanromain | 0:cf6b1eca3e67 | 950 | lv_obj_t * BpValidMDP=lv_btn_create(PopupMDP, NULL); |
becanromain | 0:cf6b1eca3e67 | 951 | lv_btn_set_style(BpValidMDP, LV_BTN_STYLE_REL,&Style_BP); |
becanromain | 0:cf6b1eca3e67 | 952 | lv_obj_set_size(BpValidMDP,100,30); |
becanromain | 0:cf6b1eca3e67 | 953 | lv_obj_align(BpValidMDP, PopupMDP, LV_ALIGN_IN_BOTTOM_MID, -60, -5); |
becanromain | 0:cf6b1eca3e67 | 954 | label = lv_label_create(BpValidMDP, NULL); |
becanromain | 0:cf6b1eca3e67 | 955 | lv_label_set_text(label, "Valider"); |
becanromain | 0:cf6b1eca3e67 | 956 | lv_obj_set_drag_parent(BpValidMDP, true); |
becanromain | 0:cf6b1eca3e67 | 957 | lv_obj_set_event_cb(BpValidMDP, BpValidMDP_ACT); |
becanromain | 0:cf6b1eca3e67 | 958 | lv_obj_set_opa_scale_enable(BpValidMDP, true); |
becanromain | 0:cf6b1eca3e67 | 959 | lv_obj_set_opa_scale(BpValidMDP, LV_OPA_COVER); |
becanromain | 0:cf6b1eca3e67 | 960 | |
becanromain | 0:cf6b1eca3e67 | 961 | //BP ANNULER |
becanromain | 0:cf6b1eca3e67 | 962 | lv_obj_t * BpAnnulMDP=lv_btn_create(PopupMDP, NULL); |
becanromain | 0:cf6b1eca3e67 | 963 | lv_btn_set_style(BpAnnulMDP, LV_BTN_STYLE_REL,&Style_BP); |
becanromain | 0:cf6b1eca3e67 | 964 | lv_obj_set_size(BpAnnulMDP,100,30); |
becanromain | 0:cf6b1eca3e67 | 965 | lv_obj_align(BpAnnulMDP, PopupMDP, LV_ALIGN_IN_BOTTOM_MID, 60, -5); |
becanromain | 0:cf6b1eca3e67 | 966 | label = lv_label_create(BpAnnulMDP, NULL); |
becanromain | 0:cf6b1eca3e67 | 967 | //lv_label_set_text(label, "Annuler"); |
kisvegabor | 1:404ee28a0b60 | 968 | |
kisvegabor | 1:404ee28a0b60 | 969 | //GABOR: Multiligual : see the function "message" |
kisvegabor | 1:404ee28a0b60 | 970 | //ROMAIN: lvgl has lv_i18n modul to so internationalization: https://github.com/littlevgl/lv_i18n |
kisvegabor | 1:404ee28a0b60 | 971 | // - It's a script which autmatically extracts the strings to translate from you code |
kisvegabor | 1:404ee28a0b60 | 972 | // - However to run the script you need the code offline |
kisvegabor | 1:404ee28a0b60 | 973 | // - An other option is to manually create the internationalization file |
kisvegabor | 1:404ee28a0b60 | 974 | // - I've added lv_i18n.c/h as a reference |
kisvegabor | 1:404ee28a0b60 | 975 | // - You can test it like this |
kisvegabor | 1:404ee28a0b60 | 976 | // lv_i18n_init(lv_i18n_language_pack); |
kisvegabor | 1:404ee28a0b60 | 977 | // lv_i18n_set_locale("en-GB"); |
kisvegabor | 1:404ee28a0b60 | 978 | // printf(_("dog")); |
kisvegabor | 1:404ee28a0b60 | 979 | // printf("\n"); |
kisvegabor | 1:404ee28a0b60 | 980 | // |
kisvegabor | 1:404ee28a0b60 | 981 | // lv_i18n_set_locale("fr"); |
kisvegabor | 1:404ee28a0b60 | 982 | // printf(_("dog")); |
kisvegabor | 1:404ee28a0b60 | 983 | // printf("\n"); |
kisvegabor | 1:404ee28a0b60 | 984 | // |
kisvegabor | 1:404ee28a0b60 | 985 | // - '_' is a function which get the translated version of "dog" and "cat" in the given local |
kisvegabor | 1:404ee28a0b60 | 986 | // - You can use it with labels: lv_label_set_text(label, _("dog")) |
kisvegabor | 1:404ee28a0b60 | 987 | // - Translation with prinf-like format characters are also possible. E.g. |
kisvegabor | 1:404ee28a0b60 | 988 | // - In lv_i18n.c: {"user_count", "There are %d users"}, |
kisvegabor | 1:404ee28a0b60 | 989 | // - Usage: |
kisvegabor | 1:404ee28a0b60 | 990 | // char buf[128]; |
kisvegabor | 1:404ee28a0b60 | 991 | // sprintf(buf, _("user_count"), 55); |
kisvegabor | 1:404ee28a0b60 | 992 | // |
kisvegabor | 1:404ee28a0b60 | 993 | // - Or: |
kisvegabor | 1:404ee28a0b60 | 994 | // lv_label_set_text_fmt(label, _("user_count"), 55); |
kisvegabor | 1:404ee28a0b60 | 995 | lv_label_set_text(label, Message(1)); |
becanromain | 0:cf6b1eca3e67 | 996 | |
becanromain | 0:cf6b1eca3e67 | 997 | lv_obj_set_drag_parent(BpAnnulMDP, true); |
becanromain | 0:cf6b1eca3e67 | 998 | lv_obj_set_event_cb(BpAnnulMDP, BpAnnulMDP_ACT); |
becanromain | 0:cf6b1eca3e67 | 999 | lv_obj_set_opa_scale_enable(BpAnnulMDP, true); |
becanromain | 0:cf6b1eca3e67 | 1000 | lv_obj_set_opa_scale(BpAnnulMDP, LV_OPA_COVER); |
becanromain | 0:cf6b1eca3e67 | 1001 | |
becanromain | 0:cf6b1eca3e67 | 1002 | } |
becanromain | 0:cf6b1eca3e67 | 1003 | |
becanromain | 0:cf6b1eca3e67 | 1004 | static void BpValidMDP_ACT(lv_obj_t * obj, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1005 | { |
becanromain | 0:cf6b1eca3e67 | 1006 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1007 | //RECUPERATION DU NOM DE L'UTILISATEUR SELECTIONNE |
becanromain | 0:cf6b1eca3e67 | 1008 | char NomSelect[20]; |
becanromain | 0:cf6b1eca3e67 | 1009 | lv_roller_get_selected_str(SelectID, NomSelect, sizeof(NomSelect)); |
becanromain | 0:cf6b1eca3e67 | 1010 | |
becanromain | 0:cf6b1eca3e67 | 1011 | //RECUPERATION MOT DE PASSE SAISIE |
becanromain | 0:cf6b1eca3e67 | 1012 | string MdpSaisie; |
becanromain | 0:cf6b1eca3e67 | 1013 | MdpSaisie = lv_ta_get_text(MDP); |
becanromain | 0:cf6b1eca3e67 | 1014 | |
becanromain | 0:cf6b1eca3e67 | 1015 | //FOND GRISE |
becanromain | 0:cf6b1eca3e67 | 1016 | static lv_style_t modal_style; |
becanromain | 0:cf6b1eca3e67 | 1017 | lv_style_copy(&modal_style, &lv_style_plain_color); |
becanromain | 0:cf6b1eca3e67 | 1018 | modal_style.body.main_color = modal_style.body.grad_color = LV_COLOR_BLACK; |
becanromain | 0:cf6b1eca3e67 | 1019 | modal_style.body.opa = LV_OPA_50; |
becanromain | 0:cf6b1eca3e67 | 1020 | FondGris2 = lv_obj_create(lv_scr_act(), NULL); |
becanromain | 0:cf6b1eca3e67 | 1021 | lv_obj_set_style(FondGris2, &modal_style); |
becanromain | 0:cf6b1eca3e67 | 1022 | lv_obj_set_pos(FondGris2, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 1023 | lv_obj_set_size(FondGris2, LV_HOR_RES, LV_VER_RES); |
becanromain | 0:cf6b1eca3e67 | 1024 | lv_obj_set_opa_scale_enable(FondGris2, true); |
becanromain | 0:cf6b1eca3e67 | 1025 | //COMPARAISON AVEC LISTE |
becanromain | 0:cf6b1eca3e67 | 1026 | static const char * btns2[] = {"Ok", ""}; |
becanromain | 0:cf6b1eca3e67 | 1027 | for (int i = 1; i < 100; i++) { |
becanromain | 0:cf6b1eca3e67 | 1028 | if (User[i].Nom==NomSelect) |
becanromain | 0:cf6b1eca3e67 | 1029 | if (User[i].MDP==MdpSaisie){ |
becanromain | 0:cf6b1eca3e67 | 1030 | mbox=lv_mbox_create(FondGris2, NULL); |
becanromain | 0:cf6b1eca3e67 | 1031 | lv_mbox_add_btns(mbox, btns2); |
becanromain | 0:cf6b1eca3e67 | 1032 | if (User[i].Niveau==1){sprintf(text2, "qu'operateur" );} |
becanromain | 0:cf6b1eca3e67 | 1033 | if (User[i].Niveau==2){sprintf(text2, "que superviseur");} |
becanromain | 0:cf6b1eca3e67 | 1034 | if (User[i].Niveau==3){sprintf(text2, "que constructeur");} |
becanromain | 0:cf6b1eca3e67 | 1035 | sprintf(text, "Connexion autorisee a %s en tant %s pour une duree de %d min",User[i].Nom ,text2,User[i].Tps ); |
becanromain | 0:cf6b1eca3e67 | 1036 | lv_mbox_set_text(mbox, text); |
becanromain | 0:cf6b1eca3e67 | 1037 | lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 1038 | lv_obj_set_event_cb(mbox, mboxMdp_ACT); |
becanromain | 0:cf6b1eca3e67 | 1039 | TpsMdpEnCours=User[i].Tps*60; |
becanromain | 0:cf6b1eca3e67 | 1040 | UserEC=User[i]; |
becanromain | 0:cf6b1eca3e67 | 1041 | //RECLASSEMENT DU TABLEAU DES UTILISATEURS POUR AVOIR LE DERNIER CONNECTé EN PREMIER |
becanromain | 0:cf6b1eca3e67 | 1042 | User[0]=User[i]; |
becanromain | 0:cf6b1eca3e67 | 1043 | for (int j = i; j >0; j--) { //DECALAGE TABLEAU |
becanromain | 0:cf6b1eca3e67 | 1044 | User[j]=User[j-1]; |
becanromain | 0:cf6b1eca3e67 | 1045 | } |
becanromain | 0:cf6b1eca3e67 | 1046 | return; |
becanromain | 0:cf6b1eca3e67 | 1047 | } |
becanromain | 0:cf6b1eca3e67 | 1048 | } |
becanromain | 0:cf6b1eca3e67 | 1049 | mbox=lv_mbox_create(FondGris2, NULL); |
becanromain | 0:cf6b1eca3e67 | 1050 | lv_mbox_add_btns(mbox, btns2); |
becanromain | 0:cf6b1eca3e67 | 1051 | lv_mbox_set_text(mbox, "MOT DE PASSE ERRONE"); |
becanromain | 0:cf6b1eca3e67 | 1052 | lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); |
becanromain | 0:cf6b1eca3e67 | 1053 | lv_obj_set_event_cb(mbox, mboxMdp_ACT2); |
becanromain | 0:cf6b1eca3e67 | 1054 | } |
becanromain | 0:cf6b1eca3e67 | 1055 | } |
becanromain | 0:cf6b1eca3e67 | 1056 | static void BpAnnulMDP_ACT(lv_obj_t * obj, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1057 | { |
becanromain | 0:cf6b1eca3e67 | 1058 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1059 | // lv_obj_del_async(PopupMDP); |
becanromain | 0:cf6b1eca3e67 | 1060 | lv_obj_del_async(FondGris); |
becanromain | 0:cf6b1eca3e67 | 1061 | } |
becanromain | 0:cf6b1eca3e67 | 1062 | } |
becanromain | 0:cf6b1eca3e67 | 1063 | |
becanromain | 0:cf6b1eca3e67 | 1064 | static void mboxMdp_ACT(lv_obj_t * obj, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1065 | { |
becanromain | 0:cf6b1eca3e67 | 1066 | lv_obj_del_async(FondGris); |
becanromain | 0:cf6b1eca3e67 | 1067 | lv_obj_del_async(FondGris2); |
becanromain | 0:cf6b1eca3e67 | 1068 | |
becanromain | 0:cf6b1eca3e67 | 1069 | |
becanromain | 0:cf6b1eca3e67 | 1070 | } |
becanromain | 0:cf6b1eca3e67 | 1071 | static void mboxMdp_ACT2(lv_obj_t * obj, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1072 | { |
becanromain | 0:cf6b1eca3e67 | 1073 | lv_obj_del_async(FondGris2); |
becanromain | 0:cf6b1eca3e67 | 1074 | lv_ta_set_text(MDP, ""); |
becanromain | 0:cf6b1eca3e67 | 1075 | } |
becanromain | 0:cf6b1eca3e67 | 1076 | |
becanromain | 0:cf6b1eca3e67 | 1077 | |
becanromain | 0:cf6b1eca3e67 | 1078 | //************************** |
becanromain | 0:cf6b1eca3e67 | 1079 | // ACTION BOUTONS MENUS |
becanromain | 0:cf6b1eca3e67 | 1080 | //************************** |
becanromain | 0:cf6b1eca3e67 | 1081 | |
becanromain | 0:cf6b1eca3e67 | 1082 | static void Reglage_R_RGB(lv_obj_t * obj, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1083 | { |
becanromain | 0:cf6b1eca3e67 | 1084 | if(event == LV_EVENT_PRESSING) { |
becanromain | 0:cf6b1eca3e67 | 1085 | Reglage_R= lv_slider_get_value(obj); |
becanromain | 0:cf6b1eca3e67 | 1086 | sprintf(text, " %d ",Reglage_R ); |
becanromain | 0:cf6b1eca3e67 | 1087 | lv_label_set_text(Val_R, text); |
becanromain | 0:cf6b1eca3e67 | 1088 | } |
becanromain | 0:cf6b1eca3e67 | 1089 | } |
becanromain | 0:cf6b1eca3e67 | 1090 | |
becanromain | 0:cf6b1eca3e67 | 1091 | static void BPRAZ_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1092 | { |
becanromain | 0:cf6b1eca3e67 | 1093 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1094 | TpsMinEntre2Puls=999999; |
becanromain | 0:cf6b1eca3e67 | 1095 | TpsMaxEntre2Puls=0; |
becanromain | 0:cf6b1eca3e67 | 1096 | CptPuls=0; |
becanromain | 0:cf6b1eca3e67 | 1097 | Volume=0; |
becanromain | 0:cf6b1eca3e67 | 1098 | for (NumDent=20;NumDent>0;NumDent--){ |
becanromain | 0:cf6b1eca3e67 | 1099 | TpsEntre2Puls[NumDent]=0; |
becanromain | 0:cf6b1eca3e67 | 1100 | MemTpsPuls=0; |
becanromain | 0:cf6b1eca3e67 | 1101 | MemTps16Puls=0; |
becanromain | 0:cf6b1eca3e67 | 1102 | } |
becanromain | 0:cf6b1eca3e67 | 1103 | } |
becanromain | 0:cf6b1eca3e67 | 1104 | } |
becanromain | 0:cf6b1eca3e67 | 1105 | static void M100_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1106 | { |
becanromain | 0:cf6b1eca3e67 | 1107 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1108 | PosX_MenuDepart = lv_obj_get_x(BandeauHaut); |
becanromain | 0:cf6b1eca3e67 | 1109 | PosX_MenuCible = -lv_obj_get_x(M100); |
becanromain | 0:cf6b1eca3e67 | 1110 | DdeAlignMenu=1; |
becanromain | 0:cf6b1eca3e67 | 1111 | NumSousMenu=100; |
becanromain | 0:cf6b1eca3e67 | 1112 | } |
becanromain | 0:cf6b1eca3e67 | 1113 | } |
becanromain | 0:cf6b1eca3e67 | 1114 | static void M200_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1115 | { |
becanromain | 0:cf6b1eca3e67 | 1116 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1117 | PosX_MenuDepart = lv_obj_get_x(BandeauHaut); |
becanromain | 0:cf6b1eca3e67 | 1118 | PosX_MenuCible = -lv_obj_get_x(M200); |
becanromain | 0:cf6b1eca3e67 | 1119 | DdeAlignMenu=1; |
becanromain | 0:cf6b1eca3e67 | 1120 | NumSousMenu=200; |
becanromain | 0:cf6b1eca3e67 | 1121 | } |
becanromain | 0:cf6b1eca3e67 | 1122 | } |
becanromain | 0:cf6b1eca3e67 | 1123 | static void M300_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1124 | { |
becanromain | 0:cf6b1eca3e67 | 1125 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1126 | PosX_MenuDepart = lv_obj_get_x(BandeauHaut); |
becanromain | 0:cf6b1eca3e67 | 1127 | PosX_MenuCible = -lv_obj_get_x(M300); |
becanromain | 0:cf6b1eca3e67 | 1128 | DdeAlignMenu=1; |
becanromain | 0:cf6b1eca3e67 | 1129 | NumSousMenu=300; |
becanromain | 0:cf6b1eca3e67 | 1130 | } |
becanromain | 0:cf6b1eca3e67 | 1131 | } |
becanromain | 0:cf6b1eca3e67 | 1132 | static void M400_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1133 | { |
becanromain | 0:cf6b1eca3e67 | 1134 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1135 | PosX_MenuDepart = lv_obj_get_x(BandeauHaut); |
becanromain | 0:cf6b1eca3e67 | 1136 | PosX_MenuCible = -lv_obj_get_x(M400); |
becanromain | 0:cf6b1eca3e67 | 1137 | DdeAlignMenu=1; |
becanromain | 0:cf6b1eca3e67 | 1138 | NumSousMenu=400; |
becanromain | 0:cf6b1eca3e67 | 1139 | } |
becanromain | 0:cf6b1eca3e67 | 1140 | } |
becanromain | 0:cf6b1eca3e67 | 1141 | static void M500_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1142 | { |
becanromain | 0:cf6b1eca3e67 | 1143 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1144 | PosX_MenuDepart = lv_obj_get_x(BandeauHaut); |
becanromain | 0:cf6b1eca3e67 | 1145 | PosX_MenuCible = -lv_obj_get_x(M500); |
becanromain | 0:cf6b1eca3e67 | 1146 | DdeAlignMenu=1; |
becanromain | 0:cf6b1eca3e67 | 1147 | NumSousMenu=500; |
becanromain | 0:cf6b1eca3e67 | 1148 | } |
becanromain | 0:cf6b1eca3e67 | 1149 | } |
becanromain | 0:cf6b1eca3e67 | 1150 | static void M600_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1151 | { |
becanromain | 0:cf6b1eca3e67 | 1152 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1153 | PosX_MenuDepart = lv_obj_get_x(BandeauHaut); |
becanromain | 0:cf6b1eca3e67 | 1154 | PosX_MenuCible = -lv_obj_get_x(M600); |
becanromain | 0:cf6b1eca3e67 | 1155 | DdeAlignMenu=1; |
becanromain | 0:cf6b1eca3e67 | 1156 | NumSousMenu=600; |
becanromain | 0:cf6b1eca3e67 | 1157 | } |
becanromain | 0:cf6b1eca3e67 | 1158 | } |
becanromain | 0:cf6b1eca3e67 | 1159 | //************************** |
becanromain | 0:cf6b1eca3e67 | 1160 | // ACTION BOUTONS SOUS MENUS |
becanromain | 0:cf6b1eca3e67 | 1161 | //************************** |
becanromain | 0:cf6b1eca3e67 | 1162 | static void SM101_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1163 | { |
becanromain | 0:cf6b1eca3e67 | 1164 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1165 | //VERIFICATION AUTORISATION ACCES |
becanromain | 0:cf6b1eca3e67 | 1166 | uint8_t EtatBp = lv_btn_get_state(btn); |
becanromain | 0:cf6b1eca3e67 | 1167 | if (EtatBp==LV_BTN_STATE_INA){ |
becanromain | 0:cf6b1eca3e67 | 1168 | AFFPopupMDP(); |
becanromain | 0:cf6b1eca3e67 | 1169 | } |
becanromain | 0:cf6b1eca3e67 | 1170 | else{ |
becanromain | 0:cf6b1eca3e67 | 1171 | TpsAvFermSousMenu=0; |
becanromain | 0:cf6b1eca3e67 | 1172 | } |
becanromain | 0:cf6b1eca3e67 | 1173 | } |
becanromain | 0:cf6b1eca3e67 | 1174 | } |
becanromain | 0:cf6b1eca3e67 | 1175 | |
becanromain | 0:cf6b1eca3e67 | 1176 | static void SM102_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1177 | { |
becanromain | 0:cf6b1eca3e67 | 1178 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1179 | //VERIFICATION AUTORISATION ACCES |
becanromain | 0:cf6b1eca3e67 | 1180 | uint8_t EtatBp = lv_btn_get_state(btn); |
becanromain | 0:cf6b1eca3e67 | 1181 | if (EtatBp==LV_BTN_STATE_INA){ |
becanromain | 0:cf6b1eca3e67 | 1182 | AFFPopupMDP(); |
becanromain | 0:cf6b1eca3e67 | 1183 | } |
becanromain | 0:cf6b1eca3e67 | 1184 | else{ |
becanromain | 0:cf6b1eca3e67 | 1185 | TpsAvFermSousMenu=0; |
becanromain | 0:cf6b1eca3e67 | 1186 | } |
becanromain | 0:cf6b1eca3e67 | 1187 | } |
becanromain | 0:cf6b1eca3e67 | 1188 | } |
becanromain | 0:cf6b1eca3e67 | 1189 | static void SM103_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1190 | { |
becanromain | 0:cf6b1eca3e67 | 1191 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1192 | //VERIFICATION AUTORISATION ACCES |
becanromain | 0:cf6b1eca3e67 | 1193 | uint8_t EtatBp = lv_btn_get_state(btn); |
becanromain | 0:cf6b1eca3e67 | 1194 | if (EtatBp==LV_BTN_STATE_INA){ |
becanromain | 0:cf6b1eca3e67 | 1195 | AFFPopupMDP(); |
becanromain | 0:cf6b1eca3e67 | 1196 | } |
becanromain | 0:cf6b1eca3e67 | 1197 | else{ |
becanromain | 0:cf6b1eca3e67 | 1198 | TpsAvFermSousMenu=0; |
becanromain | 0:cf6b1eca3e67 | 1199 | } |
becanromain | 0:cf6b1eca3e67 | 1200 | } |
becanromain | 0:cf6b1eca3e67 | 1201 | } |
becanromain | 0:cf6b1eca3e67 | 1202 | static void SM104_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1203 | { |
becanromain | 0:cf6b1eca3e67 | 1204 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1205 | //VERIFICATION AUTORISATION ACCES |
becanromain | 0:cf6b1eca3e67 | 1206 | uint8_t EtatBp = lv_btn_get_state(btn); |
becanromain | 0:cf6b1eca3e67 | 1207 | if (EtatBp==LV_BTN_STATE_INA){ |
becanromain | 0:cf6b1eca3e67 | 1208 | AFFPopupMDP(); |
becanromain | 0:cf6b1eca3e67 | 1209 | } |
becanromain | 0:cf6b1eca3e67 | 1210 | else{ |
becanromain | 0:cf6b1eca3e67 | 1211 | TpsAvFermSousMenu=0; |
becanromain | 0:cf6b1eca3e67 | 1212 | } |
becanromain | 0:cf6b1eca3e67 | 1213 | } |
becanromain | 0:cf6b1eca3e67 | 1214 | } |
becanromain | 0:cf6b1eca3e67 | 1215 | static void SM105_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1216 | { |
becanromain | 0:cf6b1eca3e67 | 1217 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1218 | //VERIFICATION AUTORISATION ACCES |
becanromain | 0:cf6b1eca3e67 | 1219 | uint8_t EtatBp = lv_btn_get_state(btn); |
becanromain | 0:cf6b1eca3e67 | 1220 | if (EtatBp==LV_BTN_STATE_INA){ |
becanromain | 0:cf6b1eca3e67 | 1221 | AFFPopupMDP(); |
becanromain | 0:cf6b1eca3e67 | 1222 | } |
becanromain | 0:cf6b1eca3e67 | 1223 | else{ |
becanromain | 0:cf6b1eca3e67 | 1224 | TpsAvFermSousMenu=0; |
becanromain | 0:cf6b1eca3e67 | 1225 | } |
becanromain | 0:cf6b1eca3e67 | 1226 | } |
becanromain | 0:cf6b1eca3e67 | 1227 | } |
becanromain | 0:cf6b1eca3e67 | 1228 | |
becanromain | 0:cf6b1eca3e67 | 1229 | static void SM201_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1230 | { |
becanromain | 0:cf6b1eca3e67 | 1231 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1232 | //VERIFICATION AUTORISATION ACCES |
becanromain | 0:cf6b1eca3e67 | 1233 | uint8_t EtatBp = lv_btn_get_state(btn); |
becanromain | 0:cf6b1eca3e67 | 1234 | if (EtatBp==LV_BTN_STATE_INA){ |
becanromain | 0:cf6b1eca3e67 | 1235 | AFFPopupMDP(); |
becanromain | 0:cf6b1eca3e67 | 1236 | } |
becanromain | 0:cf6b1eca3e67 | 1237 | else{ |
becanromain | 0:cf6b1eca3e67 | 1238 | TpsAvFermSousMenu=0; |
becanromain | 0:cf6b1eca3e67 | 1239 | } |
becanromain | 0:cf6b1eca3e67 | 1240 | } |
becanromain | 0:cf6b1eca3e67 | 1241 | } |
becanromain | 0:cf6b1eca3e67 | 1242 | static void SM202_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1243 | { |
becanromain | 0:cf6b1eca3e67 | 1244 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1245 | //VERIFICATION AUTORISATION ACCES |
becanromain | 0:cf6b1eca3e67 | 1246 | uint8_t EtatBp = lv_btn_get_state(btn); |
becanromain | 0:cf6b1eca3e67 | 1247 | if (EtatBp==LV_BTN_STATE_INA){ |
becanromain | 0:cf6b1eca3e67 | 1248 | AFFPopupMDP(); |
becanromain | 0:cf6b1eca3e67 | 1249 | } |
becanromain | 0:cf6b1eca3e67 | 1250 | else{ |
becanromain | 0:cf6b1eca3e67 | 1251 | TpsAvFermSousMenu=0; |
becanromain | 0:cf6b1eca3e67 | 1252 | } |
becanromain | 0:cf6b1eca3e67 | 1253 | } |
becanromain | 0:cf6b1eca3e67 | 1254 | } |
becanromain | 0:cf6b1eca3e67 | 1255 | static void SM203_ACT(lv_obj_t * btn, lv_event_t event) |
becanromain | 0:cf6b1eca3e67 | 1256 | { |
becanromain | 0:cf6b1eca3e67 | 1257 | if(event == LV_EVENT_CLICKED) { |
becanromain | 0:cf6b1eca3e67 | 1258 | //VERIFICATION AUTORISATION ACCES |
becanromain | 0:cf6b1eca3e67 | 1259 | uint8_t EtatBp = lv_btn_get_state(btn); |
becanromain | 0:cf6b1eca3e67 | 1260 | if (EtatBp==LV_BTN_STATE_INA){ |
becanromain | 0:cf6b1eca3e67 | 1261 | AFFPopupMDP(); |
becanromain | 0:cf6b1eca3e67 | 1262 | } |
becanromain | 0:cf6b1eca3e67 | 1263 | else{ |
becanromain | 0:cf6b1eca3e67 | 1264 | TpsAvFermSousMenu=0; |
becanromain | 0:cf6b1eca3e67 | 1265 | } |
becanromain | 0:cf6b1eca3e67 | 1266 | } |
becanromain | 0:cf6b1eca3e67 | 1267 | } |
becanromain | 0:cf6b1eca3e67 | 1268 | |
becanromain | 0:cf6b1eca3e67 | 1269 | //GABOR: is it a Good way to make a multilingual application? |
becanromain | 0:cf6b1eca3e67 | 1270 | //******************** |
becanromain | 0:cf6b1eca3e67 | 1271 | // MULTILANGUE |
becanromain | 0:cf6b1eca3e67 | 1272 | //******************** |
becanromain | 0:cf6b1eca3e67 | 1273 | //Message multilangue |
becanromain | 0:cf6b1eca3e67 | 1274 | char * Message(int Num){ |
becanromain | 0:cf6b1eca3e67 | 1275 | if (Num<900){ |
becanromain | 0:cf6b1eca3e67 | 1276 | if (Langue==1){Num=Num+1000;}//FRANCAIS |
becanromain | 0:cf6b1eca3e67 | 1277 | if (Langue==2){Num=Num+2000;}//ANGLAIS |
becanromain | 0:cf6b1eca3e67 | 1278 | if (Langue==3){Num=Num+3000;}//????? |
becanromain | 0:cf6b1eca3e67 | 1279 | if (Langue==4){Num=Num+4000;}//????? |
becanromain | 0:cf6b1eca3e67 | 1280 | } |
becanromain | 0:cf6b1eca3e67 | 1281 | |
becanromain | 0:cf6b1eca3e67 | 1282 | switch (Num) { |
becanromain | 0:cf6b1eca3e67 | 1283 | //FRANCAIS// //ANGLAIS// //????// //????// |
becanromain | 0:cf6b1eca3e67 | 1284 | case 1000: return "";break; case 2000: return "";break; case 3000: return "";break; case 4000: return "";break; |
becanromain | 0:cf6b1eca3e67 | 1285 | case 1001: return "ANNULER";break; case 2001: return "CANCEL";break; case 3001: return "VOLUME";break; case 4001: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1286 | case 1002: return "TEMPERATURE 1";break; case 2002: return "TEMPERATURE 1";break; case 3002: return "TEMPERATURE 1";break; case 4002: return "TEMPERATURE 1";break; |
becanromain | 0:cf6b1eca3e67 | 1287 | case 1003: return "PRESSION 1";break; case 2003: return "VOLUME";break; case 3003: return "VOLUME";break; case 4003: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1288 | case 1004: return "HYGROMETRIE 1";break; case 2004: return "VOLUME";break; case 3004: return "VOLUME";break; case 4004: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1289 | 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; |
becanromain | 0:cf6b1eca3e67 | 1290 | 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; |
becanromain | 0:cf6b1eca3e67 | 1291 | case 1007: return "Normolitre/min: (DIN1343)";break; case 2007: return "VOLUME";break; case 3007: return "VOLUME";break; case 4007: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1292 | case 1008: return "Normolitre/min: (ISO2533)";break; case 2008: return "VOLUME";break; case 3008: return "VOLUME";break; case 4008: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1293 | case 1009: return "Normolitre/min: (Ref Personnalisee)";break; case 2009: return "VOLUME";break; case 3009: return "VOLUME";break; case 4009: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1294 | 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; |
becanromain | 0:cf6b1eca3e67 | 1295 | case 1011: return "DEBIT MASSIQUE MESURE";break; case 2011: return "VOLUME";break; case 3011: return "VOLUME";break; case 4011: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1296 | case 1012: return "Masse calculee";break; case 2012: return "VOLUME";break; case 3012: return "VOLUME";break; case 4012: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1297 | case 1013: return "TEMPERATURE 2";break; case 2013: return "VOLUME";break; case 3013: return "VOLUME";break; case 4013: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1298 | case 1014: return "PRESSION 2";break; case 2014: return "VOLUME";break; case 3014: return "VOLUME";break; case 4014: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1299 | case 1015: return "HYGROMETRIE 2";break; case 2015: return "VOLUME";break; case 3015: return "VOLUME";break; case 4015: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1300 | 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; |
becanromain | 0:cf6b1eca3e67 | 1301 | 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; |
becanromain | 0:cf6b1eca3e67 | 1302 | case 1018: return "NOMBRE D'IMPULSIONS";break; case 2018: return "VOLUME";break; case 3018: return "VOLUME";break; case 4018: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1303 | case 1019: return "TOTALISATEUR";break; case 2019: return "VOLUME";break; case 3019: return "VOLUME";break; case 4019: return "VOLUME";break; |
becanromain | 0:cf6b1eca3e67 | 1304 | case 1020: return "RAZ VOLUME EN COURS";break; case 2020: return "VOLUME";break; case 3020: return "VOLUME";break; case 4020: return "VOLUME MESURE";break; |
becanromain | 0:cf6b1eca3e67 | 1305 | 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; |
becanromain | 0:cf6b1eca3e67 | 1306 | } |
becanromain | 0:cf6b1eca3e67 | 1307 | } |
becanromain | 0:cf6b1eca3e67 | 1308 | |
becanromain | 0:cf6b1eca3e67 | 1309 | //******************** |
becanromain | 0:cf6b1eca3e67 | 1310 | // FONCTIONS GENERALES |
becanromain | 0:cf6b1eca3e67 | 1311 | //******************** |
becanromain | 0:cf6b1eca3e67 | 1312 | void lv_ticker_func() |
becanromain | 0:cf6b1eca3e67 | 1313 | { |
becanromain | 0:cf6b1eca3e67 | 1314 | lv_tick_inc(5); //Call lv_tick_inc(x) every x milliseconds in a Timer or Task (x should be between 1 and 10). It is required for the internal timing of LittlevGL. |
becanromain | 0:cf6b1eca3e67 | 1315 | } |
becanromain | 0:cf6b1eca3e67 | 1316 | |
becanromain | 0:cf6b1eca3e67 | 1317 | //FONCTION D'AFFICHAGE |
becanromain | 0:cf6b1eca3e67 | 1318 | void my_disp_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_t* color_p) |
becanromain | 0:cf6b1eca3e67 | 1319 | { |
becanromain | 0:cf6b1eca3e67 | 1320 | //The most simple case (but also the slowest) to put all pixels to the screen one-by-one |
becanromain | 0:cf6b1eca3e67 | 1321 | uint16_t x, y; |
becanromain | 0:cf6b1eca3e67 | 1322 | for(y = area->y1; y <= area->y2; y++) { |
becanromain | 0:cf6b1eca3e67 | 1323 | for(x = area->x1; x <= area->x2; x++) { |
becanromain | 0:cf6b1eca3e67 | 1324 | |
becanromain | 0:cf6b1eca3e67 | 1325 | lcd.DrawPixel( x, y, color_p->full); |
becanromain | 0:cf6b1eca3e67 | 1326 | color_p++; |
becanromain | 0:cf6b1eca3e67 | 1327 | } |
becanromain | 0:cf6b1eca3e67 | 1328 | } |
becanromain | 0:cf6b1eca3e67 | 1329 | |
becanromain | 0:cf6b1eca3e67 | 1330 | // IMPORTANT!!! |
becanromain | 0:cf6b1eca3e67 | 1331 | // Inform the graphics library that you are ready with the flushing |
becanromain | 0:cf6b1eca3e67 | 1332 | lv_disp_flush_ready(disp_drv); |
becanromain | 0:cf6b1eca3e67 | 1333 | } |
becanromain | 0:cf6b1eca3e67 | 1334 | |
becanromain | 0:cf6b1eca3e67 | 1335 | //FONCTION RECUPERATION COORDONNEES APPUI |
becanromain | 0:cf6b1eca3e67 | 1336 | bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) |
becanromain | 0:cf6b1eca3e67 | 1337 | { |
becanromain | 0:cf6b1eca3e67 | 1338 | static lv_coord_t last_x = 0; |
becanromain | 0:cf6b1eca3e67 | 1339 | static lv_coord_t last_y = 0; |
becanromain | 0:cf6b1eca3e67 | 1340 | |
becanromain | 0:cf6b1eca3e67 | 1341 | //Save the state and save the pressed coordinate |
becanromain | 0:cf6b1eca3e67 | 1342 | ts.GetState(&TS_State); |
becanromain | 0:cf6b1eca3e67 | 1343 | |
becanromain | 0:cf6b1eca3e67 | 1344 | if(TS_State.touchDetected == 1) { |
becanromain | 0:cf6b1eca3e67 | 1345 | data->state = LV_INDEV_STATE_PR; |
becanromain | 0:cf6b1eca3e67 | 1346 | } else { |
becanromain | 0:cf6b1eca3e67 | 1347 | data->state = LV_INDEV_STATE_REL; |
becanromain | 0:cf6b1eca3e67 | 1348 | } |
becanromain | 0:cf6b1eca3e67 | 1349 | |
becanromain | 0:cf6b1eca3e67 | 1350 | //data->state = tttt ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; |
becanromain | 0:cf6b1eca3e67 | 1351 | // if(data->state == LV_INDEV_STATE_PR){ |
becanromain | 0:cf6b1eca3e67 | 1352 | if(data->state == LV_INDEV_STATE_PR) { |
becanromain | 0:cf6b1eca3e67 | 1353 | //touchpad_get_xy(&last_x, &last_y); |
becanromain | 0:cf6b1eca3e67 | 1354 | last_x = TS_State.touchX[0]; |
becanromain | 0:cf6b1eca3e67 | 1355 | last_y = TS_State.touchY[0]; |
becanromain | 0:cf6b1eca3e67 | 1356 | } |
becanromain | 0:cf6b1eca3e67 | 1357 | |
becanromain | 0:cf6b1eca3e67 | 1358 | //Set the coordinates (if released use the last pressed coordinates) |
becanromain | 0:cf6b1eca3e67 | 1359 | data->point.x = last_x; |
becanromain | 0:cf6b1eca3e67 | 1360 | data->point.y = last_y; |
becanromain | 0:cf6b1eca3e67 | 1361 | |
becanromain | 0:cf6b1eca3e67 | 1362 | X = TS_State.touchDetected ; |
becanromain | 0:cf6b1eca3e67 | 1363 | |
becanromain | 0:cf6b1eca3e67 | 1364 | |
becanromain | 0:cf6b1eca3e67 | 1365 | |
becanromain | 0:cf6b1eca3e67 | 1366 | return false; //Return `false` because we are not buffering and no more data to read |
becanromain | 0:cf6b1eca3e67 | 1367 | } |
becanromain | 0:cf6b1eca3e67 | 1368 |