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: WakeUp mbed EPD_GDE021A1
Sources/main.cpp@14:65e134c75d8c, 2016-11-09 (annotated)
- Committer:
- nba
- Date:
- Wed Nov 09 21:42:18 2016 +0000
- Revision:
- 14:65e134c75d8c
- Parent:
- 13:0afb541c480e
- Child:
- 15:5bb6f11fc300
MAJ ecran
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mathieusab | 1:b1380b9f18c2 | 1 | /* |
| mathieusab | 1:b1380b9f18c2 | 2 | main.cpp comportant la machine d'état. |
| mathieusab | 1:b1380b9f18c2 | 3 | Les fonctions appelées par ce main doivent être déclarées dans des headers. |
| mathieusab | 1:b1380b9f18c2 | 4 | */ |
| mathieusab | 1:b1380b9f18c2 | 5 | |
| mathieusab | 1:b1380b9f18c2 | 6 | #include <stdio.h> |
| mathieusab | 1:b1380b9f18c2 | 7 | #include "mbed.h" |
| nba | 7:42302df77ca5 | 8 | #include "WakeUp.h" |
| nba | 13:0afb541c480e | 9 | #include "EPD_GDE021A1.h" |
| mathieusab | 1:b1380b9f18c2 | 10 | #include "../Headers/period.h" |
| mathieusab | 1:b1380b9f18c2 | 11 | #include "../Headers/states.h" |
| mathieusab | 1:b1380b9f18c2 | 12 | #include "../Headers/constants.h" |
| nba | 14:65e134c75d8c | 13 | //#include "../Headers/ecran.h" |
| nba | 13:0afb541c480e | 14 | //#include "../Headers/poids.h" |
| nba | 13:0afb541c480e | 15 | |
| nba | 13:0afb541c480e | 16 | //EPD_GDE021A1 epd(EPD_CS, EPD_DC, EPD_RESET, EPD_BUSY, EPD_POWER, EPD_SPI_MOSI, EPD_SPI_MISO, EPD_SPI_SCK);//Parametre l'ecrant E-Ink |
| mathieusab | 1:b1380b9f18c2 | 17 | |
| mathieusab | 1:b1380b9f18c2 | 18 | Serial pc(USBTX, USBRX); // serie USB (ne pas oublier de souder sur la carte) |
| nba | 13:0afb541c480e | 19 | InterruptIn bouton(PA_0); // bouton bleu en interuption |
| mathieusab | 1:b1380b9f18c2 | 20 | |
| mathieusab | 1:b1380b9f18c2 | 21 | State state = Start; // état de base : start |
| mathieusab | 1:b1380b9f18c2 | 22 | |
| mathieusab | 1:b1380b9f18c2 | 23 | int main () |
| mathieusab | 1:b1380b9f18c2 | 24 | { |
| nba | 14:65e134c75d8c | 25 | //bouton.rise(&Ecran.print()); |
| mathieusab | 1:b1380b9f18c2 | 26 | while(true) |
| mathieusab | 1:b1380b9f18c2 | 27 | { |
| mathieusab | 1:b1380b9f18c2 | 28 | switch(state) |
| mathieusab | 1:b1380b9f18c2 | 29 | { |
| mathieusab | 1:b1380b9f18c2 | 30 | case Start: |
| mathieusab | 12:ec54a73ea7ec | 31 | pc.printf("State Start\n"); |
| mathieusab | 1:b1380b9f18c2 | 32 | //TODO Test jour ou nuit |
| mathieusab | 1:b1380b9f18c2 | 33 | |
| mathieusab | 1:b1380b9f18c2 | 34 | //TODO SI jour, Etat suivant = DeepSleepShort |
| mathieusab | 1:b1380b9f18c2 | 35 | //TODO SI nuit, Etat suivant = DeepSleepLong |
| mathieusab | 1:b1380b9f18c2 | 36 | break; |
| mathieusab | 1:b1380b9f18c2 | 37 | case DeepSleepShort: |
| mathieusab | 12:ec54a73ea7ec | 38 | pc.printf("State DeepSleepShort\n"); |
| mathieusab | 1:b1380b9f18c2 | 39 | //TODO Ajouter appel à standby(...) |
| mathieusab | 1:b1380b9f18c2 | 40 | |
| mathieusab | 1:b1380b9f18c2 | 41 | //TODO Etat suivant = Start |
| mathieusab | 1:b1380b9f18c2 | 42 | break; |
| mathieusab | 1:b1380b9f18c2 | 43 | case DeepSleepLong: |
| mathieusab | 12:ec54a73ea7ec | 44 | pc.printf("State DeepSleepLong\n"); |
| mathieusab | 1:b1380b9f18c2 | 45 | //TODO Ajouter appel à standby(...) |
| mathieusab | 1:b1380b9f18c2 | 46 | |
| mathieusab | 1:b1380b9f18c2 | 47 | //TODO Etat suivant = Start |
| mathieusab | 1:b1380b9f18c2 | 48 | break; |
| mathieusab | 1:b1380b9f18c2 | 49 | case MesPHT: |
| mathieusab | 12:ec54a73ea7ec | 50 | pc.printf("State MesPHT\n"); |
| mathieusab | 1:b1380b9f18c2 | 51 | //TODO Ajouter appel à mesPHT(...) |
| mathieusab | 1:b1380b9f18c2 | 52 | |
| mathieusab | 1:b1380b9f18c2 | 53 | //TODO Test poids |
| mathieusab | 1:b1380b9f18c2 | 54 | |
| mathieusab | 1:b1380b9f18c2 | 55 | //TODO SI poids < 5 Kg, Etat suivant = MesGPS |
| mathieusab | 1:b1380b9f18c2 | 56 | //TODO SINON Etat suivant = Send |
| mathieusab | 1:b1380b9f18c2 | 57 | break; |
| mathieusab | 1:b1380b9f18c2 | 58 | case MesGPS: |
| mathieusab | 12:ec54a73ea7ec | 59 | pc.printf("State MesGPS\n"); |
| mathieusab | 1:b1380b9f18c2 | 60 | //TODO Ajouter appel à mesGPS(...) |
| mathieusab | 1:b1380b9f18c2 | 61 | break; |
| mathieusab | 1:b1380b9f18c2 | 62 | case Send: |
| mathieusab | 12:ec54a73ea7ec | 63 | pc.printf("State Send\n"); |
| mathieusab | 1:b1380b9f18c2 | 64 | //TODO Ajouter appel à send(...) |
| mathieusab | 1:b1380b9f18c2 | 65 | |
| mathieusab | 1:b1380b9f18c2 | 66 | //TODO Test jour ou nuit |
| mathieusab | 1:b1380b9f18c2 | 67 | |
| mathieusab | 1:b1380b9f18c2 | 68 | //TODO SI jour, Etat suivant = DeepSleepShort |
| mathieusab | 1:b1380b9f18c2 | 69 | //TODO SI nuit, Etat suivant = DeepSleepLong |
| mathieusab | 1:b1380b9f18c2 | 70 | break; |
| mathieusab | 1:b1380b9f18c2 | 71 | default: |
| mathieusab | 12:ec54a73ea7ec | 72 | pc.printf("State Error\n"); |
| mathieusab | 1:b1380b9f18c2 | 73 | //TODO Etat suivant = Start |
| mathieusab | 1:b1380b9f18c2 | 74 | }//end switch |
| mathieusab | 1:b1380b9f18c2 | 75 | }//end while |
| mathieusab | 1:b1380b9f18c2 | 76 | }//end main |