Yves Roy
/
247-436-M2-S4-TH-A
Exemple de création de classe (toggle)
Revision 0:d28be86053a3, committed 2018-02-14
- Comitter:
- YROY2004
- Date:
- Wed Feb 14 15:19:40 2018 +0000
- Commit message:
- exemple de cr?ation d'une classe (toggle)
Changed in this revision
diff -r 000000000000 -r d28be86053a3 maClasseToggle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/maClasseToggle.h Wed Feb 14 15:19:40 2018 +0000 @@ -0,0 +1,28 @@ +//#include "mbed.h" +class maClasseToggle +{ + public: + maClasseToggle(void) + { + statut = 0; + } + void toggle(void) + { + if (statut == 0) + { + statut = 1; + } + else + { + statut = 0; + } + } + unsigned char retourneStatut(void) + { + return statut; + } + private: + unsigned char statut; +}; + +
diff -r 000000000000 -r d28be86053a3 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Feb 14 15:19:40 2018 +0000 @@ -0,0 +1,18 @@ +//code dérivé du code présenté dans le document 2018-01 247-436 D-0015 M2-S4-TH (powerpoint) +#include "mbed.h" +#include "maClasseToggle.h" +int main() { + unsigned char retour; + DigitalOut monLED(LED1); + maClasseToggle monObjetToggle1; + + printf("initialisation\n"); + + while(1) { + monObjetToggle1.toggle(); + retour = monObjetToggle1.retourneStatut(); + printf("retour: %d\n", retour); + monLED = retour; + wait(1); + } +} \ No newline at end of file
diff -r 000000000000 -r d28be86053a3 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Feb 14 15:19:40 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/7130f322cb7e \ No newline at end of file