Log

Dependents:   oldheating gps motorhome heating

Revision:
7:417a6a65e942
Parent:
6:b98aa0ec75a1
Child:
8:e793e9005f89
--- a/log.cpp	Thu Jun 29 19:41:08 2017 +0000
+++ b/log.cpp	Mon Jul 03 14:27:15 2017 +0000
@@ -1,5 +1,5 @@
 #include "mbed.h"
-#include "time.h"
+#include "clock.h"
 
 #define BUFFER_LENGTH 4096
 static char buffer[BUFFER_LENGTH];
@@ -7,7 +7,8 @@
 static char* pPull; //Initialised in init
 static int enable = true;
 
-Serial LogUart(USBTX, USBRX);
+static Serial uart(USBTX, USBRX);
+bool LogUart = false;
 
 static char* incrementPushPullPointer(char* p, char* buffer, int bufferLength)
 {
@@ -25,7 +26,7 @@
     *pPush = c;
     pPush = incrementPushPullPointer(pPush, buffer, BUFFER_LENGTH);
     
-    if (LogUart) LogUart.putc(c);
+    if (LogUart) uart.putc(c);
 }
 void LogPush(char c)
 {
@@ -75,7 +76,7 @@
 }
 int LogInit()
 {
-    LogUart.baud(115200);
+    uart.baud(115200);
     pPush = buffer;
     pPull = buffer;
     return 0;
@@ -143,7 +144,7 @@
 void LogTime()
 {
     struct tm tm;
-    TimeToTmUtc(time(NULL), &tm);
+    ClockTmUtc(&tm);
     
     pushuint4(tm.tm_year + 1900);
     LogPush('-');
@@ -169,13 +170,3 @@
     LogV(fmt, argptr);
     va_end(argptr);
 }
-void LogSave(FILE *fp)
-{
-    LogEnumerateStart();
-    while(1)
-    {
-        int c = LogEnumerate();
-        if (c == EOF) break;
-        putc(c, fp);
-    }
-}