Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
Alarme/alarme.cpp@35:bda112796505, 2019-05-16 (annotated)
- Committer:
- ascheriit
- Date:
- Thu May 16 18:03:02 2019 +0000
- Revision:
- 35:bda112796505
- Parent:
- 34:2ea9312c0608
- Child:
- 39:b069cf6be013
Cahier des charges complet !!!!!!!!!!!!
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ascheriit | 27:86d38e8d3015 | 1 | # include "alarme.h" |
| ascheriit | 27:86d38e8d3015 | 2 | |
| ascheriit | 27:86d38e8d3015 | 3 | DigitalIn pinTgAl(PE_6); |
| ascheriit | 33:31271a36a9a4 | 4 | DigitalIn pinSeAl(PE_5); |
| ascheriit | 35:bda112796505 | 5 | DigitalOut pinAlarme(PG_13); |
| ascheriit | 27:86d38e8d3015 | 6 | |
| ascheriit | 27:86d38e8d3015 | 7 | void A_initAlarmes(STalarmes* all){ |
| ascheriit | 27:86d38e8d3015 | 8 | all->ListeAlarmes = (temps*) malloc(sizeof(temps) * NOMBREDALARMES); |
| ascheriit | 27:86d38e8d3015 | 9 | for(int i=0;i<NOMBREDALARMES;i++){ |
| ascheriit | 27:86d38e8d3015 | 10 | (all->ListeAlarmes+i)->heure = 0; |
| ascheriit | 27:86d38e8d3015 | 11 | (all->ListeAlarmes+i)->minute = 0; |
| ascheriit | 27:86d38e8d3015 | 12 | all->ListeActivation[i] = 0; |
| ascheriit | 27:86d38e8d3015 | 13 | } |
| ascheriit | 27:86d38e8d3015 | 14 | } |
| ascheriit | 27:86d38e8d3015 | 15 | |
| ascheriit | 27:86d38e8d3015 | 16 | void A_DisplayAlarmes(STalarmes* alarmesPNT){ |
| ascheriit | 27:86d38e8d3015 | 17 | STalarmes alarmes = *alarmesPNT; |
| ascheriit | 27:86d38e8d3015 | 18 | int positionYinit = 5; |
| ascheriit | 27:86d38e8d3015 | 19 | int positionYIncrement = 25; |
| ascheriit | 27:86d38e8d3015 | 20 | int alarmeTaille = 1; |
| ascheriit | 27:86d38e8d3015 | 21 | int positionXinit = 10; |
| ascheriit | 27:86d38e8d3015 | 22 | for(int i=0;i<NOMBREDALARMES;i++){ |
| ascheriit | 27:86d38e8d3015 | 23 | if(alarmes.positionCurseur==i){ |
| ascheriit | 27:86d38e8d3015 | 24 | DisplayMatrix(positionXinit,positionYinit + positionYIncrement * i,BS_fleche(),alarmeTaille * 2,COULEUR_FLECHE); |
| ascheriit | 27:86d38e8d3015 | 25 | }else{ |
| ascheriit | 27:86d38e8d3015 | 26 | DisplayMatrix(positionXinit,positionYinit + positionYIncrement * i,BS_fleche(),alarmeTaille * 2,COULEUR_FOND); |
| ascheriit | 27:86d38e8d3015 | 27 | } |
| ascheriit | 27:86d38e8d3015 | 28 | if(alarmes.ListeActivation[i]){ |
| ascheriit | 27:86d38e8d3015 | 29 | DisplayMatrix(positionXinit + alarmeTaille * 26,positionYinit + positionYIncrement * i,BS_cloche(),alarmeTaille,COULEUR_ACTIVE); |
| ascheriit | 27:86d38e8d3015 | 30 | }else{ |
| ascheriit | 27:86d38e8d3015 | 31 | DisplayMatrix(positionXinit + alarmeTaille * 26,positionYinit + positionYIncrement * i,BS_cloche(),alarmeTaille,COULEUR_OFF); |
| ascheriit | 27:86d38e8d3015 | 32 | } |
| ascheriit | 27:86d38e8d3015 | 33 | H_afficheHorlogeElemClean(*(alarmes.ListeAlarmes + i),positionXinit + alarmeTaille * 54,positionYinit + positionYIncrement * i,alarmeTaille * 2,COULEUR_HEURE_ALARME,COULEUR_FOND); |
| ascheriit | 27:86d38e8d3015 | 34 | } |
| ascheriit | 27:86d38e8d3015 | 35 | } |
| ascheriit | 27:86d38e8d3015 | 36 | |
| ascheriit | 34:2ea9312c0608 | 37 | void A_DisplayFleche(STalarmes* alarmesPNT){ |
| ascheriit | 34:2ea9312c0608 | 38 | int positionYinit = 5; |
| ascheriit | 34:2ea9312c0608 | 39 | int positionYIncrement = 25; |
| ascheriit | 34:2ea9312c0608 | 40 | int alarmeTaille = 1; |
| ascheriit | 34:2ea9312c0608 | 41 | int positionXinit = 10; |
| ascheriit | 34:2ea9312c0608 | 42 | for(int i=0;i<NOMBREDALARMES;i++){ |
| ascheriit | 34:2ea9312c0608 | 43 | if(alarmesPNT->positionCurseur==i){ |
| ascheriit | 34:2ea9312c0608 | 44 | DisplayMatrix(positionXinit,positionYinit + positionYIncrement * i,BS_fleche(),alarmeTaille * 2,COULEUR_FLECHE); |
| ascheriit | 34:2ea9312c0608 | 45 | }else{ |
| ascheriit | 34:2ea9312c0608 | 46 | DisplayMatrix(positionXinit,positionYinit + positionYIncrement * i,BS_fleche(),alarmeTaille * 2,COULEUR_FOND); |
| ascheriit | 34:2ea9312c0608 | 47 | } |
| ascheriit | 34:2ea9312c0608 | 48 | } |
| ascheriit | 34:2ea9312c0608 | 49 | } |
| ascheriit | 34:2ea9312c0608 | 50 | |
| ascheriit | 27:86d38e8d3015 | 51 | void A_getSelection(STalarmes* alarmesPNT){ |
| ascheriit | 27:86d38e8d3015 | 52 | alarmesPNT->positionCurseur=CR_donneSelection(CR_position(CR_readPins())); |
| ascheriit | 27:86d38e8d3015 | 53 | } |
| ascheriit | 27:86d38e8d3015 | 54 | |
| ascheriit | 27:86d38e8d3015 | 55 | void A_toogleAlarme(STalarmes* alarmesPNT){ |
| ascheriit | 33:31271a36a9a4 | 56 | if(pinTgAl.read() && alarmesPNT->positionCurseur < NOMBREDALARMES){ |
| ascheriit | 29:55d27fb3eb34 | 57 | while(pinTgAl.read()){ |
| ascheriit | 27:86d38e8d3015 | 58 | ; |
| ascheriit | 27:86d38e8d3015 | 59 | } |
| ascheriit | 29:55d27fb3eb34 | 60 | *(alarmesPNT->ListeActivation + alarmesPNT->positionCurseur)=!*(alarmesPNT->ListeActivation + alarmesPNT->positionCurseur); |
| ascheriit | 34:2ea9312c0608 | 61 | A_DisplayAlarmes(alarmesPNT); |
| ascheriit | 27:86d38e8d3015 | 62 | } |
| ascheriit | 27:86d38e8d3015 | 63 | } |
| ascheriit | 27:86d38e8d3015 | 64 | |
| ascheriit | 33:31271a36a9a4 | 65 | void A_setAlarme(STalarmes* alarmesPNT){ |
| ascheriit | 33:31271a36a9a4 | 66 | if(pinSeAl.read() && alarmesPNT->positionCurseur < NOMBREDALARMES){ |
| ascheriit | 33:31271a36a9a4 | 67 | while(pinSeAl.read()){ |
| ascheriit | 33:31271a36a9a4 | 68 | ; |
| ascheriit | 33:31271a36a9a4 | 69 | } |
| ascheriit | 33:31271a36a9a4 | 70 | int positionYinit = 5; |
| ascheriit | 33:31271a36a9a4 | 71 | int positionYIncrement = 25; |
| ascheriit | 33:31271a36a9a4 | 72 | int alarmeTaille = 1; |
| ascheriit | 33:31271a36a9a4 | 73 | int positionXinit = 10; |
| ascheriit | 33:31271a36a9a4 | 74 | H_reglage(alarmesPNT->ListeAlarmes + alarmesPNT->positionCurseur,positionXinit + alarmeTaille * 54,positionYinit + positionYIncrement * alarmesPNT->positionCurseur,alarmeTaille * 2,COULEUR_HEURE_ALARME_MOD,COULEUR_FOND); |
| ascheriit | 34:2ea9312c0608 | 75 | A_DisplayAlarmes(alarmesPNT); |
| ascheriit | 33:31271a36a9a4 | 76 | } |
| ascheriit | 33:31271a36a9a4 | 77 | } |
| ascheriit | 33:31271a36a9a4 | 78 | |
| ascheriit | 35:bda112796505 | 79 | void A_checkAlarmes(STalarmes* alarmesPNT,temps* maintenant){ |
| ascheriit | 35:bda112796505 | 80 | int isOn=0; //booléen pour test l'activation d'une alarme. |
| ascheriit | 35:bda112796505 | 81 | for(int i=0;i<NOMBREDALARMES;i++){ |
| ascheriit | 35:bda112796505 | 82 | if(*(alarmesPNT->ListeActivation + i) && (alarmesPNT->ListeAlarmes + i)->heure==maintenant->heure && (alarmesPNT->ListeAlarmes + i)->minute==maintenant->minute){ |
| ascheriit | 35:bda112796505 | 83 | isOn=1; |
| ascheriit | 35:bda112796505 | 84 | break; |
| ascheriit | 35:bda112796505 | 85 | } |
| ascheriit | 35:bda112796505 | 86 | } |
| ascheriit | 35:bda112796505 | 87 | pinAlarme=isOn; |
| ascheriit | 35:bda112796505 | 88 | } |
| ascheriit | 35:bda112796505 | 89 | |
| ascheriit | 35:bda112796505 | 90 | |
| ascheriit | 27:86d38e8d3015 | 91 | void A_test(){ |
| ascheriit | 27:86d38e8d3015 | 92 | STalarmes alarmes; |
| ascheriit | 27:86d38e8d3015 | 93 | A_initAlarmes(&alarmes); |
| ascheriit | 27:86d38e8d3015 | 94 | clean(); |
| ascheriit | 27:86d38e8d3015 | 95 | A_DisplayAlarmes(&alarmes); |
| ascheriit | 27:86d38e8d3015 | 96 | alarmes.positionCurseur=2; |
| ascheriit | 27:86d38e8d3015 | 97 | *(alarmes.ListeActivation+3)=1; |
| ascheriit | 27:86d38e8d3015 | 98 | (alarmes.ListeAlarmes+4)->minute=23; |
| ascheriit | 27:86d38e8d3015 | 99 | (alarmes.ListeAlarmes+4)->heure=17; |
| ascheriit | 33:31271a36a9a4 | 100 | wait(0.5); |
| ascheriit | 27:86d38e8d3015 | 101 | while(1){ |
| ascheriit | 33:31271a36a9a4 | 102 | //clean(); |
| ascheriit | 33:31271a36a9a4 | 103 | //wait(0.05); |
| ascheriit | 27:86d38e8d3015 | 104 | A_getSelection(&alarmes); |
| ascheriit | 29:55d27fb3eb34 | 105 | A_toogleAlarme(&alarmes); |
| ascheriit | 33:31271a36a9a4 | 106 | A_setAlarme(&alarmes); |
| ascheriit | 34:2ea9312c0608 | 107 | A_DisplayFleche(&alarmes); |
| ascheriit | 33:31271a36a9a4 | 108 | //H_toogleElem(); |
| ascheriit | 33:31271a36a9a4 | 109 | wait(0.15); |
| ascheriit | 27:86d38e8d3015 | 110 | } |
| ascheriit | 27:86d38e8d3015 | 111 | } |
