![](/media/cache/profiles/ba5be68d3d541f2ca043d77fc54fe702.jpg.50x50_q85.jpg)
3rd Repo, trying to figure this out.
Fork of SOFT253_Template_Weather_OS_54 by
main.cpp@32:260a288be58f, 2017-03-27 (annotated)
- Committer:
- martinsimpson
- Date:
- Mon Mar 27 09:35:05 2017 +0000
- Revision:
- 32:260a288be58f
- Parent:
- 29:0b58d21e87d6
- Child:
- 33:cffe0ae69aa6
OS 5.3 Veriso 2017
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jonathan Austin |
0:2757d7abb7d9 | 1 | #include "mbed.h" |
martinsimpson | 32:260a288be58f | 2 | #include "rtos.h" |
martinsimpson | 32:260a288be58f | 3 | #include "hts221.h" |
martinsimpson | 32:260a288be58f | 4 | #include "LPS25H.h" |
martinsimpson | 32:260a288be58f | 5 | |
martinsimpson | 32:260a288be58f | 6 | |
martinsimpson | 32:260a288be58f | 7 | DigitalOut myled(LED1); |
martinsimpson | 32:260a288be58f | 8 | I2C i2c2(I2C_SDA, I2C_SCL); |
martinsimpson | 32:260a288be58f | 9 | |
martinsimpson | 32:260a288be58f | 10 | float tempCelsius = 25.50; |
martinsimpson | 32:260a288be58f | 11 | float humi = 55; |
martinsimpson | 32:260a288be58f | 12 | int humiMax = 100; |
martinsimpson | 32:260a288be58f | 13 | char cmd=0; |
martinsimpson | 32:260a288be58f | 14 | uint32_t seconds = 0, minutes=0, hours=0; |
martinsimpson | 32:260a288be58f | 15 | |
martinsimpson | 32:260a288be58f | 16 | LPS25H barometer(i2c2, LPS25H_V_CHIP_ADDR); |
martinsimpson | 32:260a288be58f | 17 | |
martinsimpson | 32:260a288be58f | 18 | |
martinsimpson | 32:260a288be58f | 19 | |
martinsimpson | 32:260a288be58f | 20 | int main() |
martinsimpson | 32:260a288be58f | 21 | { |
martinsimpson | 32:260a288be58f | 22 | hts221_init(); |
martinsimpson | 32:260a288be58f | 23 | HTS221_Calib(); |
martinsimpson | 32:260a288be58f | 24 | printf("SOFT253 simple Temperature Humidity and Pressure Sensor Monitor\n\r"); |
martinsimpson | 32:260a288be58f | 25 | printf("Using the X-NUCLEO-IKS01A1 shield and MBED Libraries\n\r"); |
martinsimpson | 32:260a288be58f | 26 | //printf("%#x\n\r",barometer.read_id()); |
martinsimpson | 32:260a288be58f | 27 | |
martinsimpson | 32:260a288be58f | 28 | while(1) |
martinsimpson | 32:260a288be58f | 29 | { |
martinsimpson | 32:260a288be58f | 30 | cmd=NULL; |
martinsimpson | 32:260a288be58f | 31 | while(cmd==NULL){cmd=getchar();} |
martinsimpson | 32:260a288be58f | 32 | if(cmd=='?'){ |
martinsimpson | 32:260a288be58f | 33 | printf("SOFT253 simple Temperature Humidity and Pressure Sensor Monitor\n\r"); |
martinsimpson | 32:260a288be58f | 34 | printf("Using the X-NUCLEO-IKS01A1 shield and MBED Libraries\n\r"); |
martinsimpson | 32:260a288be58f | 35 | } |
martinsimpson | 32:260a288be58f | 36 | if(cmd=='A'){ |
martinsimpson | 32:260a288be58f | 37 | HTS221_ReadTempHumi(&tempCelsius, &humi); |
martinsimpson | 32:260a288be58f | 38 | printf("%4.2fC %3.1f%%", tempCelsius, humi); |
martinsimpson | 32:260a288be58f | 39 | barometer.get(); |
martinsimpson | 32:260a288be58f | 40 | printf(" %6.1f %4.1f\r\n", barometer.pressure(), barometer.temperature()); |
martinsimpson | 32:260a288be58f | 41 | myled = 1; // LED is ON |
martinsimpson | 32:260a288be58f | 42 | Thread::wait(200); // 200 ms NB 'Thread::wait(int d);' !!! d is in milliseconds! |
martinsimpson | 32:260a288be58f | 43 | myled = 0; // LED is OFF |
martinsimpson | 32:260a288be58f | 44 | Thread::wait(100); // 100 ms |
martinsimpson | 32:260a288be58f | 45 | } |
martinsimpson | 32:260a288be58f | 46 | } |
martinsimpson | 32:260a288be58f | 47 | } |
martinsimpson | 32:260a288be58f | 48 | |
martinsimpson | 32:260a288be58f | 49 | |
martinsimpson | 32:260a288be58f | 50 | |
martinsimpson | 32:260a288be58f | 51 | /*#include "mbed.h" |
Jonathan Austin |
0:2757d7abb7d9 | 52 | |
Jonathan Austin |
0:2757d7abb7d9 | 53 | DigitalOut led1(LED1); |
Jonathan Austin |
0:2757d7abb7d9 | 54 | |
Jonathan Austin |
1:846c97078558 | 55 | // main() runs in its own thread in the OS |
Jonathan Austin |
0:2757d7abb7d9 | 56 | int main() { |
Jonathan Austin |
0:2757d7abb7d9 | 57 | while (true) { |
Jonathan Austin |
0:2757d7abb7d9 | 58 | led1 = !led1; |
mbed_official | 22:af9dcf379926 | 59 | wait(0.5); |
Jonathan Austin |
0:2757d7abb7d9 | 60 | } |
Jonathan Austin |
0:2757d7abb7d9 | 61 | } |
martinsimpson | 32:260a288be58f | 62 | */ |