Skip to content

Commit

Permalink
add setLabel and setComment and setOptions, used in UIFun
Browse files Browse the repository at this point in the history
SysModUI
- add setLabel and setComment and setOptions, used in UIFun
  • Loading branch information
ewowi committed Feb 14, 2024
1 parent a47dc70 commit 86900d3
Show file tree
Hide file tree
Showing 18 changed files with 230 additions and 224 deletions.
36 changes: 18 additions & 18 deletions src/App/AppEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ class Effect {
//currentVar["value"][parentRowNr] will be set to value parameter
JsonObject currentVar = ui->initSelect(parentVar, "pal", value, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun: {
web->addResponse(var["id"], "label", "Palette");
web->addResponse(var["id"], "comment", "Colors");
JsonArray select = web->addResponseA(var["id"], "options");
select.add("CloudColors");
select.add("LavaColors");
select.add("OceanColors");
select.add("ForestColors");
select.add("RainbowColors");
select.add("RainbowStripeColors");
select.add("PartyColors");
select.add("HeatColors");
ui->setLabel(var, "Palette");
ui->setComment(var, "Colors");
JsonArray options = ui->setOptions(var);
options.add("CloudColors");
options.add("LavaColors");
options.add("OceanColors");
options.add("ForestColors");
options.add("RainbowColors");
options.add("RainbowStripeColors");
options.add("PartyColors");
options.add("HeatColors");
return true;
}
default: return false;
Expand Down Expand Up @@ -197,7 +197,7 @@ class RunningEffect: public Effect {
void controls(JsonObject parentVar, Leds &leds) {
ui->initSlider(parentVar, "BPM", 60, 0, 255, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "comment", "in BPM!");
ui->setComment(var, "in BPM!");
return true;
default: return false;
}});
Expand Down Expand Up @@ -705,12 +705,12 @@ class ScrollingText2D: public Effect {
ui->initSlider(parentVar, "Speed", 128);
ui->initSelect(parentVar, "font", 0, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun: {
JsonArray select = web->addResponseA(var["id"], "options");
select.add("4x6");
select.add("5x8");
select.add("5x12");
select.add("6x8");
select.add("7x9");
JsonArray options = ui->setOptions(var);
options.add("4x6");
options.add("5x8");
options.add("5x12");
options.add("6x8");
options.add("7x9");
return true;
}
default: return false;
Expand Down
31 changes: 13 additions & 18 deletions src/App/AppModFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ class AppModFixture:public SysModule {

JsonObject currentVar = ui->initCheckBox(parentVar, "on", true, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "label", "On/Off");
ui->setLabel(var, "On/Off");
return true;
default: return false;
}});
currentVar["stage"] = true;

//logarithmic slider (10)
currentVar = ui->initSlider(parentVar, "bri", 10, 0, 255, false , [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun

case f_UIFun:
web->addResponse(var["id"], "label", "Brightness");
ui->setLabel(var, "Brightness");
return true;

case f_ChangeFun: {
uint8_t bri = var["value"];

Expand All @@ -53,9 +51,9 @@ class AppModFixture:public SysModule {

ui->initCanvas(parentVar, "pview", UINT16_MAX, false, [this](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "label", "Preview");
web->addResponse(var["id"], "comment", "Shows the fixture");
// web->addResponse(var["id"], "comment", "Click to enlarge");
ui->setLabel(var, "Preview");
ui->setComment(var, "Shows the fixture");
// ui->setComment(var, "Click to enlarge");
return true;
case f_LoopFun: {
var["interval"] = max(lds->fixture.nrOfLeds * web->ws->count()/200, 16U)*10; //interval in ms * 10, not too fast //from cs to ms
Expand Down Expand Up @@ -85,12 +83,11 @@ class AppModFixture:public SysModule {
}});

ui->initSelect(parentVar, "fixture", lds->fixture.fixtureNr, false ,[](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun

case f_UIFun:
{
web->addResponse(var["id"], "comment", "Fixture to display effect on");
JsonArray select = web->addResponseA(var["id"], "options");
files->dirToJson(select, true, "D"); //only files containing D (1D,2D,3D), alphabetically, only looking for D not very destinctive though
ui->setComment(var, "Fixture to display effect on");
JsonArray options = ui->setOptions(var);
files->dirToJson(options, true, "D"); //only files containing D (1D,2D,3D), alphabetically, only looking for D not very destinctive though

// ui needs to load the file also initially
char fileName[32] = "";
Expand All @@ -99,7 +96,6 @@ class AppModFixture:public SysModule {
}
return true;
}

case f_ChangeFun:
{
lds->fixture.fixtureNr = var["value"];
Expand All @@ -112,7 +108,6 @@ class AppModFixture:public SysModule {
}
return true;
}

default: return false;
}}); //fixture

Expand All @@ -121,7 +116,7 @@ class AppModFixture:public SysModule {
mdl->setValue(var, lds->fixture.size);
return true;
case f_UIFun:
web->addResponse(var["id"], "label", "Size");
ui->setLabel(var, "Size");
return true;
default: return false;
}});
Expand All @@ -131,15 +126,15 @@ class AppModFixture:public SysModule {
mdl->setValue(var, lds->fixture.nrOfLeds);
return true;
case f_UIFun:
web->addResponse(var["id"], "label", "Count");
ui->setLabel(var, "Count");
web->addResponseV(var["id"], "comment", "Max %d", NUM_LEDS_Max);
return true;
default: return false;
}});

