newest

Dependencies:   BME280 BMP280 TextLCD mbed

Fork of CW_watchdog_08012018_fran by Calvin Kalintra

Committer:
ckalintra
Date:
Mon Jan 08 18:46:57 2018 +0000
Revision:
1:dc21a6fce3af
Parent:
0:7023c3f98f36
Child:
2:c696dfd53eeb
fran;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ckalintra 0:7023c3f98f36 1 #include "mbed.h"
ckalintra 0:7023c3f98f36 2 #include "TextLCD.h"
ckalintra 1:dc21a6fce3af 3 #include "BME280.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 1:dc21a6fce3af 28 lcd.printf("t:%2.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 1:dc21a6fce3af 41 if (gather_data == 1)
ckalintra 1:dc21a6fce3af 42 {
ckalintra 1:dc21a6fce3af 43 display_time();
ckalintra 1:dc21a6fce3af 44 getdata();
ckalintra 1:dc21a6fce3af 45 store();
ckalintra 1:dc21a6fce3af 46
ckalintra 1:dc21a6fce3af 47 }
ckalintra 1:dc21a6fce3af 48 if (gather_data ==0)
ckalintra 1:dc21a6fce3af 49 {
ckalintra 1:dc21a6fce3af 50
ckalintra 1:dc21a6fce3af 51 }
ckalintra 0:7023c3f98f36 52 }
ckalintra 0:7023c3f98f36 53
ckalintra 0:7023c3f98f36 54 void check_display()
ckalintra 0:7023c3f98f36 55 {
ckalintra 0:7023c3f98f36 56 if(dislcd == 0)
ckalintra 0:7023c3f98f36 57 {dislcd = 1;}
ckalintra 0:7023c3f98f36 58 else
ckalintra 0:7023c3f98f36 59 {dislcd = 0;}
ckalintra 0:7023c3f98f36 60 }
ckalintra 0:7023c3f98f36 61
ckalintra 0:7023c3f98f36 62
ckalintra 0:7023c3f98f36 63 int main()
ckalintra 0:7023c3f98f36 64 {
ckalintra 0:7023c3f98f36 65 lcd.cls();
ckalintra 0:7023c3f98f36 66 //display_date_time();
ckalintra 0:7023c3f98f36 67 // while (pointer != 14)
ckalintra 0:7023c3f98f36 68 // {
ckalintra 0:7023c3f98f36 69 // select_date();
ckalintra 0:7023c3f98f36 70 // }
ckalintra 0:7023c3f98f36 71 bmp.initialize();
ckalintra 0:7023c3f98f36 72 pc.printf("putty ready\n\r");
ckalintra 0:7023c3f98f36 73 display.attach(&lcddisp, T);
ckalintra 0:7023c3f98f36 74 second_pass.attach(&second_tick, 1.0);
ckalintra 0:7023c3f98f36 75 button.rise(&check_display);
ckalintra 0:7023c3f98f36 76
ckalintra 0:7023c3f98f36 77
ckalintra 0:7023c3f98f36 78 while(1)
ckalintra 0:7023c3f98f36 79 {
ckalintra 0:7023c3f98f36 80 check_display();
ckalintra 0:7023c3f98f36 81 putty_write();
ckalintra 1:dc21a6fce3af 82 check_display();
ckalintra 1:dc21a6fce3af 83 if (interrupt == 1)
ckalintra 0:7023c3f98f36 84 {
ckalintra 0:7023c3f98f36 85 T = t;
ckalintra 0:7023c3f98f36 86 display.attach(&lcddisp, T);
ckalintra 1:dc21a6fce3af 87 interrupt = 0;
ckalintra 0:7023c3f98f36 88 }
ckalintra 0:7023c3f98f36 89 }
ckalintra 0:7023c3f98f36 90 }
ckalintra 0:7023c3f98f36 91
ckalintra 0:7023c3f98f36 92
ckalintra 0:7023c3f98f36 93