Line 6... |
Line 6... |
6 |
#include <string.h> |
6 |
#include <string.h> |
7 |
|
7 |
|
8 |
#include "SHT25.h" |
8 |
#include "SHT25.h" |
9 |
#include "MPL3115.h" |
9 |
#include "MPL3115.h" |
10 |
#include "HMC5883L.h" |
10 |
#include "HMC5883L.h" |
- |
|
11 |
#include ".\common\dbloader.h" |
- |
|
12 |
|
11 |
|
13 |
|
12 |
unsigned int16 timer0_overflow_count; |
14 |
unsigned int16 timer0_overflow_count; |
13 |
float anemo=0; |
15 |
float anemo=0; |
14 |
unsigned int8 rain; |
16 |
unsigned int8 rain; |
15 |
|
17 |
|
Line 39... |
Line 41... |
39 |
// if (!input(PIN_B0)) ext_int_edge( L_TO_H ); |
41 |
// if (!input(PIN_B0)) ext_int_edge( L_TO_H ); |
40 |
} |
42 |
} |
41 |
|
43 |
|
42 |
float wind_direction(void) //vypocet azimutu smeru vetru |
44 |
float wind_direction(void) //vypocet azimutu smeru vetru |
43 |
{ |
45 |
{ |
44 |
signed int16 X,Y,Z; |
- |
|
45 |
float b; |
46 |
float b; |
46 |
X = mag_readX(); |
47 |
hmc5883l_read_data(); // reads magnetometer data to global variables |
47 |
delay_ms(10); |
- |
|
48 |
Y = mag_readY(); |
- |
|
49 |
|
48 |
|
50 |
|
- |
|
51 |
b = atan2((float)Y,(float)X); // vypocet azimutu z kartezskych souradnic |
49 |
b = atan2((float)compass.y,(float)compass.x); // vypocet azimutu z kartezskych souradnic |
52 |
b = (b/3.141596)*180; // prevod na stupne |
50 |
b = (b/3.141596)*180; // prevod na stupne |
53 |
b += 180; |
51 |
b += 180; |
54 |
return b; |
52 |
return b; |
55 |
} |
53 |
} |
56 |
|
54 |
|
Line 95... |
Line 93... |
95 |
set_timer1(0); |
93 |
set_timer1(0); |
96 |
timer0_overflow_count=0; |
94 |
timer0_overflow_count=0; |
97 |
rain=0; |
95 |
rain=0; |
98 |
|
96 |
|
99 |
welcome(); |
97 |
welcome(); |
- |
|
98 |
|
100 |
set_mag(); //nastaveni magnetometru pro smer vetru |
99 |
// Init the HMC5883L. Set Mode register for |
- |
|
100 |
// continuous measurements. |
- |
|
101 |
hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range |
- |
|
102 |
hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0xE0); // maximal range |
- |
|
103 |
hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00); |
101 |
|
104 |
|
102 |
//nastaveni SHT25 |
105 |
//nastaveni SHT25 |
103 |
SHT25_soft_reset(); |
106 |
SHT25_soft_reset(); |
104 |
sht_config = SHT25_RH12_T14 | SHT25_HEATER_OFF; //vypnuti topeni v SHT25 |
107 |
sht_config = SHT25_RH12_T14 | SHT25_HEATER_OFF; //vypnuti topeni v SHT25 |
105 |
SHT25_setup(sht_config); |
108 |
SHT25_setup(sht_config); |