Browse Source

Added current time, uptime, free heap, firmware size and free space to web interface

fastled
Xose Pérez 7 years ago
parent
commit
e451fb499b
7 changed files with 3613 additions and 3533 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +39
    -1
      code/espurna/espurna.ino
  3. +1
    -1
      code/espurna/ntp.ino
  4. +3517
    -3509
      code/espurna/static/index.html.gz.h
  5. +6
    -2
      code/espurna/web.ino
  6. +15
    -0
      code/html/custom.js
  7. +35
    -20
      code/html/index.html

BIN
code/espurna/data/index.html.gz View File


+ 39
- 1
code/espurna/espurna.ino View File

@ -32,7 +32,37 @@ String getIdentifier() {
return String(buffer);
}
void heartbeat() {
String buildTime() {
const char time_now[] = __TIME__; // hh:mm:ss
unsigned int hour = atoi(&time_now[0]);
unsigned int minute = atoi(&time_now[3]);
unsigned int second = atoi(&time_now[6]);
const char date_now[] = __DATE__; // Mmm dd yyyy
const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
unsigned int month = 0;
for ( int i = 0; i < 12; i++ ) {
if (strncmp(date_now, months[i], 3) == 0 ) {
month = i + 1;
break;
}
}
unsigned int day = atoi(&date_now[3]);
unsigned int year = atoi(&date_now[7]);
char buffer[20];
snprintf_P(
buffer, sizeof(buffer), PSTR("%04d/%02d/%02d %02d:%02d:%02d"),
year, month, day, hour, minute, second
);
return String(buffer);
}
unsigned long getUptime() {
static unsigned long last_uptime = 0;
static unsigned char uptime_overflows = 0;
@ -40,6 +70,14 @@ void heartbeat() {
if (millis() < last_uptime) ++uptime_overflows;
last_uptime = millis();
unsigned long uptime_seconds = uptime_overflows * (UPTIME_OVERFLOW / 1000) + (last_uptime / 1000);
return uptime_seconds;
}
void heartbeat() {
unsigned long uptime_seconds = getUptime();
unsigned int free_heap = ESP.getFreeHeap();
DEBUG_MSG_P(PSTR("[MAIN] Time: %s\n"), (char *) ntpDateTime().c_str());


+ 1
- 1
code/espurna/ntp.ino View File

@ -39,7 +39,7 @@ String ntpDateTime() {
int month = value.substring(12, 14).toInt();
int year = value.substring(15, 19).toInt();
char buffer[20];
snprintf_P(buffer, sizeof(buffer), PSTR("%04d/%02d/%02dT%02d:%02d:%02d"), year, month, day, hour, minute, second);
snprintf_P(buffer, sizeof(buffer), PSTR("%04d/%02d/%02d %02d:%02d:%02d"), year, month, day, hour, minute, second);
return String(buffer);
}


+ 3517
- 3509
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 6
- 2
code/espurna/web.ino View File

@ -409,8 +409,7 @@ void _wsStart(uint32_t client_id) {
root["app"] = APP_NAME;
root["version"] = APP_VERSION;
root["buildDate"] = __DATE__;
root["buildTime"] = __TIME__;
root["build"] = buildTime();
root["manufacturer"] = String(MANUFACTURER);
root["chipid"] = chipid;
@ -419,6 +418,11 @@ void _wsStart(uint32_t client_id) {
root["hostname"] = getSetting("hostname");
root["network"] = getNetwork();
root["deviceip"] = getIP();
root["time"] = ntpDateTime();
root["uptime"] = getUptime();
root["heap"] = ESP.getFreeHeap();
root["sketch_size"] = ESP.getSketchSize();
root["free_size"] = ESP.getFreeSketchSpace();
root["ntpStatus"] = ntpConnected();
root["ntpServer1"] = getSetting("ntpServer1", NTP_SERVER);


+ 15
- 0
code/html/custom.js View File

@ -533,6 +533,21 @@ function processData(data) {
return;
}
if (key == "uptime") {
var uptime = parseInt(data[key]);
var seconds = uptime % 60; uptime = parseInt(uptime / 60);
var minutes = uptime % 60; uptime = parseInt(uptime / 60);
var hours = uptime % 24; uptime = parseInt(uptime / 24);
var days = uptime;
data[key] = days + 'd ' + hours + 'h ' + minutes + 'm ' + seconds + 's';
}
if (key == "time") data[key] = data[key].replace('T', ' ');
if (key == "heap") data[key] = data[key] + ' bytes';
if (key == "sketch_size") data[key] = data[key] + ' bytes';
if (key == "free_size") data[key] = data[key] + ' bytes';
if (key == "useWhite") {
useWhite = data[key];
}


+ 35
- 20
code/html/index.html View File

@ -227,35 +227,50 @@
<div class="pure-u-1 state">
<div class="pure-u-1 pure-u-sm-11-24">Manufacturer</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="manufacturer"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">Manufacturer</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="manufacturer"></span></div>
<div class="pure-u-1 pure-u-sm-11-24">Device</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="device"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">Device</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="device"></span></div>
<div class="pure-u-1 pure-u-sm-11-24">Chip ID</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="chipid"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">Chip ID</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="chipid"></span></div>
<div class="pure-u-1 pure-u-sm-11-24">MAC</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="mac"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">MAC</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="mac"></span></div>
<div class="pure-u-1 pure-u-sm-11-24">Network</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="network"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">Network</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="network"></span></div>
<div class="pure-u-1 pure-u-sm-11-24">IP</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="deviceip"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">IP</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="deviceip"></span></div>
<div class="pure-u-1 pure-u-sm-11-24">ESPurna Version</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="version"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">ESPurna version</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="version"></span></div>
<div class="pure-u-1 pure-u-sm-11-24">ESPurna Build</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="buildDate"></span> <span class="right" name="buildTime"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">ESPurna build</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="build"></span></div>
<div class="pure-u-1 pure-u-sm-11-24">MQTT Status</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="mqttStatus"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">Current time</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="time"></span></div>
<div class="pure-u-1 pure-u-sm-11-24">NTP Status</div>
<div class="pure-u-1 pure-u-sm-11-24"><span class="right" name="ntpStatus"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">Uptime</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="uptime"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">Free heap</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="heap"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">Firmware size</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="sketch_size"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">Free space</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="free_size"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">MQTT Status</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="mqttStatus"></span></div>
<div class="pure-u-1 pure-u-sm-1-4">NTP Status</div>
<div class="pure-u-1 pure-u-sm-17-24"><span class="right" name="ntpStatus"></span></div>
</div>


Loading…
Cancel
Save