ui->initNumber(parentVar, "fps", lds->fps, 1, 999, false , [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "comment", "Frames per second");
ui->setComment(var, "Frames per second");
return true;
case f_ChangeFun:
lds->fps = var["value"];
Expand All @@ -157,8 +152,8 @@ class AppModFixture:public SysModule {
#ifdef STARMOD_USERMOD_WLEDAUDIO
ui->initCheckBox(parentVar, "mHead", false, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "label", "Moving heads");
web->addResponse(var["id"], "comment", "Move on GEQ");
ui->setLabel(var, "Moving heads");
ui->setComment(var, "Move on GEQ");
return true;
case f_ChangeFun:
if (!var["value"])
Expand Down
50 changes: 25 additions & 25 deletions src/App/AppModFixtureGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,22 +538,22 @@ class AppModFixtureGen:public SysModule {
ui->initSelect(parentVar, "fixtureGen", 0, false, [this](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun

case f_UIFun: {
web->addResponse(var["id"], "label", "Fixture");
web->addResponse(var["id"], "comment", "Type of fixture");
JsonArray select = web->addResponseA(var["id"], "options");
select.add("1DSpiral"); //0
select.add("2DMatrix"); //1
select.add("2DRing"); //2
select.add("2DRings241"); //3
select.add("2DCloud"); //4
select.add("2DWall"); //5
select.add("2DWheel"); //6
select.add("2DHexagon"); //7
select.add("3DCone"); //8
select.add("3DSideCube"); //9
select.add("3DCube"); //10
select.add("3DGlobe WIP"); //11
select.add("3DGeodesicDome WIP"); //12
ui->setLabel(var, "Fixture");
ui->setComment(var, "Type of fixture");
JsonArray options = ui->setOptions(var);
options.add("1DSpiral"); //0
options.add("2DMatrix"); //1
options.add("2DRing"); //2
options.add("2DRings241"); //3
options.add("2DCloud"); //4
options.add("2DWall"); //5
options.add("2DWheel"); //6
options.add("2DHexagon"); //7
options.add("3DCone"); //8
options.add("3DSideCube"); //9
options.add("3DCube"); //10
options.add("3DGlobe WIP"); //11
options.add("3DGeodesicDome WIP"); //12
return true;
}
case f_ChangeFun:
Expand All @@ -567,7 +567,7 @@ class AppModFixtureGen:public SysModule {

ui->initText(parentVar, "pinList", "16", 32, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "comment", "One or more e.g. 12,13,14");
ui->setComment(var, "One or more e.g. 12,13,14");
return true;
default: return false;
}});
Expand Down Expand Up @@ -638,21 +638,21 @@ class AppModFixtureGen:public SysModule {

ui->initSelect(parentVar, "firstLedX", 0, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun: {
web->addResponse(var["id"], "comment", "WIP");
JsonArray select = web->addResponseA(var["id"], "options");
select.add("Left"); //0
select.add("Right"); //1
ui->setComment(var, "WIP");
JsonArray options = ui->setOptions(var);
options.add("Left"); //0
options.add("Right"); //1
return true;
}
default: return false;
}});

ui->initSelect(parentVar, "firstLedY", 0, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun: {
web->addResponse(var["id"], "comment", "WIP");
JsonArray select = web->addResponseA(var["id"], "options");
select.add("Top"); //0
select.add("Bottom"); //1
ui->setComment(var, "WIP");
JsonArray options = ui->setOptions(var);
options.add("Top"); //0
options.add("Bottom"); //1
return true;
}
default: return false;
Expand Down
55 changes: 28 additions & 27 deletions src/App/AppModLeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class AppModLeds:public SysModule {

JsonObject tableVar = ui->initTable(parentVar, "fxTbl", nullptr, false, [this](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "label", "Effects");
web->addResponse(var["id"], "comment", "List of effects");
ui->setLabel(var, "Effects");
ui->setComment(var, "List of effects");
return true;
case f_AddRow: {
rowNr = fixture.ledsList.size();
Expand Down Expand Up @@ -111,11 +111,11 @@ class AppModLeds:public SysModule {
mdl->setValue(var, fixture.ledsList[rowNr].fx, rowNr);
return true;
case f_UIFun: {
web->addResponse(var["id"], "label", "Effect");
web->addResponse(var["id"], "comment", "Effect to show");
JsonArray select = web->addResponseA(var["id"], "options");
ui->setLabel(var, "Effect");
ui->setComment(var, "Effect to show");
JsonArray options = ui->setOptions(var);
for (Effect *effect:effects.effects) {
select.add(effect->name());
options.add(effect->name());
}
return true;
}
Expand All @@ -138,18 +138,18 @@ class AppModLeds:public SysModule {
mdl->setValue(var, fixture.ledsList[rowNr].projectionNr, rowNr);
return true;
case f_UIFun: {
web->addResponse(var["id"], "label", "Projection");
web->addResponse(var["id"], "comment", "How to project fx");
JsonArray select = web->addResponseA(var["id"], "options");
select.add("None"); // 0
select.add("Random"); // 1
select.add("Distance from point"); //2
select.add("Distance from center"); //3
select.add("Mirror"); //4
select.add("Reverse"); //5
select.add("Multiply"); //6
select.add("Kaleidoscope"); //7
select.add("Fun"); //8
ui->setLabel(var, "Projection");
ui->setComment(var, "How to project fx");
JsonArray options = ui->setOptions(var);
options.add("None"); // 0
options.add("Random"); // 1
options.add("Distance from point"); //2
options.add("Distance from center"); //3
options.add("Mirror"); //4
options.add("Reverse"); //5
options.add("Multiply"); //6
options.add("Kaleidoscope"); //7
options.add("Fun"); //8
return true;
}
case f_ChangeFun:
Expand All @@ -171,7 +171,7 @@ class AppModLeds:public SysModule {
mdl->setValue(var, fixture.ledsList[rowNr].startPos, rowNr);
return true;
case f_UIFun:
web->addResponse(var["id"], "label", "Start");
ui->setLabel(var, "Start");
return true;
case f_ChangeFun:
if (rowNr < fixture.ledsList.size()) {
Expand All @@ -197,7 +197,7 @@ class AppModLeds:public SysModule {
USER_PRINTF("fxEnd[%d] valueFun %d,%d,%d\n", rowNr, fixture.ledsList[rowNr].endPos.x, fixture.ledsList[rowNr].endPos.y, fixture.ledsList[rowNr].endPos.z);
return true;
case f_UIFun:
web->addResponse(var["id"], "label", "End");
ui->setLabel(var, "End");
return true;
case f_ChangeFun:
if (rowNr < fixture.ledsList.size()) {
Expand Down Expand Up @@ -226,19 +226,20 @@ class AppModLeds:public SysModule {
}
return true;
case f_UIFun:
web->addResponse(var["id"], "label", "Size");
ui->setLabel(var, "Size");
return true;
default: return false;
}});

ui->initSelect(parentVar, "fxLayout", 0, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun: {
web->addResponse(var["id"], "label", "Layout");
JsonArray select = web->addResponseA(var["id"], "options");
select.add(""); //0
select.add("="); //1
select.add("||"); //2
select.add("+"); //3
ui->setLabel(var, "Layout");
ui->setComment(var, "WIP");
JsonArray options = ui->setOptions(var);
options.add(""); //0
options.add("="); //1
options.add("||"); //2
options.add("+"); //3
return true;
}
default: return false;
Expand Down
12 changes: 6 additions & 6 deletions src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void SysModFiles::setup() {
JsonObject tableVar = ui->initTable(parentVar, "fileTbl", nullptr, false, [this](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
{
web->addResponse(var["id"], "label", "Files");
web->addResponse(var["id"], "comment", "List of files");
ui->setLabel(var, "Files");
ui->setComment(var, "List of files");
JsonArray rows = web->addResponseA(var["id"], "value"); //overwrite the value
dirToJson(rows);
return true;
Expand Down Expand Up @@ -70,21 +70,21 @@ void SysModFiles::setup() {

ui->initText(tableVar, "flName", nullptr, 32, true, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "label", "Name");
ui->setLabel(var, "Name");
return true;
default: return false;
}});

ui->initNumber(tableVar, "flSize", UINT16_MAX, 0, UINT16_MAX, true, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "label", "Size (B)");
ui->setLabel(var, "Size (B)");
return true;
default: return false;
}});

ui->initURL(tableVar, "flLink", nullptr, true, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun
case f_UIFun:
web->addResponse(var["id"], "label", "Show");
ui->setLabel(var, "Show");
return true;
default: return false;
}});
Expand All @@ -94,7 +94,7 @@ void SysModFiles::setup() {
mdl->setValue(var, files->usedBytes());
return true;
case f_UIFun:
web->addResponse(var["id"], "label", "FS Size");
ui->setLabel(var, "FS Size");
return true;
case f_ChangeFun:
var["max"] = files->totalBytes(); //makes sense?
Expand Down
Loading

0 comments on commit 86900d3

Please sign in to comment.