Browse Source

led: fixup configuration in the webui

Also fix the rogue typos from the scheduler change
dev
Maxim Prokhorov 3 years ago
parent
commit
b6934d395d
23 changed files with 25225 additions and 25611 deletions
  1. BIN
      code/espurna/data/index.all.html.gz
  2. BIN
      code/espurna/data/index.curtain.html.gz
  3. BIN
      code/espurna/data/index.garland.html.gz
  4. BIN
      code/espurna/data/index.light.html.gz
  5. BIN
      code/espurna/data/index.lightfox.html.gz
  6. BIN
      code/espurna/data/index.rfbridge.html.gz
  7. BIN
      code/espurna/data/index.rfm69.html.gz
  8. BIN
      code/espurna/data/index.sensor.html.gz
  9. BIN
      code/espurna/data/index.small.html.gz
  10. BIN
      code/espurna/data/index.thermostat.html.gz
  11. +17
    -8
      code/espurna/led.cpp
  12. +3012
    -3061
      code/espurna/static/index.all.html.gz.h
  13. +2244
    -2281
      code/espurna/static/index.curtain.html.gz.h
  14. +2195
    -2231
      code/espurna/static/index.garland.html.gz.h
  15. +2764
    -2804
      code/espurna/static/index.light.html.gz.h
  16. +2219
    -2256
      code/espurna/static/index.lightfox.html.gz.h
  17. +2244
    -2280
      code/espurna/static/index.rfbridge.html.gz.h
  18. +3806
    -3847
      code/espurna/static/index.rfm69.html.gz.h
  19. +2279
    -2325
      code/espurna/static/index.sensor.html.gz.h
  20. +2192
    -2228
      code/espurna/static/index.small.html.gz.h
  21. +2228
    -2265
      code/espurna/static/index.thermostat.html.gz.h
  22. +23
    -23
      code/html/custom.js
  23. +2
    -2
      code/html/index.html

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


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


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


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


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


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


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


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


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


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


+ 17
- 8
code/espurna/led.cpp View File

@ -250,18 +250,27 @@ void _ledWebSocketOnVisible(JsonObject& root) {
} }
void _ledWebSocketOnConnected(JsonObject& root) { void _ledWebSocketOnConnected(JsonObject& root) {
if (!ledCount()) return;
JsonObject& module = root.createNestedObject("led");
if (!ledCount()) {
return;
}
JsonObject& config = root.createNestedObject("ledConfig");
JsonArray& schema = module.createNestedArray("schema");
schema.add("GPIO");
schema.add("Inv");
schema.add("Mode");
{
static constexpr const char* const schema_keys[] PROGMEM = {
"ledGpio",
"ledInv",
"ledMode"
#if RELAY_SUPPORT #if RELAY_SUPPORT
schema.add("Relay");
,"ledRelay"
#endif #endif
};
JsonArray& schema = config.createNestedArray("schema");
schema.copyFrom(schema_keys, sizeof(schema_keys) / sizeof(*schema_keys));
}
JsonArray& leds = module.createNestedArray("list");
JsonArray& leds = config.createNestedArray("leds");
for (size_t index = 0; index < ledCount(); ++index) { for (size_t index = 0; index < ledCount(); ++index) {
JsonArray& led = leds.createNestedArray(); JsonArray& led = leds.createNestedArray();


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


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


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


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


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


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


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


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


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


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


+ 23
- 23
code/html/custom.js View File

@ -64,7 +64,7 @@ function followScroll(id, threshold) {
function fromSchema(source, schema) { function fromSchema(source, schema) {
if (schema.length !== source.length) { if (schema.length !== source.length) {
throw "Schema mismatch!";
throw `Schema mismatch! Expected length ${schema.length} vs. ${source.length}`;
} }
var target = {}; var target = {};
@ -1023,6 +1023,20 @@ function addNetwork(network) {
// Relays scheduler // Relays scheduler
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function addLed(id, cfg, payload) {
var line = loadConfigTemplate("ledConfigTemplate");
fillTemplateLineFromCfg(line, id, cfg);
$("span.id", line)
.html(id);
line.appendTo("#ledConfig");
}
// -----------------------------------------------------------------------------
// Relays scheduler
// -----------------------------------------------------------------------------
function numSchedules() { function numSchedules() {
return $("#schedules > div").length; return $("#schedules > div").length;
} }
@ -1862,7 +1876,7 @@ function processData(data) {
let schema = value.schema; let schema = value.schema;
value["schedules"].forEach((entries, id) => { value["schedules"].forEach((entries, id) => {
let cfg = fromSchema(entries, id);
let cfg = fromSchema(entries, schema);
addSchedule(cfg, value); addSchedule(cfg, value);
}); });
@ -1921,28 +1935,14 @@ function processData(data) {
// LEDs // LEDs
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
if ("led" === key) {
if($("#ledConfig > div").length > 0) return;
var schema = value["schema"];
value["list"].forEach(function(led_data, index) {
var line = loadConfigTemplate("ledConfigTemplate");
$("span.id", line).html(index);
$("select", line).attr("data", index);
$("input", line).attr("data", index);
var led = fromSchema(led_data, schema);
$("select[name='ledGPIO']", line).val(led.GPIO);
// XXX: checkbox implementation depends on unique id
// $("input[name='ledInv']", line).val(led.Inv);
$("select[name='ledMode']", line).val(led.Mode);
$("input[name='ledRelay']", line).val(led.Relay);
setOriginalsFromValues($("input,select", line));
if ("ledConfig" === key) {
if ($("#ledConfig > div").length > 0) {
return;
}
line.appendTo("#ledConfig");
let schema = value["schema"];
value["leds"].forEach((entries, id) => {
addLed(id, fromSchema(entries, schema), value);
}); });
return; return;


+ 2
- 2
code/html/index.html View File

@ -1913,7 +1913,7 @@
<legend class="pure-u-1 pure-u-lg-1-4">LED #<span class="id"></span></legend> <legend class="pure-u-1 pure-u-lg-1-4">LED #<span class="id"></span></legend>
<div class="pure-control-group"> <div class="pure-control-group">
<label>GPIO</label> <label>GPIO</label>
<select class="pure-input-2-3 gpio-select" name="ledGPIO" action="reboot"></select>
<select class="pure-input-2-3 gpio-select" name="ledGpio" action="reboot"></select>
</div> </div>
<div class="pure-control-group"> <div class="pure-control-group">
<label>Mode</label> <label>Mode</label>
@ -1930,7 +1930,7 @@
<option value="7">Always OFF</option> <option value="7">Always OFF</option>
</select> </select>
</div> </div>
<div class="pure-control-group">
<div class="module-relay pure-control-group">
<label>Relay ID</label> <label>Relay ID</label>
<input class="pure-input-2-3" name="ledRelay" type="number" min="0" data="0"></input> <input class="pure-input-2-3" name="ledRelay" type="number" min="0" data="0"></input>
</div> </div>


Loading…
Cancel
Save