Line 33... |
Line 33... |
33 |
|
33 |
|
34 |
#INT_EXT |
34 |
#INT_EXT |
35 |
void EXT_isr() //interrup from rain sensor clip. |
35 |
void EXT_isr() //interrup from rain sensor clip. |
36 |
{ |
36 |
{ |
37 |
rain++; |
37 |
rain++; |
38 |
if (input(PIN_B0)) ext_int_edge( H_TO_L ); |
38 |
// if (input(PIN_B0)) ext_int_edge( H_TO_L ); osetreni pro pripad, ze by bylo treba cist obe hrany impulzu |
39 |
if (!input(PIN_B0)) ext_int_edge( L_TO_H ); |
39 |
// if (!input(PIN_B0)) ext_int_edge( L_TO_H ); |
40 |
} |
40 |
} |
41 |
|
41 |
|
42 |
float wind_direction(void) //vypocet azimutu smeru vetru |
42 |
float wind_direction(void) //vypocet azimutu smeru vetru |
43 |
{ |
43 |
{ |
44 |
signed int16 X,Y,Z; |
44 |
signed int16 X,Y,Z; |
45 |
float b; |
45 |
float b; |
46 |
X = mag_readX(); |
46 |
X = mag_readX(); |
- |
|
47 |
delay_ms(10); |
47 |
Y = mag_readY(); |
48 |
Y = mag_readY(); |
48 |
|
49 |
|
49 |
|
50 |
|
50 |
b = atan2((float)Y,(float)X); // vypocet azimutu z kartezskych souradnic |
51 |
b = atan2((float)Y,(float)X); // vypocet azimutu z kartezskych souradnic |
51 |
b = (b/3.141596)*180; // prevod na stupne |
52 |
b = (b/3.141596)*180; // prevod na stupne |
Line 82... |
Line 83... |
82 |
float sht25_h; //relativni vlhkost z SHT25 |
83 |
float sht25_h; //relativni vlhkost z SHT25 |
83 |
float smer_v; //smer vetru |
84 |
float smer_v; //smer vetru |
84 |
|
85 |
|
85 |
unsigned int8 sht_config; |
86 |
unsigned int8 sht_config; |
86 |
|
87 |
|
87 |
//nastaveni SHT25 |
- |
|
88 |
SHT25_soft_reset(); |
- |
|
89 |
sht_config = SHT25_RH12_T14 | SHT25_HEATER_OFF; //vypnuti topeni v SHT25 |
- |
|
90 |
SHT25_setup(sht_config); |
- |
|
91 |
|
- |
|
92 |
//nastavení pøeruení pro anemometr |
88 |
//nastavení pøeruení pro anemometr |
93 |
enable_interrupts(INT_TIMER1); |
89 |
enable_interrupts(INT_TIMER1); |
94 |
enable_interrupts(INT_TIMER0); |
90 |
enable_interrupts(INT_TIMER0); |
95 |
enable_interrupts(INT_EXT); |
91 |
enable_interrupts(INT_EXT); |
96 |
enable_interrupts(GLOBAL); |
92 |
enable_interrupts(GLOBAL); |
Line 98... |
Line 94... |
98 |
set_timer0(0); |
94 |
set_timer0(0); |
99 |
set_timer1(0); |
95 |
set_timer1(0); |
100 |
timer0_overflow_count=0; |
96 |
timer0_overflow_count=0; |
101 |
rain=0; |
97 |
rain=0; |
102 |
|
98 |
|
103 |
|
- |
|
104 |
welcome(); |
99 |
welcome(); |
105 |
set_mag(); //nastaveni magnetometru pro smer vetru |
100 |
set_mag(); //nastaveni magnetometru pro smer vetru |
106 |
|
101 |
|
- |
|
102 |
//nastaveni SHT25 |
- |
|
103 |
SHT25_soft_reset(); |
- |
|
104 |
sht_config = SHT25_RH12_T14 | SHT25_HEATER_OFF; //vypnuti topeni v SHT25 |
- |
|
105 |
SHT25_setup(sht_config); |
- |
|
106 |
|
- |
|
107 |
|
107 |
while(TRUE) |
108 |
while(TRUE) |
108 |
{ |
109 |
{ |
109 |
unsigned int32 i=0; |
110 |
unsigned int32 i=0; |
110 |
|
111 |
|
111 |
mpl3115_setP(); //nastaveni pro tlak a teplotu |
112 |
mpl3115_setP(); //nastaveni pro tlak a teplotu |