EmonGLCD Template based display's
I have been thinking about how it could be possible to program an EmonGLCD display remotely or at least specify which displays are shown i.e if you could construct a command to tell the display to:
display solar pv page as page 1, use the solar power value from node 10.
Skipping for now the how the commands are sent and interpreted, I think the first part of creating these specifiable displays is to convert the current display code into template functions which should be of benefit whether the displays are remotely programmed or not.
Here's my first attempt at this:
draw_temperature_time_footer(temp, mintemp, maxtemp, hour,minute);
draws the following page:
draw_solar_page(use, usekwh, gen, 2050, genkwh, temp, mintemp, maxtemp, hour,minute);
draws:
(thanks to drsdre for the icons!)
This is what the full code looks like:
#include <JeeLib.h>
#include <GLCD_ST7565.h>
#include <avr/pgmspace.h>
GLCD_ST7565 glcd;
unsigned long fast_update;
// Fixed values for this example
double temp = 17.4 ,maxtemp = 19 ,mintemp = 16;
int hour = 23, minute = 43;
double use = 252, usekwh = 2.5;
double gen = 1760, genkwh = 4.8;
void setup()
{
glcd.begin(0x20);
glcd.backLight(200);
}
void loop()
{
//-----------------------------------------------------------------------------
// Display update every 200ms
//-----------------------------------------------------------------------------
if ((millis()-fast_update)>200)
{
fast_update = millis();
int S1 = digitalRead(15);
int S2 = digitalRead(16);
int S3 = digitalRead(19);
if (S1==1)
{
// powerstr, power, energystr, kwh
draw_power_page( "POWER" ,use, "USE", usekwh);
// temp, mintemp, maxtemp, hour, minute
draw_temperature_time_footer(temp, mintemp, maxtemp, hour,minute);
glcd.refresh();
}
else if (S2==1)
{
// powerstr, power, energystr, kwh
draw_power_page( "SOLAR" ,gen, "GEN", genkwh);
// temp, mintemp, maxtemp, hour, minute
draw_temperature_time_footer(temp, mintemp, maxtemp, hour,minute);
glcd.refresh();
}
else
{
// use, usekwh, gen, maxgen, genkwh, temp, mintemp, maxtemp, hour, minute
draw_solar_page(use, usekwh, gen, 2050, genkwh, temp, mintemp, maxtemp, 12,43);
glcd.refresh();
}
}
}
To run this you will need the accompanying icons and templates files, its all available in the EmonGLCD repo here: https://github.com/openenergymonitor/EmonGLCD/tree/master/emonGLCD_Template_Dev
Interested to hear any thoughts on how best to take this forward.