newest

Dependencies:   BME280 BMP280 TextLCD mbed

Fork of CW_watchdog_08012018_fran by Calvin Kalintra

Committer:
ckalintra
Date:
Tue Jan 09 11:26:15 2018 +0000
Revision:
2:c696dfd53eeb
Parent:
1:dc21a6fce3af
Child:
3:f5fe5071416a
code;

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 2:c696dfd53eeb 11 DigitalOut led(PB_11), led2(PB_10);
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 2:c696dfd53eeb 15
ckalintra 2:c696dfd53eeb 16
ckalintra 0:7023c3f98f36 17 void second_tick()
ckalintra 0:7023c3f98f36 18 {
ckalintra 0:7023c3f98f36 19 ss++;
ckalintra 0:7023c3f98f36 20 time_rule();
ckalintra 0:7023c3f98f36 21 day_check();
ckalintra 0:7023c3f98f36 22 lcd.cls();
ckalintra 0:7023c3f98f36 23 if (dislcd == 1)
ckalintra 0:7023c3f98f36 24 {
ckalintra 0:7023c3f98f36 25 lcd.locate(10,0);
ckalintra 0:7023c3f98f36 26 lcd.printf("l:%1.2f", lvl);
ckalintra 0:7023c3f98f36 27 lcd.locate(0,0);
ckalintra 2:c696dfd53eeb 28 lcd.printf("p:%5.1f", pressuref);
ckalintra 0:7023c3f98f36 29 lcd.locate(10,1);
ckalintra 1:dc21a6fce3af 30 lcd.printf("t:%2.1f", tempf);
ckalintra 2:c696dfd53eeb 31 display_time();
ckalintra 0:7023c3f98f36 32 }
ckalintra 0:7023c3f98f36 33 else if (dislcd == 0)
ckalintra 0:7023c3f98f36 34 {
ckalintra 0:7023c3f98f36 35 display_dates();
ckalintra 0:7023c3f98f36 36 display_time();
ckalintra 0:7023c3f98f36 37 }
ckalintra 2:c696dfd53eeb 38
ckalintra 2:c696dfd53eeb 39 //VIC_SystemReset();
ckalintra 0:7023c3f98f36 40 }
ckalintra 0:7023c3f98f36 41
ckalintra 0:7023c3f98f36 42 void lcddisp()
ckalintra 0:7023c3f98f36 43 {
ckalintra 1:dc21a6fce3af 44 if (gather_data == 1)
ckalintra 1:dc21a6fce3af 45 {
ckalintra 2:c696dfd53eeb 46 led2 = 1;
ckalintra 1:dc21a6fce3af 47 display_time();
ckalintra 1:dc21a6fce3af 48 getdata();
ckalintra 1:dc21a6fce3af 49 store();
ckalintra 2:c696dfd53eeb 50 led2 = 0;
ckalintra 1:dc21a6fce3af 51 }
ckalintra 1:dc21a6fce3af 52 if (gather_data ==0)
ckalintra 1:dc21a6fce3af 53 {
ckalintra 2:c696dfd53eeb 54 led = 1;
ckalintra 2:c696dfd53eeb 55 wait(0.2);
ckalintra 2:c696dfd53eeb 56 led = 0;
ckalintra 1:dc21a6fce3af 57 }
ckalintra 0:7023c3f98f36 58 }
ckalintra 0:7023c3f98f36 59
ckalintra 0:7023c3f98f36 60 void check_display()
ckalintra 0:7023c3f98f36 61 {
ckalintra 0:7023c3f98f36 62 if(dislcd == 0)
ckalintra 0:7023c3f98f36 63 {dislcd = 1;}
ckalintra 0:7023c3f98f36 64 else
ckalintra 0:7023c3f98f36 65 {dislcd = 0;}
ckalintra 0:7023c3f98f36 66 }
ckalintra 0:7023c3f98f36 67
ckalintra 0:7023c3f98f36 68
ckalintra 0:7023c3f98f36 69 int main()
ckalintra 0:7023c3f98f36 70 {
ckalintra 0:7023c3f98f36 71 lcd.cls();
ckalintra 2:c696dfd53eeb 72
ckalintra 0:7023c3f98f36 73 //display_date_time();
ckalintra 0:7023c3f98f36 74 // while (pointer != 14)
ckalintra 0:7023c3f98f36 75 // {
ckalintra 0:7023c3f98f36 76 // select_date();
ckalintra 0:7023c3f98f36 77 // }
ckalintra 0:7023c3f98f36 78 bmp.initialize();
ckalintra 2:c696dfd53eeb 79 pc.printf("\n\rputty ready\n\r");
ckalintra 0:7023c3f98f36 80 display.attach(&lcddisp, T);
ckalintra 0:7023c3f98f36 81 second_pass.attach(&second_tick, 1.0);
ckalintra 0:7023c3f98f36 82 button.rise(&check_display);
ckalintra 0:7023c3f98f36 83 while(1)
ckalintra 0:7023c3f98f36 84 {
ckalintra 2:c696dfd53eeb 85 check_display();
ckalintra 2:c696dfd53eeb 86 putty_write();
ckalintra 2:c696dfd53eeb 87 check_display();
ckalintra 2:c696dfd53eeb 88 if (interrupt == 1)
ckalintra 2:c696dfd53eeb 89 {
ckalintra 2:c696dfd53eeb 90 T = t;
ckalintra 2:c696dfd53eeb 91 display.attach(&lcddisp, T);
ckalintra 2:c696dfd53eeb 92 interrupt = 0;
ckalintra 2:c696dfd53eeb 93 }
ckalintra 0:7023c3f98f36 94 }
ckalintra 0:7023c3f98f36 95 }
ckalintra 0:7023c3f98f36 96
ckalintra 0:7023c3f98f36 97
ckalintra 0:7023c3f98f36 98