test de premier push
Dependencies: WakeUp mbed EPD_GDE021A1
Sources/main.cpp@27:221ee2a91664, 2016-11-25 (annotated)
- Committer:
- mathieusab
- Date:
- Fri Nov 25 06:56:49 2016 +0000
- Revision:
- 27:221ee2a91664
- Parent:
- 24:b1c29d839d9b
Appel depuis le main de la fonction send(); Faut verifier si la commande est bonne dans le send.cpp
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" |
mathieusab | 1:b1380b9f18c2 | 9 | #include "../Headers/period.h" |
mathieusab | 1:b1380b9f18c2 | 10 | #include "../Headers/states.h" |
mathieusab | 1:b1380b9f18c2 | 11 | #include "../Headers/constants.h" |
nba | 16:dc4a1be5abdb | 12 | #include "../Headers/ecran.h" |
nba | 16:dc4a1be5abdb | 13 | #include "../Headers/poids.h" |
mathieusab | 27:221ee2a91664 | 14 | #include "../Headers/send.h" |
nba | 17:3f52db5f8b42 | 15 | #include "../Headers/refreshScreen.h" |
mathieusab | 24:b1c29d839d9b | 16 | #include "../Headers/standby.h" |
nba | 13:0afb541c480e | 17 | |
mathieusab | 1:b1380b9f18c2 | 18 | |
mathieusab | 1:b1380b9f18c2 | 19 | Serial pc(USBTX, USBRX); // serie USB (ne pas oublier de souder sur la carte) |
nba | 13:0afb541c480e | 20 | InterruptIn bouton(PA_0); // bouton bleu en interuption |
mathieusab | 1:b1380b9f18c2 | 21 | |
mathieusab | 1:b1380b9f18c2 | 22 | State state = Start; // état de base : start |
nba | 18:ec86c13524ad | 23 | int poidsRuche; |
mathieusab | 1:b1380b9f18c2 | 24 | |
mathieusab | 27:221ee2a91664 | 25 | int poids = 17; |
mathieusab | 27:221ee2a91664 | 26 | int temp = 21; |
mathieusab | 27:221ee2a91664 | 27 | int hum = 92; |
mathieusab | 27:221ee2a91664 | 28 | |
mathieusab | 1:b1380b9f18c2 | 29 | int main () |
mathieusab | 1:b1380b9f18c2 | 30 | { |
nba | 16:dc4a1be5abdb | 31 | //Ecran::print; |
nba | 17:3f52db5f8b42 | 32 | refreshScreen(); |
nba | 18:ec86c13524ad | 33 | poidsRuche = Poids::get(); |
mathieusab | 1:b1380b9f18c2 | 34 | while(true) |
mathieusab | 1:b1380b9f18c2 | 35 | { |
nba | 17:3f52db5f8b42 | 36 | bouton.rise(&refreshScreen); |
mathieusab | 1:b1380b9f18c2 | 37 | switch(state) |
mathieusab | 1:b1380b9f18c2 | 38 | { |
mathieusab | 1:b1380b9f18c2 | 39 | case Start: |
mathieusab | 12:ec54a73ea7ec | 40 | pc.printf("State Start\n"); |
mathieusab | 1:b1380b9f18c2 | 41 | //TODO Test jour ou nuit |
mathieusab | 1:b1380b9f18c2 | 42 | |
mathieusab | 1:b1380b9f18c2 | 43 | //TODO SI jour, Etat suivant = DeepSleepShort |
mathieusab | 1:b1380b9f18c2 | 44 | //TODO SI nuit, Etat suivant = DeepSleepLong |
mathieusab | 27:221ee2a91664 | 45 | state = Send; |
mathieusab | 1:b1380b9f18c2 | 46 | break; |
mathieusab | 1:b1380b9f18c2 | 47 | case DeepSleepShort: |
mathieusab | 12:ec54a73ea7ec | 48 | pc.printf("State DeepSleepShort\n"); |
mathieusab | 24:b1c29d839d9b | 49 | standby(DEEPSLEEP_SHORT_DURATION); |
mathieusab | 24:b1c29d839d9b | 50 | state = Start; |
mathieusab | 1:b1380b9f18c2 | 51 | break; |
mathieusab | 1:b1380b9f18c2 | 52 | case DeepSleepLong: |
mathieusab | 12:ec54a73ea7ec | 53 | pc.printf("State DeepSleepLong\n"); |
mathieusab | 24:b1c29d839d9b | 54 | standby(DEEPSLEEP_LONG_DURATION); |
mathieusab | 24:b1c29d839d9b | 55 | state = Start; |
mathieusab | 1:b1380b9f18c2 | 56 | break; |
mathieusab | 1:b1380b9f18c2 | 57 | case MesPHT: |
mathieusab | 12:ec54a73ea7ec | 58 | pc.printf("State MesPHT\n"); |
mathieusab | 1:b1380b9f18c2 | 59 | //TODO Ajouter appel à mesPHT(...) |
mathieusab | 1:b1380b9f18c2 | 60 | |
mathieusab | 1:b1380b9f18c2 | 61 | //TODO Test poids |
mathieusab | 1:b1380b9f18c2 | 62 | |
mathieusab | 1:b1380b9f18c2 | 63 | //TODO SI poids < 5 Kg, Etat suivant = MesGPS |
mathieusab | 1:b1380b9f18c2 | 64 | //TODO SINON Etat suivant = Send |
mathieusab | 1:b1380b9f18c2 | 65 | break; |
mathieusab | 1:b1380b9f18c2 | 66 | case MesGPS: |
mathieusab | 12:ec54a73ea7ec | 67 | pc.printf("State MesGPS\n"); |
mathieusab | 1:b1380b9f18c2 | 68 | //TODO Ajouter appel à mesGPS(...) |
mathieusab | 1:b1380b9f18c2 | 69 | break; |
mathieusab | 1:b1380b9f18c2 | 70 | case Send: |
mathieusab | 12:ec54a73ea7ec | 71 | pc.printf("State Send\n"); |
mathieusab | 1:b1380b9f18c2 | 72 | //TODO Ajouter appel à send(...) |
mathieusab | 27:221ee2a91664 | 73 | send(poids,temp,hum); |
mathieusab | 1:b1380b9f18c2 | 74 | //TODO Test jour ou nuit |
mathieusab | 1:b1380b9f18c2 | 75 | |
mathieusab | 1:b1380b9f18c2 | 76 | //TODO SI jour, Etat suivant = DeepSleepShort |
mathieusab | 1:b1380b9f18c2 | 77 | //TODO SI nuit, Etat suivant = DeepSleepLong |
mathieusab | 27:221ee2a91664 | 78 | state = Start; |
mathieusab | 1:b1380b9f18c2 | 79 | break; |
mathieusab | 1:b1380b9f18c2 | 80 | default: |
mathieusab | 12:ec54a73ea7ec | 81 | pc.printf("State Error\n"); |
mathieusab | 24:b1c29d839d9b | 82 | state = Start; |
mathieusab | 1:b1380b9f18c2 | 83 | }//end switch |
mathieusab | 1:b1380b9f18c2 | 84 | }//end while |
mathieusab | 1:b1380b9f18c2 | 85 | }//end main |