Projet Station Domotique MONTEIRO Lenny
Dependencies: BSP_DISCO_F746NG ds3231
main.cpp@6:17d880088476, 2022-06-15 (annotated)
- Committer:
- lenny14
- Date:
- Wed Jun 15 17:36:19 2022 +0000
- Revision:
- 6:17d880088476
- Parent:
- 5:071136c3eefa
Commit initiale
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JohnnyK | 5:071136c3eefa | 1 | /** |
JohnnyK | 5:071136c3eefa | 2 | * Notebook page https://os.mbed.com/users/JohnnyK/notebook/how-start-with-the-littlevgl/ |
JohnnyK | 5:071136c3eefa | 3 | */ |
JohnnyK | 5:071136c3eefa | 4 | |
lenny14 | 6:17d880088476 | 5 | #include "lv_area.h" |
lenny14 | 6:17d880088476 | 6 | #include "lv_btn.h" |
lenny14 | 6:17d880088476 | 7 | #include "lv_disp.h" |
JohnnyK | 0:10c4b83c458d | 8 | #include "lvgl/lvgl.h" |
JohnnyK | 3:4f5dc253eb7b | 9 | #include "hal_stm_lvgl/tft/tft.h" |
JohnnyK | 3:4f5dc253eb7b | 10 | #include "hal_stm_lvgl/touchpad/touchpad.h" |
lenny14 | 6:17d880088476 | 11 | #include "ds3231.h" |
lenny14 | 6:17d880088476 | 12 | #include "mbed.h" |
lenny14 | 6:17d880088476 | 13 | |
lenny14 | 6:17d880088476 | 14 | static BufferedSerial pc(USBTX, USBRX);// Pour le debug |
JohnnyK | 0:10c4b83c458d | 15 | |
JohnnyK | 3:4f5dc253eb7b | 16 | #define LVGL_TICK 10 //Time tick value for lvgl in ms (1-10msa) |
JohnnyK | 3:4f5dc253eb7b | 17 | #define TICKER_TIME 10ms //modified to miliseconds |
JohnnyK | 0:10c4b83c458d | 18 | |
lenny14 | 6:17d880088476 | 19 | int heure_actuel = 0;// heure actuel du provenant du RTC externe |
lenny14 | 6:17d880088476 | 20 | |
lenny14 | 6:17d880088476 | 21 | int heure_debut1 = 0;// heure de debut en h |
lenny14 | 6:17d880088476 | 22 | int heure_debut2 = 0;// heure de debut en h |
lenny14 | 6:17d880088476 | 23 | int heure_debut3 = 0;// heure de debut en h |
lenny14 | 6:17d880088476 | 24 | |
lenny14 | 6:17d880088476 | 25 | int heure_fin1 = 0;// heure de debut en h |
lenny14 | 6:17d880088476 | 26 | int heure_fin2 = 0;// heure de debut en h |
lenny14 | 6:17d880088476 | 27 | int heure_fin3 = 0;// heure de debut en h |
lenny14 | 6:17d880088476 | 28 | |
lenny14 | 6:17d880088476 | 29 | int select = 0;//0 = rien 1 = selection heure de debut 2 = selection heure de fin lors du clic sur les boutons concernés |
lenny14 | 6:17d880088476 | 30 | |
lenny14 | 6:17d880088476 | 31 | |
lenny14 | 6:17d880088476 | 32 | // SDA SCL |
lenny14 | 6:17d880088476 | 33 | Ds3231 rtc(D14, D15);// initialisation des broches I2C du RTC |
lenny14 | 6:17d880088476 | 34 | |
lenny14 | 6:17d880088476 | 35 | ds3231_time_t temps;//structure contenant l'heure/minute/sec actuel |
lenny14 | 6:17d880088476 | 36 | |
JohnnyK | 3:4f5dc253eb7b | 37 | Ticker ticker; //Ticker for lvgl |
lenny14 | 6:17d880088476 | 38 | |
lenny14 | 6:17d880088476 | 39 | DigitalOut out1(A0);//Sortie1 |
lenny14 | 6:17d880088476 | 40 | DigitalOut out2(A1);//Sortie2 |
lenny14 | 6:17d880088476 | 41 | DigitalOut out3(A2);//Sortie3 |
lenny14 | 6:17d880088476 | 42 | |
lenny14 | 6:17d880088476 | 43 | //pointeur btn1 |
lenny14 | 6:17d880088476 | 44 | lv_obj_t * btn1; |
lenny14 | 6:17d880088476 | 45 | |
lenny14 | 6:17d880088476 | 46 | //pointeur btn2 |
lenny14 | 6:17d880088476 | 47 | lv_obj_t * btn2; |
lenny14 | 6:17d880088476 | 48 | |
lenny14 | 6:17d880088476 | 49 | //pointeur btn3 |
lenny14 | 6:17d880088476 | 50 | lv_obj_t * btn3; |
lenny14 | 6:17d880088476 | 51 | |
lenny14 | 6:17d880088476 | 52 | /* Boutons pour incrémenter/décrémenter les heures */ |
lenny14 | 6:17d880088476 | 53 | |
lenny14 | 6:17d880088476 | 54 | //pointeur btn_incrementer1 |
lenny14 | 6:17d880088476 | 55 | lv_obj_t * btn_inc1; |
lenny14 | 6:17d880088476 | 56 | |
lenny14 | 6:17d880088476 | 57 | //pointeur btn_decrementer1 |
lenny14 | 6:17d880088476 | 58 | lv_obj_t * btn_dec1; |
lenny14 | 6:17d880088476 | 59 | |
lenny14 | 6:17d880088476 | 60 | //pointeur btn_incrementer2 |
lenny14 | 6:17d880088476 | 61 | lv_obj_t * btn_inc2; |
lenny14 | 6:17d880088476 | 62 | |
lenny14 | 6:17d880088476 | 63 | //pointeur btn_decrementer2 |
lenny14 | 6:17d880088476 | 64 | lv_obj_t * btn_dec2; |
lenny14 | 6:17d880088476 | 65 | |
lenny14 | 6:17d880088476 | 66 | //pointeur btn_incrementer3 |
lenny14 | 6:17d880088476 | 67 | lv_obj_t * btn_inc3; |
lenny14 | 6:17d880088476 | 68 | |
lenny14 | 6:17d880088476 | 69 | //pointeur btn_decrementer3 |
lenny14 | 6:17d880088476 | 70 | lv_obj_t * btn_dec3; |
lenny14 | 6:17d880088476 | 71 | |
lenny14 | 6:17d880088476 | 72 | /* A l'heure de début le relai est alimenté, et à l'heure de fin le relai n'est plus alimenté */ |
lenny14 | 6:17d880088476 | 73 | |
lenny14 | 6:17d880088476 | 74 | //pointeur bouton heure de début1 |
lenny14 | 6:17d880088476 | 75 | lv_obj_t * btn_heure_debut1; |
lenny14 | 6:17d880088476 | 76 | |
lenny14 | 6:17d880088476 | 77 | //pointeur bouton heure de fin1 |
lenny14 | 6:17d880088476 | 78 | lv_obj_t * btn_heure_fin1; |
lenny14 | 6:17d880088476 | 79 | |
lenny14 | 6:17d880088476 | 80 | //pointeur bouton heure de début2 |
lenny14 | 6:17d880088476 | 81 | lv_obj_t * btn_heure_debut2; |
lenny14 | 6:17d880088476 | 82 | |
lenny14 | 6:17d880088476 | 83 | //pointeur bouton heure de fin2 |
lenny14 | 6:17d880088476 | 84 | lv_obj_t * btn_heure_fin2; |
lenny14 | 6:17d880088476 | 85 | |
lenny14 | 6:17d880088476 | 86 | //pointeur bouton heure de début3 |
lenny14 | 6:17d880088476 | 87 | lv_obj_t * btn_heure_debut3; |
lenny14 | 6:17d880088476 | 88 | |
lenny14 | 6:17d880088476 | 89 | //pointeur bouton heure de fin3 |
lenny14 | 6:17d880088476 | 90 | lv_obj_t * btn_heure_fin3; |
lenny14 | 6:17d880088476 | 91 | |
lenny14 | 6:17d880088476 | 92 | //pointeur label heure de début1 |
lenny14 | 6:17d880088476 | 93 | lv_obj_t * label_heure_debut1; |
lenny14 | 6:17d880088476 | 94 | |
lenny14 | 6:17d880088476 | 95 | //pointeur label heure de début2 |
lenny14 | 6:17d880088476 | 96 | lv_obj_t * label_heure_debut2; |
lenny14 | 6:17d880088476 | 97 | |
lenny14 | 6:17d880088476 | 98 | //pointeur label heure de début3 |
lenny14 | 6:17d880088476 | 99 | lv_obj_t * label_heure_debut3; |
lenny14 | 6:17d880088476 | 100 | |
lenny14 | 6:17d880088476 | 101 | //pointeur label heure de fin1 |
lenny14 | 6:17d880088476 | 102 | lv_obj_t * label_heure_fin1; |
lenny14 | 6:17d880088476 | 103 | |
lenny14 | 6:17d880088476 | 104 | //pointeur label heure de début2 |
lenny14 | 6:17d880088476 | 105 | lv_obj_t * label_heure_fin2; |
lenny14 | 6:17d880088476 | 106 | |
lenny14 | 6:17d880088476 | 107 | //pointeur label heure de début3 |
lenny14 | 6:17d880088476 | 108 | lv_obj_t * label_heure_fin3; |
lenny14 | 6:17d880088476 | 109 | |
lenny14 | 6:17d880088476 | 110 | //pointeur label pour afficher l'heure actuelle |
lenny14 | 6:17d880088476 | 111 | lv_obj_t * label_affichage_heure; |
lenny14 | 6:17d880088476 | 112 | |
lenny14 | 6:17d880088476 | 113 | //pointeur label pour afficher le status de la sortie 1 |
lenny14 | 6:17d880088476 | 114 | lv_obj_t * label_status_1; |
lenny14 | 6:17d880088476 | 115 | |
lenny14 | 6:17d880088476 | 116 | //pointeur label pour afficher le status de la sortie 2 |
lenny14 | 6:17d880088476 | 117 | lv_obj_t * label_status_2; |
lenny14 | 6:17d880088476 | 118 | |
lenny14 | 6:17d880088476 | 119 | //pointeur label pour afficher le status de la sortie 3 |
lenny14 | 6:17d880088476 | 120 | lv_obj_t * label_status_3; |
lenny14 | 6:17d880088476 | 121 | |
lenny14 | 6:17d880088476 | 122 | static lv_style_t style_btn_inc_dec;//style pour tous les boutons inc et dec |
lenny14 | 6:17d880088476 | 123 | static lv_style_t style_btn_heure;//style pour tous les boutons heure début et fin |
lenny14 | 6:17d880088476 | 124 | |
lenny14 | 6:17d880088476 | 125 | // style bouton1 |
lenny14 | 6:17d880088476 | 126 | static lv_style_t style_btn1; |
lenny14 | 6:17d880088476 | 127 | static lv_style_t style_btn1_pressed; |
lenny14 | 6:17d880088476 | 128 | |
lenny14 | 6:17d880088476 | 129 | // style bouton1 |
lenny14 | 6:17d880088476 | 130 | static lv_style_t style_btn2; |
lenny14 | 6:17d880088476 | 131 | static lv_style_t style_btn2_pressed; |
lenny14 | 6:17d880088476 | 132 | |
lenny14 | 6:17d880088476 | 133 | // style bouton1 |
lenny14 | 6:17d880088476 | 134 | static lv_style_t style_btn3; |
lenny14 | 6:17d880088476 | 135 | static lv_style_t style_btn3_pressed; |
lenny14 | 6:17d880088476 | 136 | |
JohnnyK | 5:071136c3eefa | 137 | /* |
JohnnyK | 5:071136c3eefa | 138 | * Callback function for lvgl timing. |
JohnnyK | 5:071136c3eefa | 139 | * Call lv_tick_inc(x) every x milliseconds in a Timer or Task (x should be between 1 and 10). |
JohnnyK | 5:071136c3eefa | 140 | * It is required for the internal timing of LittlevGL. |
JohnnyK | 5:071136c3eefa | 141 | */ |
JohnnyK | 0:10c4b83c458d | 142 | void lv_ticker_func(){ |
JohnnyK | 0:10c4b83c458d | 143 | lv_tick_inc(LVGL_TICK); |
JohnnyK | 0:10c4b83c458d | 144 | } |
JohnnyK | 0:10c4b83c458d | 145 | |
lenny14 | 6:17d880088476 | 146 | // event btn1 |
lenny14 | 6:17d880088476 | 147 | static void event_btn1(lv_event_t * e) |
lenny14 | 6:17d880088476 | 148 | { |
lenny14 | 6:17d880088476 | 149 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 150 | |
lenny14 | 6:17d880088476 | 151 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 152 | { |
lenny14 | 6:17d880088476 | 153 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 154 | out1 = !out1; |
lenny14 | 6:17d880088476 | 155 | } |
lenny14 | 6:17d880088476 | 156 | } |
lenny14 | 6:17d880088476 | 157 | |
lenny14 | 6:17d880088476 | 158 | // event btn2 |
lenny14 | 6:17d880088476 | 159 | static void event_btn2(lv_event_t * e) |
lenny14 | 6:17d880088476 | 160 | { |
lenny14 | 6:17d880088476 | 161 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 162 | |
lenny14 | 6:17d880088476 | 163 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 164 | { |
lenny14 | 6:17d880088476 | 165 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 166 | out2 = !out2; |
lenny14 | 6:17d880088476 | 167 | } |
lenny14 | 6:17d880088476 | 168 | } |
lenny14 | 6:17d880088476 | 169 | |
lenny14 | 6:17d880088476 | 170 | // event btn3 |
lenny14 | 6:17d880088476 | 171 | static void event_btn3(lv_event_t * e) |
lenny14 | 6:17d880088476 | 172 | { |
lenny14 | 6:17d880088476 | 173 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 174 | |
lenny14 | 6:17d880088476 | 175 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 176 | { |
lenny14 | 6:17d880088476 | 177 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 178 | out3 = !out3; |
lenny14 | 6:17d880088476 | 179 | } |
lenny14 | 6:17d880088476 | 180 | } |
lenny14 | 6:17d880088476 | 181 | |
lenny14 | 6:17d880088476 | 182 | // event btn_inc1 |
lenny14 | 6:17d880088476 | 183 | static void event_btn_inc1(lv_event_t * e) |
lenny14 | 6:17d880088476 | 184 | { |
lenny14 | 6:17d880088476 | 185 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 186 | |
lenny14 | 6:17d880088476 | 187 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 188 | { |
lenny14 | 6:17d880088476 | 189 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 190 | |
lenny14 | 6:17d880088476 | 191 | //choix de l'heure à incrémenter(debut ou fin) |
lenny14 | 6:17d880088476 | 192 | if(select == 1) |
lenny14 | 6:17d880088476 | 193 | { |
lenny14 | 6:17d880088476 | 194 | heure_debut1++; |
lenny14 | 6:17d880088476 | 195 | } |
lenny14 | 6:17d880088476 | 196 | else if(select == 2) |
lenny14 | 6:17d880088476 | 197 | { |
lenny14 | 6:17d880088476 | 198 | heure_fin1++; |
lenny14 | 6:17d880088476 | 199 | } |
lenny14 | 6:17d880088476 | 200 | else |
lenny14 | 6:17d880088476 | 201 | { |
lenny14 | 6:17d880088476 | 202 | |
lenny14 | 6:17d880088476 | 203 | } |
lenny14 | 6:17d880088476 | 204 | } |
lenny14 | 6:17d880088476 | 205 | } |
lenny14 | 6:17d880088476 | 206 | |
lenny14 | 6:17d880088476 | 207 | // event btn_inc2 |
lenny14 | 6:17d880088476 | 208 | static void event_btn_inc2(lv_event_t * e) |
lenny14 | 6:17d880088476 | 209 | { |
lenny14 | 6:17d880088476 | 210 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 211 | |
lenny14 | 6:17d880088476 | 212 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 213 | { |
lenny14 | 6:17d880088476 | 214 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 215 | |
lenny14 | 6:17d880088476 | 216 | //choix de l'heure à incrémenter(debut ou fin |
lenny14 | 6:17d880088476 | 217 | if(select == 1) |
lenny14 | 6:17d880088476 | 218 | { |
lenny14 | 6:17d880088476 | 219 | heure_debut2++; |
lenny14 | 6:17d880088476 | 220 | } |
lenny14 | 6:17d880088476 | 221 | else if(select == 2) |
lenny14 | 6:17d880088476 | 222 | { |
lenny14 | 6:17d880088476 | 223 | heure_fin2++; |
lenny14 | 6:17d880088476 | 224 | } |
lenny14 | 6:17d880088476 | 225 | else |
lenny14 | 6:17d880088476 | 226 | { |
lenny14 | 6:17d880088476 | 227 | |
lenny14 | 6:17d880088476 | 228 | } |
lenny14 | 6:17d880088476 | 229 | } |
lenny14 | 6:17d880088476 | 230 | } |
lenny14 | 6:17d880088476 | 231 | |
lenny14 | 6:17d880088476 | 232 | // event btn_inc3 |
lenny14 | 6:17d880088476 | 233 | static void event_btn_inc3(lv_event_t * e) |
lenny14 | 6:17d880088476 | 234 | { |
lenny14 | 6:17d880088476 | 235 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 236 | |
lenny14 | 6:17d880088476 | 237 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 238 | { |
lenny14 | 6:17d880088476 | 239 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 240 | |
lenny14 | 6:17d880088476 | 241 | //choix de l'heure à incrémenter(debut ou fin |
lenny14 | 6:17d880088476 | 242 | if(select == 1) |
lenny14 | 6:17d880088476 | 243 | { |
lenny14 | 6:17d880088476 | 244 | heure_debut3++; |
lenny14 | 6:17d880088476 | 245 | } |
lenny14 | 6:17d880088476 | 246 | else if(select == 2) |
lenny14 | 6:17d880088476 | 247 | { |
lenny14 | 6:17d880088476 | 248 | heure_fin3++; |
lenny14 | 6:17d880088476 | 249 | } |
lenny14 | 6:17d880088476 | 250 | else |
lenny14 | 6:17d880088476 | 251 | { |
lenny14 | 6:17d880088476 | 252 | |
lenny14 | 6:17d880088476 | 253 | } |
lenny14 | 6:17d880088476 | 254 | } |
lenny14 | 6:17d880088476 | 255 | } |
lenny14 | 6:17d880088476 | 256 | |
lenny14 | 6:17d880088476 | 257 | // event btn_dec1 |
lenny14 | 6:17d880088476 | 258 | static void event_btn_dec1(lv_event_t * e) |
JohnnyK | 3:4f5dc253eb7b | 259 | { |
lenny14 | 6:17d880088476 | 260 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 261 | |
lenny14 | 6:17d880088476 | 262 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 263 | { |
lenny14 | 6:17d880088476 | 264 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 265 | |
lenny14 | 6:17d880088476 | 266 | //choix de l'heure à decrémenter(debut ou fin) |
lenny14 | 6:17d880088476 | 267 | if(select == 1) |
lenny14 | 6:17d880088476 | 268 | { |
lenny14 | 6:17d880088476 | 269 | heure_debut1--; |
lenny14 | 6:17d880088476 | 270 | } |
lenny14 | 6:17d880088476 | 271 | else if(select == 2) |
lenny14 | 6:17d880088476 | 272 | { |
lenny14 | 6:17d880088476 | 273 | heure_fin1--; |
lenny14 | 6:17d880088476 | 274 | } |
lenny14 | 6:17d880088476 | 275 | else |
lenny14 | 6:17d880088476 | 276 | { |
lenny14 | 6:17d880088476 | 277 | |
lenny14 | 6:17d880088476 | 278 | } |
lenny14 | 6:17d880088476 | 279 | } |
lenny14 | 6:17d880088476 | 280 | } |
lenny14 | 6:17d880088476 | 281 | |
lenny14 | 6:17d880088476 | 282 | // event btn_dec2 |
lenny14 | 6:17d880088476 | 283 | static void event_btn_dec2(lv_event_t * e) |
lenny14 | 6:17d880088476 | 284 | { |
lenny14 | 6:17d880088476 | 285 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 286 | |
lenny14 | 6:17d880088476 | 287 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 288 | { |
lenny14 | 6:17d880088476 | 289 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 290 | |
lenny14 | 6:17d880088476 | 291 | //choix de l'heure à decrémenter(debut ou fin) |
lenny14 | 6:17d880088476 | 292 | if(select == 1) |
lenny14 | 6:17d880088476 | 293 | { |
lenny14 | 6:17d880088476 | 294 | heure_debut2--; |
lenny14 | 6:17d880088476 | 295 | } |
lenny14 | 6:17d880088476 | 296 | else if(select == 2) |
lenny14 | 6:17d880088476 | 297 | { |
lenny14 | 6:17d880088476 | 298 | heure_fin2--; |
lenny14 | 6:17d880088476 | 299 | } |
lenny14 | 6:17d880088476 | 300 | else |
lenny14 | 6:17d880088476 | 301 | { |
lenny14 | 6:17d880088476 | 302 | |
lenny14 | 6:17d880088476 | 303 | } |
lenny14 | 6:17d880088476 | 304 | } |
lenny14 | 6:17d880088476 | 305 | } |
lenny14 | 6:17d880088476 | 306 | |
lenny14 | 6:17d880088476 | 307 | // event btn_dec3 |
lenny14 | 6:17d880088476 | 308 | static void event_btn_dec3(lv_event_t * e) |
lenny14 | 6:17d880088476 | 309 | { |
lenny14 | 6:17d880088476 | 310 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 311 | |
lenny14 | 6:17d880088476 | 312 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 313 | { |
lenny14 | 6:17d880088476 | 314 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 315 | |
lenny14 | 6:17d880088476 | 316 | //choix de l'heure à decrémenter(debut ou fin) |
lenny14 | 6:17d880088476 | 317 | if(select == 1) |
lenny14 | 6:17d880088476 | 318 | { |
lenny14 | 6:17d880088476 | 319 | heure_debut3--; |
lenny14 | 6:17d880088476 | 320 | } |
lenny14 | 6:17d880088476 | 321 | else if(select == 2) |
lenny14 | 6:17d880088476 | 322 | { |
lenny14 | 6:17d880088476 | 323 | heure_fin3--; |
lenny14 | 6:17d880088476 | 324 | } |
lenny14 | 6:17d880088476 | 325 | else |
lenny14 | 6:17d880088476 | 326 | { |
lenny14 | 6:17d880088476 | 327 | |
lenny14 | 6:17d880088476 | 328 | } |
JohnnyK | 3:4f5dc253eb7b | 329 | } |
lenny14 | 6:17d880088476 | 330 | } |
lenny14 | 6:17d880088476 | 331 | |
lenny14 | 6:17d880088476 | 332 | // event btn_heure_début1 |
lenny14 | 6:17d880088476 | 333 | static void event_btn_heure_debut1(lv_event_t * e) |
lenny14 | 6:17d880088476 | 334 | { |
lenny14 | 6:17d880088476 | 335 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 336 | |
lenny14 | 6:17d880088476 | 337 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 338 | { |
lenny14 | 6:17d880088476 | 339 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 340 | |
lenny14 | 6:17d880088476 | 341 | select = 1; //selection de l'heure de debut à incrementer ou à decrementer |
lenny14 | 6:17d880088476 | 342 | |
lenny14 | 6:17d880088476 | 343 | } |
lenny14 | 6:17d880088476 | 344 | } |
lenny14 | 6:17d880088476 | 345 | |
lenny14 | 6:17d880088476 | 346 | // event btn_heure_début2 |
lenny14 | 6:17d880088476 | 347 | static void event_btn_heure_debut2(lv_event_t * e) |
lenny14 | 6:17d880088476 | 348 | { |
lenny14 | 6:17d880088476 | 349 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 350 | |
lenny14 | 6:17d880088476 | 351 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 352 | { |
lenny14 | 6:17d880088476 | 353 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 354 | |
lenny14 | 6:17d880088476 | 355 | select = 1; //selection de l'heure de debut à incrementer ou à decrementer |
lenny14 | 6:17d880088476 | 356 | } |
lenny14 | 6:17d880088476 | 357 | } |
lenny14 | 6:17d880088476 | 358 | |
lenny14 | 6:17d880088476 | 359 | // event btn_heure_début3 |
lenny14 | 6:17d880088476 | 360 | static void event_btn_heure_debut3(lv_event_t * e) |
lenny14 | 6:17d880088476 | 361 | { |
lenny14 | 6:17d880088476 | 362 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 363 | |
lenny14 | 6:17d880088476 | 364 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 365 | { |
lenny14 | 6:17d880088476 | 366 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 367 | |
lenny14 | 6:17d880088476 | 368 | select = 1; //selection de l'heure de debut à incrementer ou à decrementer |
lenny14 | 6:17d880088476 | 369 | } |
lenny14 | 6:17d880088476 | 370 | } |
lenny14 | 6:17d880088476 | 371 | |
lenny14 | 6:17d880088476 | 372 | // event btn_heure_fin1 |
lenny14 | 6:17d880088476 | 373 | static void event_btn_heure_fin1(lv_event_t * e) |
lenny14 | 6:17d880088476 | 374 | { |
lenny14 | 6:17d880088476 | 375 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 376 | |
lenny14 | 6:17d880088476 | 377 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 378 | { |
lenny14 | 6:17d880088476 | 379 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 380 | |
lenny14 | 6:17d880088476 | 381 | select = 2; //selection de l'heure de fin à incrementer ou à decrementer |
lenny14 | 6:17d880088476 | 382 | } |
lenny14 | 6:17d880088476 | 383 | } |
lenny14 | 6:17d880088476 | 384 | |
lenny14 | 6:17d880088476 | 385 | // event btn_heure_fin2 |
lenny14 | 6:17d880088476 | 386 | static void event_btn_heure_fin2(lv_event_t * e) |
lenny14 | 6:17d880088476 | 387 | { |
lenny14 | 6:17d880088476 | 388 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 389 | |
lenny14 | 6:17d880088476 | 390 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 391 | { |
lenny14 | 6:17d880088476 | 392 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 393 | |
lenny14 | 6:17d880088476 | 394 | select = 2; //selection de l'heure de fin à incrementer ou à decrementer |
lenny14 | 6:17d880088476 | 395 | } |
lenny14 | 6:17d880088476 | 396 | } |
lenny14 | 6:17d880088476 | 397 | |
lenny14 | 6:17d880088476 | 398 | // event btn_heure_fin3 |
lenny14 | 6:17d880088476 | 399 | static void event_btn_heure_fin3(lv_event_t * e) |
lenny14 | 6:17d880088476 | 400 | { |
lenny14 | 6:17d880088476 | 401 | lv_event_code_t code = lv_event_get_code(e); |
lenny14 | 6:17d880088476 | 402 | |
lenny14 | 6:17d880088476 | 403 | if(code == LV_EVENT_CLICKED) //clic btn |
lenny14 | 6:17d880088476 | 404 | { |
lenny14 | 6:17d880088476 | 405 | LV_LOG_USER("Clicked"); |
lenny14 | 6:17d880088476 | 406 | select = 2; //selection de l'heure de fin à incrementer ou à decrementer |
JohnnyK | 0:10c4b83c458d | 407 | } |
JohnnyK | 1:627f26953c53 | 408 | } |
lenny14 | 6:17d880088476 | 409 | |
lenny14 | 6:17d880088476 | 410 | void Init_Widgets()//Fonction qui initialise les Widgets |
lenny14 | 6:17d880088476 | 411 | { |
lenny14 | 6:17d880088476 | 412 | //Init style btn1 |
lenny14 | 6:17d880088476 | 413 | lv_style_init(&style_btn1); |
lenny14 | 6:17d880088476 | 414 | lv_style_set_bg_color(&style_btn1, lv_color_hex(0x4542f5));//couleur bleu |
lenny14 | 6:17d880088476 | 415 | |
lenny14 | 6:17d880088476 | 416 | //Init style pressed btn1 |
lenny14 | 6:17d880088476 | 417 | lv_style_init(&style_btn1_pressed); |
lenny14 | 6:17d880088476 | 418 | lv_style_set_bg_color(&style_btn1_pressed, lv_color_hex(0xf54242));//couleur rouge quand on appuie sur le btn |
lenny14 | 6:17d880088476 | 419 | |
lenny14 | 6:17d880088476 | 420 | //init btn1 |
lenny14 | 6:17d880088476 | 421 | btn1 = lv_btn_create(lv_scr_act());//creation du bouton |
lenny14 | 6:17d880088476 | 422 | lv_obj_set_size(btn1, 100, 50);//dimention du bouton |
lenny14 | 6:17d880088476 | 423 | lv_obj_set_pos(btn1, 60, 50);//position du bouton |
lenny14 | 6:17d880088476 | 424 | lv_obj_add_style(btn1, &style_btn1, LV_STATE_DEFAULT);//couleur bleu |
lenny14 | 6:17d880088476 | 425 | lv_obj_add_style(btn1, &style_btn1_pressed, LV_STATE_PRESSED);//couleur rouge quand on appuie sur le btn |
lenny14 | 6:17d880088476 | 426 | lv_obj_add_event_cb(btn1, event_btn1, LV_EVENT_ALL, NULL);//ajout de la fonction callback |
lenny14 | 6:17d880088476 | 427 | |
lenny14 | 6:17d880088476 | 428 | //label btn1 |
lenny14 | 6:17d880088476 | 429 | lv_obj_t * label1 = lv_label_create(btn1);//creation du label du bouton |
lenny14 | 6:17d880088476 | 430 | lv_obj_set_align(label1, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 431 | lv_label_set_text(label1, "SORTIE1");//ajout du texte |
lenny14 | 6:17d880088476 | 432 | |
lenny14 | 6:17d880088476 | 433 | //////////////////////////////////////////////////////////////////// |
lenny14 | 6:17d880088476 | 434 | |
lenny14 | 6:17d880088476 | 435 | |
lenny14 | 6:17d880088476 | 436 | //Init style btn2 |
lenny14 | 6:17d880088476 | 437 | lv_style_init(&style_btn2); |
lenny14 | 6:17d880088476 | 438 | lv_style_set_bg_color(&style_btn2, lv_color_hex(0x4542f5));//couleur bleu |
lenny14 | 6:17d880088476 | 439 | |
lenny14 | 6:17d880088476 | 440 | //Init style pressed btn2 |
lenny14 | 6:17d880088476 | 441 | lv_style_init(&style_btn2_pressed); |
lenny14 | 6:17d880088476 | 442 | lv_style_set_bg_color(&style_btn2_pressed, lv_color_hex(0xf54242));//couleur rouge quand on appuie sur le btn |
lenny14 | 6:17d880088476 | 443 | |
lenny14 | 6:17d880088476 | 444 | //init btn2 |
lenny14 | 6:17d880088476 | 445 | btn2 = lv_btn_create(lv_scr_act());//creation du bouton |
lenny14 | 6:17d880088476 | 446 | lv_obj_set_size(btn2, 100, 50);//dimention du bouton |
lenny14 | 6:17d880088476 | 447 | lv_obj_set_pos(btn2, 60, 110);//position du bouton |
lenny14 | 6:17d880088476 | 448 | lv_obj_add_style(btn2, &style_btn2, LV_STATE_DEFAULT);//couleur bleu |
lenny14 | 6:17d880088476 | 449 | lv_obj_add_style(btn2, &style_btn2_pressed, LV_STATE_PRESSED);//couleur rouge quand on appuie sur le btn |
lenny14 | 6:17d880088476 | 450 | lv_obj_add_event_cb(btn2, event_btn2, LV_EVENT_ALL, NULL);//ajout de la fonction callback |
lenny14 | 6:17d880088476 | 451 | |
lenny14 | 6:17d880088476 | 452 | //label btn2 |
lenny14 | 6:17d880088476 | 453 | lv_obj_t * label2 = lv_label_create(btn2);//creation du label du bouton |
lenny14 | 6:17d880088476 | 454 | lv_obj_set_align(label2, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 455 | lv_label_set_text(label2, "SORTIE2");//ajout du texte |
lenny14 | 6:17d880088476 | 456 | |
lenny14 | 6:17d880088476 | 457 | //////////////////////////////////////////////////////////////////// |
lenny14 | 6:17d880088476 | 458 | |
lenny14 | 6:17d880088476 | 459 | |
lenny14 | 6:17d880088476 | 460 | //Init style btn3 |
lenny14 | 6:17d880088476 | 461 | lv_style_init(&style_btn3); |
lenny14 | 6:17d880088476 | 462 | lv_style_set_bg_color(&style_btn3, lv_color_hex(0x4542f5));//couleur bleu |
lenny14 | 6:17d880088476 | 463 | |
lenny14 | 6:17d880088476 | 464 | //Init style pressed btn3 |
lenny14 | 6:17d880088476 | 465 | lv_style_init(&style_btn3_pressed); |
lenny14 | 6:17d880088476 | 466 | lv_style_set_bg_color(&style_btn3_pressed, lv_color_hex(0xf54242));//couleur rouge quand on appuie sur le btn |
lenny14 | 6:17d880088476 | 467 | |
lenny14 | 6:17d880088476 | 468 | //init btn3 |
lenny14 | 6:17d880088476 | 469 | btn3 = lv_btn_create(lv_scr_act());//creation du bouton |
lenny14 | 6:17d880088476 | 470 | lv_obj_set_size(btn3, 100, 50);//dimention du bouton |
lenny14 | 6:17d880088476 | 471 | lv_obj_set_pos(btn3, 60, 170);//position du bouton |
lenny14 | 6:17d880088476 | 472 | lv_obj_add_style(btn3, &style_btn3, LV_STATE_DEFAULT);//couleur bleu |
lenny14 | 6:17d880088476 | 473 | lv_obj_add_style(btn3, &style_btn3_pressed, LV_STATE_PRESSED);//couleur rouge quand on appuie sur le btn |
lenny14 | 6:17d880088476 | 474 | lv_obj_add_event_cb(btn3, event_btn3, LV_EVENT_ALL, NULL);//ajout de la fonction callback |
lenny14 | 6:17d880088476 | 475 | |
lenny14 | 6:17d880088476 | 476 | //label btn3 |
lenny14 | 6:17d880088476 | 477 | lv_obj_t * label3 = lv_label_create(btn3);//creation du label du bouton |
lenny14 | 6:17d880088476 | 478 | lv_obj_set_align(label3, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 479 | lv_label_set_text(label3, "SORTIE3");//ajout du texte |
lenny14 | 6:17d880088476 | 480 | |
lenny14 | 6:17d880088476 | 481 | //////////////////////////////////////////////////////////////////// |
lenny14 | 6:17d880088476 | 482 | |
lenny14 | 6:17d880088476 | 483 | lv_style_init(&style_btn_inc_dec);//Initialisation du style des boutons dec et inc |
lenny14 | 6:17d880088476 | 484 | |
lenny14 | 6:17d880088476 | 485 | //////////////////////////////////////////////////////////////////// |
lenny14 | 6:17d880088476 | 486 | |
lenny14 | 6:17d880088476 | 487 | lv_style_set_bg_color(&style_btn_inc_dec, lv_color_hex(0x01a600));//couleur verte pour le style |
lenny14 | 6:17d880088476 | 488 | |
lenny14 | 6:17d880088476 | 489 | //creation des boutons inc et dec |
lenny14 | 6:17d880088476 | 490 | btn_inc1 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 491 | btn_inc2 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 492 | btn_inc3 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 493 | |
lenny14 | 6:17d880088476 | 494 | btn_dec1 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 495 | btn_dec2 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 496 | btn_dec3 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 497 | |
lenny14 | 6:17d880088476 | 498 | //ajout du style pour les btn inc et dec |
lenny14 | 6:17d880088476 | 499 | lv_obj_add_style(btn_inc1, &style_btn_inc_dec, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 500 | lv_obj_add_style(btn_inc2, &style_btn_inc_dec, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 501 | lv_obj_add_style(btn_inc3, &style_btn_inc_dec, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 502 | |
lenny14 | 6:17d880088476 | 503 | lv_obj_add_style(btn_dec1, &style_btn_inc_dec, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 504 | lv_obj_add_style(btn_dec2, &style_btn_inc_dec, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 505 | lv_obj_add_style(btn_dec3, &style_btn_inc_dec, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 506 | |
lenny14 | 6:17d880088476 | 507 | //positionnement et dimensionnement des bouton |
lenny14 | 6:17d880088476 | 508 | lv_obj_set_size(btn_inc1, 25, 25);//dimention du bouton |
lenny14 | 6:17d880088476 | 509 | lv_obj_set_pos(btn_inc1, 200, 50);//position du bouton |
lenny14 | 6:17d880088476 | 510 | |
lenny14 | 6:17d880088476 | 511 | lv_obj_set_size(btn_inc2, 25, 25);//dimention du bouton |
lenny14 | 6:17d880088476 | 512 | lv_obj_set_pos(btn_inc2, 200, 110);//position du bouton |
lenny14 | 6:17d880088476 | 513 | |
lenny14 | 6:17d880088476 | 514 | lv_obj_set_size(btn_inc3, 25, 25);//dimention du bouton |
lenny14 | 6:17d880088476 | 515 | lv_obj_set_pos(btn_inc3, 200, 170);//position du bouton |
lenny14 | 6:17d880088476 | 516 | |
lenny14 | 6:17d880088476 | 517 | //label btn_inc1 |
lenny14 | 6:17d880088476 | 518 | lv_obj_t * label_inc1 = lv_label_create(btn_inc1);//creation du label du bouton |
lenny14 | 6:17d880088476 | 519 | lv_obj_set_align(label_inc1, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 520 | lv_label_set_text(label_inc1, "+");//ajout du texte |
lenny14 | 6:17d880088476 | 521 | |
lenny14 | 6:17d880088476 | 522 | //label btn_inc2 |
lenny14 | 6:17d880088476 | 523 | lv_obj_t * label_inc2 = lv_label_create(btn_inc2);//creation du label du bouton |
lenny14 | 6:17d880088476 | 524 | lv_obj_set_align(label_inc2, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 525 | lv_label_set_text(label_inc2, "+");//ajout du texte |
lenny14 | 6:17d880088476 | 526 | |
lenny14 | 6:17d880088476 | 527 | //label btn_inc3 |
lenny14 | 6:17d880088476 | 528 | lv_obj_t * label_inc3 = lv_label_create(btn_inc3);//creation du label du bouton |
lenny14 | 6:17d880088476 | 529 | lv_obj_set_align(label_inc3, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 530 | lv_label_set_text(label_inc3, "+");//ajout du texte |
lenny14 | 6:17d880088476 | 531 | |
lenny14 | 6:17d880088476 | 532 | //positionnement et dimensionnement des bouton |
lenny14 | 6:17d880088476 | 533 | lv_obj_set_size(btn_dec1, 25, 25);//dimention du bouton |
lenny14 | 6:17d880088476 | 534 | lv_obj_set_pos(btn_dec1, 200, 75);//position du bouton |
lenny14 | 6:17d880088476 | 535 | |
lenny14 | 6:17d880088476 | 536 | lv_obj_set_size(btn_dec2, 25, 25);//dimention du bouton |
lenny14 | 6:17d880088476 | 537 | lv_obj_set_pos(btn_dec2, 200, 135);//position du bouton |
lenny14 | 6:17d880088476 | 538 | |
lenny14 | 6:17d880088476 | 539 | lv_obj_set_size(btn_dec3, 25, 25);//dimention du bouton |
lenny14 | 6:17d880088476 | 540 | lv_obj_set_pos(btn_dec3, 200, 195);//position du bouton |
lenny14 | 6:17d880088476 | 541 | |
lenny14 | 6:17d880088476 | 542 | //label btn_dec1 |
lenny14 | 6:17d880088476 | 543 | lv_obj_t * label_dec1 = lv_label_create(btn_dec1);//creation du label du bouton |
lenny14 | 6:17d880088476 | 544 | lv_obj_set_align(label_dec1, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 545 | lv_label_set_text(label_dec1, "-");//ajout du texte |
lenny14 | 6:17d880088476 | 546 | |
lenny14 | 6:17d880088476 | 547 | //label btn_dec2 |
lenny14 | 6:17d880088476 | 548 | lv_obj_t * label_dec2 = lv_label_create(btn_dec2);//creation du label du bouton |
lenny14 | 6:17d880088476 | 549 | lv_obj_set_align(label_dec2, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 550 | lv_label_set_text(label_dec2, "-");//ajout du texte |
lenny14 | 6:17d880088476 | 551 | |
lenny14 | 6:17d880088476 | 552 | //label btn_dec3 |
lenny14 | 6:17d880088476 | 553 | lv_obj_t * label_dec3 = lv_label_create(btn_dec3);//creation du label du bouton |
lenny14 | 6:17d880088476 | 554 | lv_obj_set_align(label_dec3, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 555 | lv_label_set_text(label_dec3, "-");//ajout du texte |
lenny14 | 6:17d880088476 | 556 | |
lenny14 | 6:17d880088476 | 557 | //ajout des fonction callback des btn inc et dec |
lenny14 | 6:17d880088476 | 558 | lv_obj_add_event_cb(btn_inc1, event_btn_inc1, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 559 | lv_obj_add_event_cb(btn_inc2, event_btn_inc2, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 560 | lv_obj_add_event_cb(btn_inc3, event_btn_inc3, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 561 | |
lenny14 | 6:17d880088476 | 562 | lv_obj_add_event_cb(btn_dec1, event_btn_dec1, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 563 | lv_obj_add_event_cb(btn_dec2, event_btn_dec2, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 564 | lv_obj_add_event_cb(btn_dec3, event_btn_dec3, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 565 | |
lenny14 | 6:17d880088476 | 566 | /////////////////////////////////////////////////////////////////////////// |
lenny14 | 6:17d880088476 | 567 | |
lenny14 | 6:17d880088476 | 568 | lv_style_set_bg_color(&style_btn_heure, lv_color_hex(0xf79e0d));//couleur orange pour le style |
lenny14 | 6:17d880088476 | 569 | |
lenny14 | 6:17d880088476 | 570 | //creation des boutons heure début/fin |
lenny14 | 6:17d880088476 | 571 | btn_heure_debut1 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 572 | btn_heure_debut2 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 573 | btn_heure_debut3 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 574 | |
lenny14 | 6:17d880088476 | 575 | btn_heure_fin1 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 576 | btn_heure_fin2 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 577 | btn_heure_fin3 = lv_btn_create(lv_scr_act()); |
lenny14 | 6:17d880088476 | 578 | |
lenny14 | 6:17d880088476 | 579 | //ajout du style pour les boutons heure début/fin |
lenny14 | 6:17d880088476 | 580 | lv_obj_add_style(btn_heure_debut1, &style_btn_heure, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 581 | lv_obj_add_style(btn_heure_debut2, &style_btn_heure, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 582 | lv_obj_add_style(btn_heure_debut3, &style_btn_heure, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 583 | |
lenny14 | 6:17d880088476 | 584 | lv_obj_add_style(btn_heure_fin1, &style_btn_heure, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 585 | lv_obj_add_style(btn_heure_fin2, &style_btn_heure, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 586 | lv_obj_add_style(btn_heure_fin3, &style_btn_heure, LV_STATE_DEFAULT); |
lenny14 | 6:17d880088476 | 587 | |
lenny14 | 6:17d880088476 | 588 | //positionnement et dimensionnement des bouton |
lenny14 | 6:17d880088476 | 589 | lv_obj_set_size(btn_heure_debut1, 100, 50);//dimention du bouton |
lenny14 | 6:17d880088476 | 590 | lv_obj_set_pos(btn_heure_debut1, 225, 50);//position du bouton |
lenny14 | 6:17d880088476 | 591 | |
lenny14 | 6:17d880088476 | 592 | lv_obj_set_size(btn_heure_debut2, 100, 50);//dimention du bouton |
lenny14 | 6:17d880088476 | 593 | lv_obj_set_pos(btn_heure_debut2, 225, 110);//position du bouton |
lenny14 | 6:17d880088476 | 594 | |
lenny14 | 6:17d880088476 | 595 | lv_obj_set_size(btn_heure_debut3, 100, 50);//dimention du bouton |
lenny14 | 6:17d880088476 | 596 | lv_obj_set_pos(btn_heure_debut3, 225, 170);//position du bouton |
lenny14 | 6:17d880088476 | 597 | |
lenny14 | 6:17d880088476 | 598 | lv_obj_set_size(btn_heure_fin1, 100, 50);//dimention du bouton |
lenny14 | 6:17d880088476 | 599 | lv_obj_set_pos(btn_heure_fin1, 325, 50);//position du bouton |
lenny14 | 6:17d880088476 | 600 | |
lenny14 | 6:17d880088476 | 601 | lv_obj_set_size(btn_heure_fin2, 100, 50);//dimention du bouton |
lenny14 | 6:17d880088476 | 602 | lv_obj_set_pos(btn_heure_fin2, 325, 110);//position du bouton |
lenny14 | 6:17d880088476 | 603 | |
lenny14 | 6:17d880088476 | 604 | lv_obj_set_size(btn_heure_fin3, 100, 50);//dimention du bouton |
lenny14 | 6:17d880088476 | 605 | lv_obj_set_pos(btn_heure_fin3, 325, 170);//position du bouton |
lenny14 | 6:17d880088476 | 606 | |
lenny14 | 6:17d880088476 | 607 | |
lenny14 | 6:17d880088476 | 608 | //label btn_heure de début1 |
lenny14 | 6:17d880088476 | 609 | label_heure_debut1 = lv_label_create(btn_heure_debut1);//creation du label du bouton |
lenny14 | 6:17d880088476 | 610 | lv_obj_set_align(label_heure_debut1, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 611 | lv_label_set_text(label_heure_debut1, "0h");//ajout du texte |
lenny14 | 6:17d880088476 | 612 | |
lenny14 | 6:17d880088476 | 613 | //label btn_heure de début2 |
lenny14 | 6:17d880088476 | 614 | label_heure_debut2 = lv_label_create(btn_heure_debut2);//creation du label du bouton |
lenny14 | 6:17d880088476 | 615 | lv_obj_set_align(label_heure_debut2, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 616 | lv_label_set_text(label_heure_debut2, "0h");//ajout du texte |
lenny14 | 6:17d880088476 | 617 | |
lenny14 | 6:17d880088476 | 618 | //label btn_heure de début1 |
lenny14 | 6:17d880088476 | 619 | label_heure_debut3 = lv_label_create(btn_heure_debut3);//creation du label du bouton |
lenny14 | 6:17d880088476 | 620 | lv_obj_set_align(label_heure_debut3, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 621 | lv_label_set_text(label_heure_debut3, "0h");//ajout du texte |
lenny14 | 6:17d880088476 | 622 | |
lenny14 | 6:17d880088476 | 623 | //label btn_heure de fin1 |
lenny14 | 6:17d880088476 | 624 | label_heure_fin1 = lv_label_create(btn_heure_fin1);//creation du label du bouton |
lenny14 | 6:17d880088476 | 625 | lv_obj_set_align(label_heure_fin1, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 626 | lv_label_set_text(label_heure_fin1, "0h");//ajout du texte |
lenny14 | 6:17d880088476 | 627 | |
lenny14 | 6:17d880088476 | 628 | //label btn_heure de début2 |
lenny14 | 6:17d880088476 | 629 | label_heure_fin2 = lv_label_create(btn_heure_fin2);//creation du label du bouton |
lenny14 | 6:17d880088476 | 630 | lv_obj_set_align(label_heure_fin2, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 631 | lv_label_set_text(label_heure_fin2, "0h");//ajout du texte |
lenny14 | 6:17d880088476 | 632 | |
lenny14 | 6:17d880088476 | 633 | //label btn_heure de début1 |
lenny14 | 6:17d880088476 | 634 | label_heure_fin3 = lv_label_create(btn_heure_fin3);//creation du label du bouton |
lenny14 | 6:17d880088476 | 635 | lv_obj_set_align(label_heure_fin3, LV_ALIGN_CENTER);//alignement |
lenny14 | 6:17d880088476 | 636 | lv_label_set_text(label_heure_fin3, "0h");//ajout du texte |
lenny14 | 6:17d880088476 | 637 | |
lenny14 | 6:17d880088476 | 638 | //ajout des fonction callback des btn heure debut/fin |
lenny14 | 6:17d880088476 | 639 | lv_obj_add_event_cb(btn_heure_debut1, event_btn_heure_debut1, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 640 | lv_obj_add_event_cb(btn_heure_debut2, event_btn_heure_debut2, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 641 | lv_obj_add_event_cb(btn_heure_debut3, event_btn_heure_debut3, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 642 | |
lenny14 | 6:17d880088476 | 643 | lv_obj_add_event_cb(btn_heure_fin1, event_btn_heure_fin1, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 644 | lv_obj_add_event_cb(btn_heure_fin2, event_btn_heure_fin2, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 645 | lv_obj_add_event_cb(btn_heure_fin3, event_btn_heure_fin3, LV_EVENT_ALL, NULL); |
lenny14 | 6:17d880088476 | 646 | |
lenny14 | 6:17d880088476 | 647 | ////////////////////////////////////////////////////////////////////////////////////// |
lenny14 | 6:17d880088476 | 648 | |
lenny14 | 6:17d880088476 | 649 | //label affichage de l'heure actuelle |
lenny14 | 6:17d880088476 | 650 | label_affichage_heure = lv_label_create(lv_scr_act()); //creation du label |
lenny14 | 6:17d880088476 | 651 | lv_obj_set_pos(label_affichage_heure, 220, 20); //position du labe |
lenny14 | 6:17d880088476 | 652 | lv_label_set_text(label_affichage_heure, "00:00:00"); //ajout du texte |
lenny14 | 6:17d880088476 | 653 | |
lenny14 | 6:17d880088476 | 654 | ////////////////////////////////////////////////////////////////////////////////////// |
lenny14 | 6:17d880088476 | 655 | |
lenny14 | 6:17d880088476 | 656 | |
lenny14 | 6:17d880088476 | 657 | //label status_1 |
lenny14 | 6:17d880088476 | 658 | label_status_1 = lv_label_create(lv_scr_act()); //creation du label |
lenny14 | 6:17d880088476 | 659 | lv_obj_set_pos(label_status_1, 17, 65); //position du label |
lenny14 | 6:17d880088476 | 660 | lv_label_set_text(label_status_1, "OFF"); //ajout du texte*/ |
lenny14 | 6:17d880088476 | 661 | |
lenny14 | 6:17d880088476 | 662 | //label status_2 |
lenny14 | 6:17d880088476 | 663 | label_status_2 = lv_label_create(lv_scr_act()); //creation du label |
lenny14 | 6:17d880088476 | 664 | lv_obj_set_pos(label_status_2, 17, 125); //position du label |
lenny14 | 6:17d880088476 | 665 | lv_label_set_text(label_status_2, "OFF"); //ajout du texte*/ |
lenny14 | 6:17d880088476 | 666 | |
lenny14 | 6:17d880088476 | 667 | //label status_3 |
lenny14 | 6:17d880088476 | 668 | label_status_3 = lv_label_create(lv_scr_act()); //creation du label |
lenny14 | 6:17d880088476 | 669 | lv_obj_set_pos(label_status_3, 17, 185); //position du label |
lenny14 | 6:17d880088476 | 670 | lv_label_set_text(label_status_3, "OFF"); //ajout du texte*/ |
lenny14 | 6:17d880088476 | 671 | } |
lenny14 | 6:17d880088476 | 672 | |
lenny14 | 6:17d880088476 | 673 | void Init_gpio()//Initialisation des sorties |
lenny14 | 6:17d880088476 | 674 | { |
lenny14 | 6:17d880088476 | 675 | out1.write(0); |
lenny14 | 6:17d880088476 | 676 | out2.write(0); |
lenny14 | 6:17d880088476 | 677 | out3.write(0); |
lenny14 | 6:17d880088476 | 678 | } |
lenny14 | 6:17d880088476 | 679 | |
JohnnyK | 0:10c4b83c458d | 680 | int main() |
lenny14 | 6:17d880088476 | 681 | { |
lenny14 | 6:17d880088476 | 682 | char text[30] = "";// tableau de caractère à afficher |
JohnnyK | 3:4f5dc253eb7b | 683 | printf("LVGL-"); |
JohnnyK | 3:4f5dc253eb7b | 684 | lv_init(); //Initialize the LVGL |
JohnnyK | 3:4f5dc253eb7b | 685 | tft_init(); //Initialize diplay |
JohnnyK | 3:4f5dc253eb7b | 686 | touchpad_init(); //Initialize touchpad |
JohnnyK | 3:4f5dc253eb7b | 687 | ticker.attach(callback(&lv_ticker_func),TICKER_TIME); //Attach callback to ticker |
JohnnyK | 3:4f5dc253eb7b | 688 | |
lenny14 | 6:17d880088476 | 689 | Init_Widgets(); //initialisation Widgets |
JohnnyK | 0:10c4b83c458d | 690 | |
JohnnyK | 3:4f5dc253eb7b | 691 | while (true){ |
JohnnyK | 3:4f5dc253eb7b | 692 | lv_task_handler(); |
JohnnyK | 3:4f5dc253eb7b | 693 | //Call lv_task_handler() periodically every few milliseconds. |
JohnnyK | 3:4f5dc253eb7b | 694 | //It will redraw the screen if required, handle input devices etc. |
JohnnyK | 3:4f5dc253eb7b | 695 | thread_sleep_for(LVGL_TICK); |
lenny14 | 6:17d880088476 | 696 | |
lenny14 | 6:17d880088476 | 697 | rtc.get_time(&temps);//lecture de l'heure actuel |
lenny14 | 6:17d880088476 | 698 | heure_actuel = temps.hours;//stockage |
lenny14 | 6:17d880088476 | 699 | |
lenny14 | 6:17d880088476 | 700 | /* Affichage de l'heure actuelle */ |
lenny14 | 6:17d880088476 | 701 | sprintf(text, "%d:%d:%d", temps.hours, temps.minutes, temps.seconds); |
lenny14 | 6:17d880088476 | 702 | lv_label_set_text(label_affichage_heure, text);//affichage |
lenny14 | 6:17d880088476 | 703 | |
lenny14 | 6:17d880088476 | 704 | /* Affichage des heure de debut et fin sur les label des bouton */ |
lenny14 | 6:17d880088476 | 705 | |
lenny14 | 6:17d880088476 | 706 | sprintf(text, "%dh", heure_debut1);//Formatage chaine |
lenny14 | 6:17d880088476 | 707 | lv_label_set_text(label_heure_debut1, text);//Affichage de la chaine formaté |
lenny14 | 6:17d880088476 | 708 | |
lenny14 | 6:17d880088476 | 709 | sprintf(text, "%dh", heure_debut2);//Formatage chaine |
lenny14 | 6:17d880088476 | 710 | lv_label_set_text(label_heure_debut2, text);//Affichage de la chaine formaté |
lenny14 | 6:17d880088476 | 711 | |
lenny14 | 6:17d880088476 | 712 | sprintf(text, "%dh", heure_debut3);//Formatage chaine |
lenny14 | 6:17d880088476 | 713 | lv_label_set_text(label_heure_debut3, text);//Affichage de la chaine formaté |
lenny14 | 6:17d880088476 | 714 | |
lenny14 | 6:17d880088476 | 715 | sprintf(text, "%dh", heure_fin1);//Formatage chaine |
lenny14 | 6:17d880088476 | 716 | lv_label_set_text(label_heure_fin1, text);//Affichage de la chaine formaté |
lenny14 | 6:17d880088476 | 717 | |
lenny14 | 6:17d880088476 | 718 | sprintf(text, "%dh", heure_fin2);//Formatage chaine |
lenny14 | 6:17d880088476 | 719 | lv_label_set_text(label_heure_fin2, text);//Affichage de la chaine formaté |
lenny14 | 6:17d880088476 | 720 | |
lenny14 | 6:17d880088476 | 721 | sprintf(text, "%dh", heure_fin3);//Formatage chaine |
lenny14 | 6:17d880088476 | 722 | lv_label_set_text(label_heure_fin3, text);//Affichage de la chaine formaté |
lenny14 | 6:17d880088476 | 723 | |
lenny14 | 6:17d880088476 | 724 | /* A l'heure de début le relai est alimenté, et à l'heure de fin le relai n'est plus alimenté */ |
lenny14 | 6:17d880088476 | 725 | |
lenny14 | 6:17d880088476 | 726 | if(heure_debut1 == heure_fin1)// si les heure(debut et fin) sont égaux |
lenny14 | 6:17d880088476 | 727 | { |
lenny14 | 6:17d880088476 | 728 | //on fait rien |
lenny14 | 6:17d880088476 | 729 | } |
lenny14 | 6:17d880088476 | 730 | else if(heure_actuel == heure_debut1)//si heure actuel est égal à l'heure de début |
lenny14 | 6:17d880088476 | 731 | { |
lenny14 | 6:17d880088476 | 732 | out1 = 1;//on active le relay |
lenny14 | 6:17d880088476 | 733 | } |
lenny14 | 6:17d880088476 | 734 | else if(heure_actuel == heure_fin1)//si heure actuel est égal à l'heure de fin |
lenny14 | 6:17d880088476 | 735 | { |
lenny14 | 6:17d880088476 | 736 | out1 = 0;//on desactive le relay |
lenny14 | 6:17d880088476 | 737 | } |
lenny14 | 6:17d880088476 | 738 | |
lenny14 | 6:17d880088476 | 739 | if(heure_debut2 == heure_fin2)// si les heure(debut et fin) sont égaux |
lenny14 | 6:17d880088476 | 740 | { |
lenny14 | 6:17d880088476 | 741 | //on fait rien² |
lenny14 | 6:17d880088476 | 742 | } |
lenny14 | 6:17d880088476 | 743 | else if(heure_actuel == heure_debut2)//si heure actuel est égal à l'heure de début |
lenny14 | 6:17d880088476 | 744 | { |
lenny14 | 6:17d880088476 | 745 | out2 = 1;//on active le relay |
lenny14 | 6:17d880088476 | 746 | } |
lenny14 | 6:17d880088476 | 747 | else if(heure_actuel == heure_fin2)//si heure actuel est égal à l'heure de fin |
lenny14 | 6:17d880088476 | 748 | { |
lenny14 | 6:17d880088476 | 749 | out2 = 0;//on desactive le relay |
lenny14 | 6:17d880088476 | 750 | } |
lenny14 | 6:17d880088476 | 751 | |
lenny14 | 6:17d880088476 | 752 | if(heure_debut3 == heure_fin3)// si les heure(debut et fin) sont égaux |
lenny14 | 6:17d880088476 | 753 | { |
lenny14 | 6:17d880088476 | 754 | //on fait rien |
lenny14 | 6:17d880088476 | 755 | } |
lenny14 | 6:17d880088476 | 756 | else if(heure_actuel == heure_debut3)//si heure actuel est égal à l'heure de début |
lenny14 | 6:17d880088476 | 757 | { |
lenny14 | 6:17d880088476 | 758 | out3 = 1;//on active le relay |
lenny14 | 6:17d880088476 | 759 | } |
lenny14 | 6:17d880088476 | 760 | else if(heure_actuel == heure_fin3)//si heure actuel est égal à l'heure de fin |
lenny14 | 6:17d880088476 | 761 | { |
lenny14 | 6:17d880088476 | 762 | out3 = 1;//on desactive le relay |
lenny14 | 6:17d880088476 | 763 | } |
lenny14 | 6:17d880088476 | 764 | |
lenny14 | 6:17d880088476 | 765 | /* Actualisation du status des sorties */ |
lenny14 | 6:17d880088476 | 766 | |
lenny14 | 6:17d880088476 | 767 | if(out1 == 1)// si la sortie est activé |
lenny14 | 6:17d880088476 | 768 | { |
lenny14 | 6:17d880088476 | 769 | lv_label_set_text(label_status_1, "ON"); |
lenny14 | 6:17d880088476 | 770 | } |
lenny14 | 6:17d880088476 | 771 | else if(out1 == 0)// si la sortie est désactivé |
lenny14 | 6:17d880088476 | 772 | { |
lenny14 | 6:17d880088476 | 773 | lv_label_set_text(label_status_1, "OFF"); |
lenny14 | 6:17d880088476 | 774 | } |
lenny14 | 6:17d880088476 | 775 | |
lenny14 | 6:17d880088476 | 776 | if(out2 == 1)// si la sortie est activé |
lenny14 | 6:17d880088476 | 777 | { |
lenny14 | 6:17d880088476 | 778 | lv_label_set_text(label_status_2, "ON"); |
lenny14 | 6:17d880088476 | 779 | } |
lenny14 | 6:17d880088476 | 780 | else if(out2 == 0)// si la sortie est désactivé |
lenny14 | 6:17d880088476 | 781 | { |
lenny14 | 6:17d880088476 | 782 | lv_label_set_text(label_status_2, "OFF"); |
lenny14 | 6:17d880088476 | 783 | } |
lenny14 | 6:17d880088476 | 784 | |
lenny14 | 6:17d880088476 | 785 | if(out3 == 1)// si la sortie est activé |
lenny14 | 6:17d880088476 | 786 | { |
lenny14 | 6:17d880088476 | 787 | lv_label_set_text(label_status_3, "ON"); |
lenny14 | 6:17d880088476 | 788 | } |
lenny14 | 6:17d880088476 | 789 | else if(out3 == 0)// si la sortie est désactivé |
lenny14 | 6:17d880088476 | 790 | { |
lenny14 | 6:17d880088476 | 791 | lv_label_set_text(label_status_3, "OFF"); |
lenny14 | 6:17d880088476 | 792 | } |
lenny14 | 6:17d880088476 | 793 | |
JohnnyK | 0:10c4b83c458d | 794 | } |
JohnnyK | 3:4f5dc253eb7b | 795 | } |