ccc
Dependencies: HYT TextLCD mbed
Fork of HYT_example by
main.cpp@1:97c7fc5d4127, 2018-08-28 (annotated)
- Committer:
- jw17594
- Date:
- Tue Aug 28 03:26:13 2018 +0000
- Revision:
- 1:97c7fc5d4127
- Parent:
- 0:cd8ba9e5f346
???
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ksenia | 0:cd8ba9e5f346 | 1 | #include "mbed.h" |
Ksenia | 0:cd8ba9e5f346 | 2 | #include "HYT.h" |
jw17594 | 1:97c7fc5d4127 | 3 | #include "TextLCD.h" |
jw17594 | 1:97c7fc5d4127 | 4 | TextLCD lcd(p15, p16, p17, p18, p19, p20); |
Ksenia | 0:cd8ba9e5f346 | 5 | Serial pc(USBTX, USBRX); |
Ksenia | 0:cd8ba9e5f346 | 6 | Ticker timeKeeping; |
jw17594 | 1:97c7fc5d4127 | 7 | HYT SENSOR (p9, p10); // sda, scl |
Ksenia | 0:cd8ba9e5f346 | 8 | // HYT sensor polling cycle |
Ksenia | 0:cd8ba9e5f346 | 9 | void dataUpdate(void) |
Ksenia | 0:cd8ba9e5f346 | 10 | { |
Ksenia | 0:cd8ba9e5f346 | 11 | SENSOR.MRCommand(); |
Ksenia | 0:cd8ba9e5f346 | 12 | wait_ms(100); |
Ksenia | 0:cd8ba9e5f346 | 13 | SENSOR.DFCommand(); |
Ksenia | 0:cd8ba9e5f346 | 14 | } |
Ksenia | 0:cd8ba9e5f346 | 15 | |
Ksenia | 0:cd8ba9e5f346 | 16 | void secondsCallback(void) { |
Ksenia | 0:cd8ba9e5f346 | 17 | pc.printf("Humidity level: %.1f\r\n%", SENSOR.humidity); |
Ksenia | 0:cd8ba9e5f346 | 18 | pc.printf("Temperature level: %.1f\r\n%", SENSOR.temperature); |
Ksenia | 0:cd8ba9e5f346 | 19 | pc.printf("-------------------------------\r\n%", SENSOR.temperature); |
jw17594 | 1:97c7fc5d4127 | 20 | lcd.locate(1,0); |
jw17594 | 1:97c7fc5d4127 | 21 | lcd.printf("Humidity level: %.1f\r\n%", SENSOR.humidity); |
Ksenia | 0:cd8ba9e5f346 | 22 | } |
Ksenia | 0:cd8ba9e5f346 | 23 | int main() |
Ksenia | 0:cd8ba9e5f346 | 24 | { |
Ksenia | 0:cd8ba9e5f346 | 25 | timeKeeping.attach(&secondsCallback, 1.0f); |
Ksenia | 0:cd8ba9e5f346 | 26 | while(1) { |
Ksenia | 0:cd8ba9e5f346 | 27 | dataUpdate(); |
Ksenia | 0:cd8ba9e5f346 | 28 | } |
Ksenia | 0:cd8ba9e5f346 | 29 | } |