Permet de lire et de stocker dans des variables publiques la direction pointées par la girouette WS1080.
Dependents: test_girouette_library
GirouetteWD1080.cpp@0:493f86ea1ecb, 2019-05-20 (annotated)
- Committer:
- Station_Meteo_Laos
- Date:
- Mon May 20 08:14:27 2019 +0000
- Revision:
- 0:493f86ea1ecb
- Child:
- 1:4c8b15e19600
Permet de lire et de stocker dans une variable publique la direction pointe 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 | 0:493f86ea1ecb | 9 | // GirouetteWD1080 |
Station_Meteo_Laos | 0:493f86ea1ecb | 10 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 11 | bool GirouetteWD1080::read( ) |
Station_Meteo_Laos | 0:493f86ea1ecb | 12 | { |
Station_Meteo_Laos | 0:493f86ea1ecb | 13 | uint16_t positions[8] = {770, 200, 53, 30, 13, 105, 350, 550}, girou, i=0; |
Station_Meteo_Laos | 0:493f86ea1ecb | 14 | string directions[9]={"O","S-O","S","S-E","E","N-E","N","N-O", "ERR"}; |
Station_Meteo_Laos | 0:493f86ea1ecb | 15 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 16 | girou = int(girouette.read()*1000.0f); |
Station_Meteo_Laos | 0:493f86ea1ecb | 17 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 18 | for(i=0; i<9;i++){ |
Station_Meteo_Laos | 0:493f86ea1ecb | 19 | if( (positions[i]-10)<=girou && (positions[i]+10)>=girou){ |
Station_Meteo_Laos | 0:493f86ea1ecb | 20 | direction = directions[i]; |
Station_Meteo_Laos | 0:493f86ea1ecb | 21 | return true; |
Station_Meteo_Laos | 0:493f86ea1ecb | 22 | } |
Station_Meteo_Laos | 0:493f86ea1ecb | 23 | } |
Station_Meteo_Laos | 0:493f86ea1ecb | 24 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 25 | direction = directions[8]; |
Station_Meteo_Laos | 0:493f86ea1ecb | 26 | return false; |
Station_Meteo_Laos | 0:493f86ea1ecb | 27 | } |
Station_Meteo_Laos | 0:493f86ea1ecb | 28 | |
Station_Meteo_Laos | 0:493f86ea1ecb | 29 |