Skip to content

Commit

Permalink
Reorder modules for proper UI display
Browse files Browse the repository at this point in the history
main: reorder modules for proper UI display

UserModArtNet and DDP bugfix: move initUI from constructor to setup
  • Loading branch information
ewowi committed Aug 13, 2023
1 parent 7813c0b commit 5863f99
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/Sys/SysModModules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void SysModModules::setup() {
module->setup();
}

//do its own setup
//do its own setup: will be shown as last module
parentVar = ui->initModule(parentVar, name);

JsonObject tableVar = ui->initTable(parentVar, "mdlTbl", nullptr, false, [](JsonObject var) { //uiFun
Expand Down Expand Up @@ -57,7 +57,7 @@ void SysModModules::setup() {
uint8_t rowNr = 0;

//if value not array, create array
if (!var["value"].is<JsonArray>())
if (!var["value"].is<JsonArray>()) //comment if forced to recreate enabled array
var.createNestedArray("value");

//if value array not same size as nr of modules
Expand Down
16 changes: 8 additions & 8 deletions src/User/UserModArtNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class UserModArtNet:public Module {

isEnabled = false; //default off

print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed");
};

//setup filesystem
void setup() {
Module::setup();
print->print("%s %s\n", __PRETTY_FUNCTION__, name);

parentVar = ui->initModule(parentVar, name);

ui->initSelect(parentVar, "artInst", -1, false, [](JsonObject var) { //uiFun
Expand All @@ -45,14 +53,6 @@ class UserModArtNet:public Module {
}
}); //ddpInst

print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed");
};

//setup filesystem
void setup() {
Module::setup();
print->print("%s %s\n", __PRETTY_FUNCTION__, name);

print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed");
}

Expand Down
15 changes: 8 additions & 7 deletions src/User/UserModDDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ class UserModDDP:public Module {

isEnabled = false; //default off

print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed");
};

//setup filesystem
void setup() {
Module::setup();
print->print("%s %s\n", __PRETTY_FUNCTION__, name);

parentVar = ui->initModule(parentVar, name);

ui->initSelect(parentVar, "ddpInst", -1, false, [](JsonObject var) { //uiFun
Expand All @@ -61,13 +69,6 @@ class UserModDDP:public Module {
}
}); //ddpInst

print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed");
};

//setup filesystem
void setup() {
Module::setup();
print->print("%s %s\n", __PRETTY_FUNCTION__, name);
print->print("%s %s %s\n", __PRETTY_FUNCTION__, name, success?"success":"failed");
}

Expand Down
2 changes: 1 addition & 1 deletion src/User/UserModE131.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UserModE131:public Module {

VarToWatch varsToWatch[maxChannels]; //up to 513

UserModE131() :Module("e131-sACN support") {
UserModE131() :Module("e131-sACN") {
print->print("%s %s\n", __PRETTY_FUNCTION__, name);

isEnabled = false; //defailt off
Expand Down
2 changes: 1 addition & 1 deletion src/User/UserModInstances.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class UserModInstances:public Module {
if (node->ip == remoteIp) {
found = true;
node->timeStamp = millis(); //update timestamp
// strcpy(node->details, nodeName); //update name (in case changed)
strcpy(node->details, nodeName); //update name (in case changed)
}
}

Expand Down
22 changes: 12 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,36 @@ void setup() {
hamod = new UserModHA();
#endif

//prefered default order in the UI
//prefered default order in the UI.
//Reorder with care! If changed make sure mdlEnabled.chFun executes var.createNestedArray("value"); and saveModel!
//Default: add below, not in between
#ifdef APPMOD_LEDS
mdls->add(lds);
mdls->add(lfg);
#endif
mdls->add(files);
mdls->add(instances);
mdls->add(sys);
mdls->add(pins);
mdls->add(print);
mdls->add(web);
mdls->add(net);
#ifdef APPMOD_LEDS
mdls->add(lfg);
#ifdef USERMOD_ARTNET
mdls->add(artnetmod);
#endif
#ifdef USERMOD_DDP
mdls->add(ddpmod);
#endif
#ifdef USERMOD_ARTNET
mdls->add(artnetmod);
#endif
#endif
mdls->add(ui);
mdls->add(web);
mdls->add(net);
mdls->add(mdl);
#ifdef USERMOD_E131
mdls->add(e131mod);
#endif
#ifdef USERMOD_HA
mdls->add(hamod);
#endif
mdls->add(instances);
mdls->add(mdl);
mdls->add(ui);

//do not add mdls itself as it does setup and loop for itself!!! (it is the orchestrator)
mdls->setup();
Expand Down

0 comments on commit 5863f99

Please sign in to comment.