2 Day emonGLCD with BST/GMT dates and time

Hi - I have finished testing the latest verion of my two day emonGLCD sketch - zip files attached

The new version gets the date and time from a revised emonBase (sketch attached). 

emonGLCD updates included from the latest version of emonGLCD.  I had a lot of problems getting a stable version as I seemed to keep running out of some resource and the sketch crashing.  As a consequence I have made quite a lot of code changes to reduce the size of the sketch.
The main differences from the standard emonGLCD are:

  • Two days of summary KWh are shown (yesterdays data above is a whole day of horrible English weather)
  • Two tarrifs for Import - Economy 7 and a main daily tarrif (start and end times are configurable in setup data)
  • The Date (bottom right) and Time (top left) are correct for normal and daylight saving (GMt/BST in the UK)
  • The display update and smoothing factor can easily be changed

 

emonBase Changes

The structure of the emonbase data type structure now includes the year, month & day fields

typedef struct { int year, month, day, hour, mins, secs;} PayloadBase;
PayloadBase emonbase;

A new function booConvNetDate is called that checks the datetime structure and populates emonbase values.  If an error in the nework date/time string is found it returns False so that the emonbase data is not sent.

  if ( booConvNetDate(line_buf) ){
        // Date and Time from net is OK - send to emonGLCD
        // Send time data
      int i = 0; while (!rf12_canSend() && i<10) {rf12_recvDone(); i++;}    // if can send - exit if it gets stuck, as it seems too
      rf12_sendStart(0, &emonbase, sizeof emonbase);                        // send payload
      rf12_sendWait(0);

   
      Serial.println("time sent to emonGLCD");
  }

  Feel free to download and amend the code.

Ian