Changes between Version 28 and Version 29 of IOC_T06
- Timestamp:
- Mar 20, 2026, 11:50:00 AM (7 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
IOC_T06
v28 v29 180 180 181 181 {{{#!c 182 / /--------------------------------------------------------------------------------------------------------------------182 / -------------------------------------------------------------------------------------------------------------------- 183 183 // Multi-tâches cooperatives : solution basique mais efficace :-) 184 184 // -------------------------------------------------------------------------------------------------------------------- … … 198 198 unsigned long waitFor(int timer, unsigned long period) { 199 199 static unsigned long last_period[MAX_WAIT_FOR_TIMER]; // il y a autant de timers que de tâches 200 unsigned long current = micros() / period; // numéro de période200 unsigned long current = micros() / period; // numéro de période 201 201 unsigned long delta = current - last_period[timer]; // gère le wrap-around 202 202 if (delta) last_period[timer] = current; // mise à jour si déclenchement … … 204 204 } 205 205 206 //--------- dé finition de la tache Led206 //--------- déclaration de la tache Led 207 207 208 208 typedef struct { … … 212 212 int etat; // etat interne de la led 213 213 } ctx_led_t; 214 215 void init_led(ctx_led_t * ctx, int timer, unsigned long period, byte pin); 216 void step_led(ctx_led_t * ctx); 217 218 //--------- déclaration de la tache Mess 219 220 typedef struct { 221 int timer; // numéro de timer utilisé par WaitFor 222 unsigned long period; // periode d'affichage 223 char mess[20]; 224 } ctx_mess_t; 225 226 void init_mess(ctx_mess_t * ctx, int timer, unsigned long period, const char * mess); 227 void step_mess(ctx_mess_t *ctx); 228 229 //--------- définition de la tache Led 214 230 215 231 void init_led(ctx_led_t * ctx, int timer, unsigned long period, byte pin) { … … 230 246 //--------- definition de la tache Mess 231 247 232 typedef struct {233 int timer; // numéro de timer utilisé par WaitFor234 unsigned long period; // periode d'affichage235 char mess[20];236 } ctx_mess_t;237 238 248 void init_mess(ctx_mess_t * ctx, int timer, unsigned long period, const char * mess) { 239 249 ctx->timer = timer; … … 248 258 } 249 259 250 //--------- Déclaration des contextede tâches260 //--------- déclaration des contextes de tâches 251 261 252 262 ctx_led_t Led1; … … 263 273 step_led(&Led1); 264 274 step_mess(&Mess1); 265 } 275 } 266 276 }}} 267 277
