Line 1... |
Line 1... |
1 |
#include "main.h" |
1 |
#include "main.h" |
2 |
#include "HMC5883L.h" |
2 |
#include "HMC5883L.h" |
- |
|
3 |
#include <math.h> |
3 |
|
4 |
|
4 |
void main() |
5 |
void main() |
5 |
{ |
6 |
{ |
6 |
int1 last; |
7 |
float last,b,anemo_speed; |
7 |
unsigned int16 anemo_round=0; |
8 |
unsigned int16 anemo_round=0; |
8 |
unsigned int16 i; |
9 |
unsigned int16 i; |
9 |
|
10 |
|
10 |
|
11 |
|
11 |
//signed int16 X,Y,Z; |
12 |
//signed int16 X,Y,Z; |
Line 44... |
Line 45... |
44 |
*/ |
45 |
*/ |
45 |
|
46 |
|
46 |
while(TRUE) |
47 |
while(TRUE) |
47 |
{ |
48 |
{ |
48 |
|
49 |
|
49 |
for( i=0;i<=1000;i++) |
50 |
// for(i=0;i<=10;i++) |
50 |
{ |
51 |
// { |
51 |
// delay_ms(); |
- |
|
52 |
hmc5883l_read_data(); |
52 |
hmc5883l_read_data(); |
- |
|
53 |
|
- |
|
54 |
// b = atan2((float)compass.y,(float)compass.x); // vypocet azimutu z kartezskych souradnic |
- |
|
55 |
// b = (b/3.141596)*180; // prevod na stupne |
- |
|
56 |
// b += 180; |
53 |
|
57 |
|
54 |
if(compass.x < 0) |
58 |
// anemo_speed += (b-last); |
55 |
{ |
59 |
// last=b; |
56 |
if(last == 1) anemo_round++; |
- |
|
57 |
last=0; |
60 |
// delay_ms(10); |
58 |
} |
61 |
// } |
59 |
if(compass.x > 0) last=1; |
62 |
// anemo_speed=anemo_speed/10; |
60 |
} |
- |
|
61 |
|
63 |
|
62 |
printf("%6Ld %6Ld %6Ld %6Ld \n\r", compass.x, compass.y, compass.z, anemo_round); |
64 |
printf("%6Ld %6Ld %6Ld \n\r", compass.x, compass.y, compass.z); |
63 |
anemo_round=0; |
65 |
// delay_ms(100); |
64 |
} |
66 |
} |
65 |
|
67 |
|
66 |
} |
68 |
} |
67 |
|
69 |
|
68 |
|
70 |
|