kjdas
Dependencies: BME280 BMP280 TextLCD mbed
Fork of CW_sd_0801 by
main.cpp@0:7023c3f98f36, 2018-01-06 (annotated)
- Committer:
- ckalintra
- Date:
- Sat Jan 06 17:28:05 2018 +0000
- Revision:
- 0:7023c3f98f36
- Child:
- 1:dc21a6fce3af
code;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ckalintra | 0:7023c3f98f36 | 1 | #include "mbed.h" |
ckalintra | 0:7023c3f98f36 | 2 | #include "TextLCD.h" |
ckalintra | 0:7023c3f98f36 | 3 | #include "BMP280.h" |
ckalintra | 0:7023c3f98f36 | 4 | #include "putty.h" |
ckalintra | 0:7023c3f98f36 | 5 | //DigitalOut myled(LED1); |
ckalintra | 0:7023c3f98f36 | 6 | int dislcd = 0; |
ckalintra | 0:7023c3f98f36 | 7 | float T = 15; |
ckalintra | 0:7023c3f98f36 | 8 | Ticker display; |
ckalintra | 0:7023c3f98f36 | 9 | Ticker second_pass; |
ckalintra | 0:7023c3f98f36 | 10 | InterruptIn button(USER_BUTTON); |
ckalintra | 0:7023c3f98f36 | 11 | |
ckalintra | 0:7023c3f98f36 | 12 | //NVIC_SetPriority(display, 0); |
ckalintra | 0:7023c3f98f36 | 13 | //NVIC_SetPriority(second_pass, 1); |
ckalintra | 0:7023c3f98f36 | 14 | //NVIC_SetPriority(button, 1); |
ckalintra | 0:7023c3f98f36 | 15 | void second_tick() |
ckalintra | 0:7023c3f98f36 | 16 | { |
ckalintra | 0:7023c3f98f36 | 17 | ss++; |
ckalintra | 0:7023c3f98f36 | 18 | time_rule(); |
ckalintra | 0:7023c3f98f36 | 19 | day_check(); |
ckalintra | 0:7023c3f98f36 | 20 | lcd.cls(); |
ckalintra | 0:7023c3f98f36 | 21 | if (dislcd == 1) |
ckalintra | 0:7023c3f98f36 | 22 | { |
ckalintra | 0:7023c3f98f36 | 23 | lcd.locate(10,0); |
ckalintra | 0:7023c3f98f36 | 24 | lcd.printf("l:%1.2f", lvl); |
ckalintra | 0:7023c3f98f36 | 25 | lcd.locate(0,0); |
ckalintra | 0:7023c3f98f36 | 26 | lcd.printf("p:%3.1f", pressuref); |
ckalintra | 0:7023c3f98f36 | 27 | lcd.locate(10,1); |
ckalintra | 0:7023c3f98f36 | 28 | lcd.printf("t:%3.1f", tempf); |
ckalintra | 0:7023c3f98f36 | 29 | display_time(); |
ckalintra | 0:7023c3f98f36 | 30 | } |
ckalintra | 0:7023c3f98f36 | 31 | |
ckalintra | 0:7023c3f98f36 | 32 | else if (dislcd == 0) |
ckalintra | 0:7023c3f98f36 | 33 | { |
ckalintra | 0:7023c3f98f36 | 34 | display_dates(); |
ckalintra | 0:7023c3f98f36 | 35 | display_time(); |
ckalintra | 0:7023c3f98f36 | 36 | } |
ckalintra | 0:7023c3f98f36 | 37 | } |
ckalintra | 0:7023c3f98f36 | 38 | |
ckalintra | 0:7023c3f98f36 | 39 | void lcddisp() |
ckalintra | 0:7023c3f98f36 | 40 | { |
ckalintra | 0:7023c3f98f36 | 41 | display_time(); |
ckalintra | 0:7023c3f98f36 | 42 | getdata(); |
ckalintra | 0:7023c3f98f36 | 43 | store(); |
ckalintra | 0:7023c3f98f36 | 44 | } |
ckalintra | 0:7023c3f98f36 | 45 | |
ckalintra | 0:7023c3f98f36 | 46 | void check_display() |
ckalintra | 0:7023c3f98f36 | 47 | { |
ckalintra | 0:7023c3f98f36 | 48 | if(dislcd == 0) |
ckalintra | 0:7023c3f98f36 | 49 | {dislcd = 1;} |
ckalintra | 0:7023c3f98f36 | 50 | else |
ckalintra | 0:7023c3f98f36 | 51 | {dislcd = 0;} |
ckalintra | 0:7023c3f98f36 | 52 | } |
ckalintra | 0:7023c3f98f36 | 53 | |
ckalintra | 0:7023c3f98f36 | 54 | |
ckalintra | 0:7023c3f98f36 | 55 | int main() |
ckalintra | 0:7023c3f98f36 | 56 | { |
ckalintra | 0:7023c3f98f36 | 57 | lcd.cls(); |
ckalintra | 0:7023c3f98f36 | 58 | //display_date_time(); |
ckalintra | 0:7023c3f98f36 | 59 | // while (pointer != 14) |
ckalintra | 0:7023c3f98f36 | 60 | // { |
ckalintra | 0:7023c3f98f36 | 61 | // select_date(); |
ckalintra | 0:7023c3f98f36 | 62 | // } |
ckalintra | 0:7023c3f98f36 | 63 | bmp.initialize(); |
ckalintra | 0:7023c3f98f36 | 64 | pc.printf("putty ready\n\r"); |
ckalintra | 0:7023c3f98f36 | 65 | display.attach(&lcddisp, T); |
ckalintra | 0:7023c3f98f36 | 66 | second_pass.attach(&second_tick, 1.0); |
ckalintra | 0:7023c3f98f36 | 67 | button.rise(&check_display); |
ckalintra | 0:7023c3f98f36 | 68 | |
ckalintra | 0:7023c3f98f36 | 69 | |
ckalintra | 0:7023c3f98f36 | 70 | while(1) |
ckalintra | 0:7023c3f98f36 | 71 | { |
ckalintra | 0:7023c3f98f36 | 72 | check_display(); |
ckalintra | 0:7023c3f98f36 | 73 | putty_write(); |
ckalintra | 0:7023c3f98f36 | 74 | if (interrupt == 1); |
ckalintra | 0:7023c3f98f36 | 75 | { |
ckalintra | 0:7023c3f98f36 | 76 | T = t; |
ckalintra | 0:7023c3f98f36 | 77 | display.attach(&lcddisp, T); |
ckalintra | 0:7023c3f98f36 | 78 | interrupt =0; |
ckalintra | 0:7023c3f98f36 | 79 | } |
ckalintra | 0:7023c3f98f36 | 80 | check_display(); |
ckalintra | 0:7023c3f98f36 | 81 | } |
ckalintra | 0:7023c3f98f36 | 82 | } |
ckalintra | 0:7023c3f98f36 | 83 | |
ckalintra | 0:7023c3f98f36 | 84 | |
ckalintra | 0:7023c3f98f36 | 85 |