-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
64 lines (49 loc) · 1.4 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "mbed.h"
//#include "rtos.h"
#include "hts221.h"
#include "LPS25H.h"
DigitalOut myled(LED1);
I2C i2c2(I2C_SDA, I2C_SCL);
float tempCelsius = 25.50;
float humi = 55;
int humiMax = 100;
char cmd=0;
uint32_t seconds = 0, minutes=0, hours=0;
LPS25H barometer(i2c2, LPS25H_V_CHIP_ADDR);
int main()
{
hts221_init();
HTS221_Calib();
printf("SOFT253 simple Temperature Humidity and Pressure Sensor Monitor\n\r");
printf("Using the X-NUCLEO-IKS01A1 shield and MBED Libraries\n\r");
//printf("%#x\n\r",barometer.read_id());
while(1)
{
cmd=NULL;
while(cmd==NULL){cmd=getchar();}
if(cmd=='?'){
printf("SOFT253 simple Temperature Humidity and Pressure Sensor Monitor\n\r");
printf("Using the X-NUCLEO-IKS01A1 shield and MBED Libraries\n\r");
}
if(cmd=='A'){
HTS221_ReadTempHumi(&tempCelsius, &humi);
printf("%4.2fC %3.1f%%", tempCelsius, humi);
barometer.get();
printf(" %6.1f %4.1f\r\n", barometer.pressure(), barometer.temperature());
myled = 1; // LED is ON
Thread::wait(200); // 200 ms NB 'Thread::wait(int d);' !!! d is in milliseconds!
myled = 0; // LED is OFF
Thread::wait(100); // 100 ms
}
}
}
/*#include "mbed.h"
DigitalOut led1(LED1);
// main() runs in its own thread in the OS
int main() {
while (true) {
led1 = !led1;
wait(0.5);
}
}
*/