Permet de lire et de stocker dans des variables publiques la direction pointées par la girouette WS1080.
Dependents: test_girouette_library
GirouetteWD1080.cpp@1:4c8b15e19600, 2019-05-20 (annotated)
- Committer:
- Station_Meteo_Laos
- Date:
- Mon May 20 08:24:08 2019 +0000
- Revision:
- 1:4c8b15e19600
- Parent:
- 0:493f86ea1ecb
- Child:
- 2:6d392919b388
Permet de lire la girouette WD1080 et de stocker dans une variable publique (de type string) la direction pointee par la girouette.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Station_Meteo_Laos | 0:493f86ea1ecb | 1 | #include "GirouetteWD1080.h" |
Station_Meteo_Laos | 0:493f86ea1ecb | 2 | #include "mbed.h" |
Station_Meteo_Laos | 0:493f86ea1ecb | 3 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 4 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 5 | GirouetteWD1080::GirouetteWD1080(PinName analog_pin):girouette(analog_pin) |
Station_Meteo_Laos | 0:493f86ea1ecb | 6 | { |
Station_Meteo_Laos | 0:493f86ea1ecb | 7 | } |
Station_Meteo_Laos | 0:493f86ea1ecb | 8 | |
Station_Meteo_Laos | 1:4c8b15e19600 | 9 | // Lit les différentes valeurs donné par la GirouetteWD1080 |
Station_Meteo_Laos | 1:4c8b15e19600 | 10 | //En déduit la direction inidquée par la girouette |
Station_Meteo_Laos | 1:4c8b15e19600 | 11 | |
Station_Meteo_Laos | 1:4c8b15e19600 | 12 | // /!\ Les pôles de réfèrence sont sculptés sur le pied de la girouette /!\ |
Station_Meteo_Laos | 0:493f86ea1ecb | 13 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 14 | bool GirouetteWD1080::read( ) |
Station_Meteo_Laos | 0:493f86ea1ecb | 15 | { |
Station_Meteo_Laos | 0:493f86ea1ecb | 16 | uint16_t positions[8] = {770, 200, 53, 30, 13, 105, 350, 550}, girou, i=0; |
Station_Meteo_Laos | 0:493f86ea1ecb | 17 | string directions[9]={"O","S-O","S","S-E","E","N-E","N","N-O", "ERR"}; |
Station_Meteo_Laos | 0:493f86ea1ecb | 18 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 19 | girou = int(girouette.read()*1000.0f); |
Station_Meteo_Laos | 0:493f86ea1ecb | 20 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 21 | for(i=0; i<9;i++){ |
Station_Meteo_Laos | 0:493f86ea1ecb | 22 | if( (positions[i]-10)<=girou && (positions[i]+10)>=girou){ |
Station_Meteo_Laos | 0:493f86ea1ecb | 23 | direction = directions[i]; |
Station_Meteo_Laos | 0:493f86ea1ecb | 24 | return true; |
Station_Meteo_Laos | 0:493f86ea1ecb | 25 | } |
Station_Meteo_Laos | 0:493f86ea1ecb | 26 | } |
Station_Meteo_Laos | 0:493f86ea1ecb | 27 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 28 | direction = directions[8]; |
Station_Meteo_Laos | 0:493f86ea1ecb | 29 | return false; |
Station_Meteo_Laos | 0:493f86ea1ecb | 30 | } |
Station_Meteo_Laos | 0:493f86ea1ecb | 31 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 32 |