1 | #include "SmartcontrolOS.h"
|
2 | #include "Apps.h"
|
3 | #include "CMSIS.h"
|
4 | void Temperature_Humidity(ui32 dt){
|
5 |
|
6 | static bool ini_OK = false;
|
7 |
|
8 |
|
9 | LCD__write(_,"%2.0f",wf(dd));
|
10 |
|
11 | if(!ini_OK) Scheduler__wait(_,3*sec); // start signal block
|
12 | DO__write_open_drain(_,PA4,1);
|
13 | DO__write_open_drain(_,PA4,0);
|
14 | Scheduler__wait(_,10*ms);
|
15 | DO__write_open_drain(_,PA4,1);
|
16 | Scheduler__wait(_,40*us);
|
17 | DI__read(_,PA4);
|
18 |
|
19 |
|
20 |
|
21 | Scheduler__wait(_,40*us); //check sensor reply block
|
22 |
|
23 | if(DI__read(_,PA4) == 0) Scheduler__wait(_,90*us);
|
24 |
|
25 |
|
26 | while(DI__read(_,PA4) == 0);
|
27 |
|
28 |
|
29 | ui8 sum = 0;
|
30 | ui8 temp1 = 0, temp2 = 0;
|
31 | ui8 feucht1 = 0, feucht2 = 0;
|
32 | int i;
|
33 |
|
34 |
|
35 | for(i = 39; i >= 0; i = i - 1) //read data block
|
36 | {
|
37 |
|
38 | while(DI__read(_,PA4) != 1);
|
39 |
|
40 | Scheduler__wait(_,40*us);
|
41 |
|
42 | if(DI__read(_,PA4) == 1)
|
43 | {
|
44 | if (i >= 32) feucht1 |= 1 << (i - 32);
|
45 | else if(i >= 24) feucht2 |= 1 << (i - 24);
|
46 | else if(i >= 16) temp1 |= 1 << (i - 16);
|
47 | else if(i >= 8) temp2 |= 1 << (i-8);
|
48 | else sum |= 1 << i;
|
49 | }
|
50 |
|
51 | while(DI__read(_,PA4) == 0);
|
52 |
|
53 | }
|
54 |
|
55 |
|
56 |
|
57 | ui16 Temperature = 0, RH = 0;
|
58 |
|
59 | RH = (feucht1 << 8) | feucht2;
|
60 |
|
61 | Temperature = (temp1 << 8) | temp2;
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | LCD__write(_,"%8.1f\n%8.1f %5.0f",wf(RH/10.0f),wf(Temperature/10.0f),wf(sum));
|
67 |
|
68 |
|
69 |
|
70 | Scheduler__wait(_,3*sec);
|
71 | ini_OK = true;
|
72 | }
|
73 |
|
74 |
|
75 | void CPE_App__Wetterstation_T_RH(){
|
76 |
|
77 | Resources__ExBoard_init(_,"");
|
78 |
|
79 | while(1){
|
80 | const ui32 dt = 1*ms;
|
81 | Scheduler__wait(_,dt);
|
82 |
|
83 |
|
84 |
|
85 | Temperature_Humidity(dt);
|
86 |
|
87 |
|
88 | }
|
89 |
|
90 | }
|