newest

Dependencies:   BME280 BMP280 TextLCD mbed

Fork of CW_watchdog_08012018_newest by Calvin Kalintra

Revision:
5:8aa72ee456fc
Parent:
4:5dbb5145d0a9
--- a/main.cpp	Tue Jan 09 12:11:46 2018 +0000
+++ b/main.cpp	Tue Jan 09 15:45:56 2018 +0000
@@ -1,15 +1,16 @@
 #include "mbed.h"
 #include "TextLCD.h"
 #include "BME280.h"
-#include "putty.h"
+#include "sd.h"
 #define watchdog_time 15
 //DigitalOut myled(LED1);
 int dislcd = 0, wdcounter = 0, watchdog = 0;
 float T = 15;
+char ch = 0;
 Ticker display;
 Ticker second_pass;
 InterruptIn button(USER_BUTTON);
-DigitalOut led(PB_11), led2(PB_10);
+
 //NVIC_SetPriority(display, 0);     
 //NVIC_SetPriority(second_pass, 1);
 //NVIC_SetPriority(button, 1);
@@ -31,8 +32,8 @@
         lcd.printf("l:%1.2f", lvl);
         lcd.locate(0,0);
         lcd.printf("p:%5.1f", pressuref);
-        lcd.locate(8,1);
-        lcd.printf("t:%4.1f", tempf);
+        lcd.locate(10,1);
+        lcd.printf("t:%3.1f", tempf);
         display_time(); 
     }
     else if (dislcd == 0)
@@ -42,26 +43,32 @@
     }
    if (wdcounter >= watchdog_time)
    {
+       pc.printf("system stuck, reset\n\r");
        NVIC_SystemReset();
    }
 }
-
+void watchdog()
+{
+    wdcounter = 0;
+    watchdog = 1;
+}
 void lcddisp()
 { 
+    
     if (gather_data == 1)
     {
-        led2 = 1;
+        redLED = 1;
         display_time();
         getdata();
         store();
-        led2 = 0;
+        redLED = 0;
     }
     if (gather_data ==0)
     {
-        led = 1;
+        redLED = 1;
         wait(0.2);
-        led = 0;
     }
+    
 }
 
 void check_display()
@@ -90,7 +97,24 @@
     while(1)
     {
         check_display();
-        putty_write();
+        if (putty_enabled == 1)
+        {
+            //watchdog();
+            putty_write();
+            watchdog = 0;
+        }
+        
+        if (putty_enabled == 0)
+        {
+            while(ch != 'p')
+            {
+                ch = 0;
+                yellowLED = 1;
+                ch = pc.getc();
+            }
+            putty_enabled = 1;
+        }
+        yellowLED = 0;
         check_display();
         if (interrupt == 1)
         {
@@ -98,6 +122,10 @@
             display.attach(&lcddisp, T);
             interrupt = 0;
         }
+        //if(sw1 == 1 && sw2 == 1)
+//        {
+//            sd();
+//        }
     }
 }