newest

Dependencies:   BME280 BMP280 TextLCD mbed

Fork of CW_watchdog_08012018_fran by Calvin Kalintra

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