Laurent Huot
/
APP2
RTC et Timers
Fork of APP2 by
Revision 2:28fd10eccd74, committed 2016-01-25
- Comitter:
- larryspaghetti
- Date:
- Mon Jan 25 18:01:51 2016 +0000
- Parent:
- 1:7b379ec59b5d
- Commit message:
- dddd
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Jan 24 20:36:08 2016 +0000 +++ b/main.cpp Mon Jan 25 18:01:51 2016 +0000 @@ -86,23 +86,28 @@ // génération éventuelle d'un événement if(moyenneCourante > SEUIL_ANAL * NIVEAU_DC_ANAL) { - //Générer un évènement + //Générer un évènement + time_t seconds = time(NULL); + char buffer[32]; + strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); } } } void lecture_num(void const *args) { - bool lecture, lecturePrecedente; + bool lecture, lecturePrecedente, lectureDebut; while (true) { // lecture des échantillons numériques //TODO, généralisé la fonction - bool lectureDebut = en_1.read(); + lectureDebut = en_1.read(); wait_ms(FREQ_NUM_STAB_MS); - if(lectureDebut == en_1.read()) + if(lectureDebut != en_1.read()) { - + time_t seconds = time(NULL); + char buffer[32]; + strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds)); } // prise en charge du phénomène de rebond @@ -140,7 +145,13 @@ int main() { // initialisation du RTC set_time(1453667014); + // démarrage des tâches - while(1) { - } + RtosTimer anal_timer(lecture_num, osTimerPeriodic, NULL); + RtosTimer num_timer(lecture_analog, osTimerPeriodic, NULL); + + anal_timer.start(FREQ_ANAL_MS); + num_timer.start(FREQ_NUM_MS); + + while(1); } \ No newline at end of file