Skip to content

Commit

Permalink
Module ordering and rename AI to Workflow
Browse files Browse the repository at this point in the history
General: reorder all modules

index.htm: add ⓘ in header

index.js:
- refactor module column distribution
- checbox and button: support table rows

SysModWorkflow
- rename from AI
- rename recommendation to action
  • Loading branch information
ewowi committed Mar 27, 2024
1 parent 9df3ab4 commit 93bbbc5
Show file tree
Hide file tree
Showing 29 changed files with 1,536 additions and 1,505 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# StarMod

Headstart for building ESP32 applications: printing, file management, persistent data, Wifi, Web, UI and system management works out of the box.
StarMod will integrate with major iot/network devices and applications (Work in progress).
StarMod will integrate with major IOT/network devices and applications.

Everything is a module.

Expand All @@ -16,19 +16,21 @@ System modules:
* System: Show and manage ESP32 system

User Modules

* E131/DMX support
* Home Assistant (planned)
* WLED (planned)
* LEDs
* ...

Build apps on top of this

* Led apps
* IO control apps
* IOT apps
* Any app

By [MoonModules](https://github.com/MoonModules)
Inspired by [WLED](https://github.com/MoonModules/WLED)
LED module inspired by [WLED MM](https://github.com/MoonModules/WLED)

Disclaimer:

Expand Down
6 changes: 5 additions & 1 deletion data/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
</head>
<body onload="onLoad()">
<div class="module">
<h1>StarMod💫 LEDs 🎨 by MoonModules 🌔</h1>
<hgroup>
<h1 style="float: left;">StarMod💫 LEDs 🎨 by MoonModules 🌔</h1>
<a href="https://ewowi.github.io/StarDocs" style="float: right;"></a>
</hgroup>
<br>
<h2><div id="instanceName"></div></h2>
<input type="button" value="App" id="vApp" onclick="setView(this)">
<input type="button" value="DashBoard" id="vDash" onclick="setView(this)">
Expand Down
22 changes: 13 additions & 9 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
let d = document;
let ws = null;

let mdlColumnNr = 0;
let nrOfMdlColumns = 4;
let jsonValues = {};
let uiFunCommands = [];
Expand Down Expand Up @@ -177,8 +176,7 @@ function createHTML(json, parentNode = null, rowNr = UINT8_MAX) {

//if root (type module) add the html to one of the mdlColumns
if (parentNode == null) {
parentNode = gId("mdlColumn" + mdlColumnNr);
mdlColumnNr = (mdlColumnNr +1)%nrOfMdlColumns; //distribute over columns (tbd: configure)
parentNode = gId("mdlColumn" + variable.o%nrOfMdlColumns);
}
let parentNodeType = parentNode.nodeName.toLocaleLowerCase();

Expand Down Expand Up @@ -879,11 +877,17 @@ function changeHTML(variable, commandJson, rowNr = UINT8_MAX) {
else if (node.className == "canvas")
console.log("not called anymore");
else if (node.className == "checkbox") {
node.querySelector("input").checked = commandJson.value;
node.querySelector("input").indeterminate = (commandJson.value == null); //set the false if it has a non null value
let value = commandJson.value;
if (Array.isArray(commandJson.value) && rowNr != UINT8_MAX)
value = commandJson.value[rowNr];
node.querySelector("input").checked = value;
node.querySelector("input").indeterminate = (value == null); //set the false if it has a non null value
}
else if (node.className == "button") {
if (commandJson.value) node.value = commandJson.value; //else the id / label is used as button label
let value = commandJson.value;
if (Array.isArray(commandJson.value) && rowNr != UINT8_MAX)
value = commandJson.value[rowNr];
if (value) node.value = value; //else the id / label is used as button label
}
else if (node.className == "coord3D") {
// console.log("chHTML value coord3D", node, commandJson.value, rowNr);
Expand Down Expand Up @@ -1440,9 +1444,9 @@ function changeHTMLView(value) {
}
}

if (value=="vApp")
mdlContainerNode.className = "mdlContainer2";
else
// if (value=="vApp")
// mdlContainerNode.className = "mdlContainer2";
// else
mdlContainerNode.className = "mdlContainer" + columnCounter; //1..4

setInstanceTableColumns();
Expand Down
6 changes: 3 additions & 3 deletions data/model.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"id": "AI",
"id": "WorkFlow",
"type": "appmod",
"ro": true,
"o": 6100,
Expand All @@ -13,14 +13,14 @@
"o": 1,
"n": [
{
"id": "aiIntel",
"id": "wfAction",
"type": "text",
"ro": true,
"o": 2,
"max": 32
},
{
"id": "aiButton",
"id": "wfButton",
"type": "button",
"ro": false,
"o": 3
Expand Down
1 change: 1 addition & 0 deletions src/App/LedFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ void Fixture::projectAndMap() {
//tbd: more check

strncpy(pins->pinObjects[currPin].details, details, sizeof(PinObject::details)-1);
pins->pinsChanged = true;
}
}
else {//allocate new pin
Expand Down
2 changes: 1 addition & 1 deletion src/App/LedModEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class LedModEffects:public SysModule {
void setup() {
SysModule::setup();

parentVar = ui->initAppMod(parentVar, name, 1200);
parentVar = ui->initAppMod(parentVar, name, 1201);

JsonObject currentVar;

Expand Down
5 changes: 5 additions & 0 deletions src/App/LedModFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class LedModFixture:public SysModule {
return true;
case f_ChangeFun:
ui->callVarFun("bri", UINT8_MAX, f_ChangeFun); //set FastLed brightness

//WIP!!!
wf->addAction("Define fixture", "FixtureGen");
wf->addAction("Save model", "Model");

return true;
default: return false;
}});
Expand Down
2 changes: 1 addition & 1 deletion src/App/LedModFixtureGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class LedModFixtureGen:public SysModule {
void setup() {
SysModule::setup();

parentVar = ui->initUserMod(parentVar, name, 1300); //created as a usermod, not an appmod to have it in the usermods tab
parentVar = ui->initUserMod(parentVar, name, 6302); //created as a usermod, not an appmod to have it in the usermods tab

ui->initSelect(parentVar, "fixtureGen", 0, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_UIFun: {
Expand Down
93 changes: 0 additions & 93 deletions src/Sys/SysModAI.h

This file was deleted.

8 changes: 4 additions & 4 deletions src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "SysModWeb.h"
#include "SysModPrint.h"
#include "SysModModel.h"
#include "SysModAI.h"
#include "SysModWorkFlow.h"

// #include <FS.h>

Expand All @@ -31,7 +31,7 @@ SysModFiles::SysModFiles() :SysModule("Files") {
//setup filesystem
void SysModFiles::setup() {
SysModule::setup();
parentVar = ui->initSysMod(parentVar, name, 2000);
parentVar = ui->initSysMod(parentVar, name, 2101);

JsonObject tableVar = ui->initTable(parentVar, "fileTbl", nullptr, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_UIFun:
Expand Down Expand Up @@ -134,8 +134,8 @@ void SysModFiles::loop() {
}
root.close();

// ai->addIntelligence("No fixture found", "FixtureGen");
// ai->addIntelligence("No model found", "Model");
// wf->addAction("Define fixture", "FixtureGen");
// wf->addAction("Save model", "Model");

ui->callVarFun(mdl->findVar("drsize")); //valueFun

Expand Down
1 change: 1 addition & 0 deletions src/Sys/SysModFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

#pragma once

#include "SysModule.h"
#include "LittleFS.h"

Expand Down
3 changes: 2 additions & 1 deletion src/Sys/SysModModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SysModModel::SysModModel() :SysModule("Model") {
void SysModModel::setup() {
SysModule::setup();

parentVar = ui->initSysMod(parentVar, name, 4000);
parentVar = ui->initSysMod(parentVar, name, 4303);

ui->initButton(parentVar, "saveModel", false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_UIFun:
Expand Down Expand Up @@ -96,6 +96,7 @@ void SysModModel::setup() {
StarModJson starModJson("/model.json", "w"); //open fileName for deserialize
starModJson.addExclusion("fun");
starModJson.addExclusion("dash");
starModJson.addExclusion("o");
starModJson.writeJsonDocToFile(model);

// print->printJson("Write model", *model); //this shows the model before exclusion
Expand Down
6 changes: 3 additions & 3 deletions src/Sys/SysModNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
#include "SysModWeb.h"
#include "SysModUI.h"
#include "SysModModel.h"
#include "SysModAI.h"
#include "SysModWorkFlow.h"

SysModNetwork::SysModNetwork() :SysModule("Network") {};

//setup wifi an async webserver
void SysModNetwork::setup() {
SysModule::setup();

parentVar = ui->initSysMod(parentVar, name, 2500);
parentVar = ui->initSysMod(parentVar, name, 3502);

// JsonObject tableVar = ui->initTable(parentVar, "wfTbl", nullptr, false, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { //varFun ro false: create and delete row possible
// ui->setLabel(var, "Wifi");
Expand Down Expand Up @@ -68,7 +68,7 @@ void SysModNetwork::setup() {
default: return false;
}});

// ai->addIntelligence("Enter credentials", "Network");
// wf->addAction("Enter credentials", "Network");
}

void SysModNetwork::loop() {
Expand Down
3 changes: 2 additions & 1 deletion src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SysModPins::SysModPins() :SysModule("Pins") {

void SysModPins::setup() {
SysModule::setup();
parentVar = ui->initSysMod(parentVar, name, 2200);
parentVar = ui->initSysMod(parentVar, name, 2202);

//show table of allocated pins
JsonObject tableVar = ui->initTable(parentVar, "pinTbl", nullptr, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
Expand Down Expand Up @@ -69,6 +69,7 @@ void SysModPins::setup() {
ui->initText(tableVar, "pinDetails", nullptr, 256, true, [this](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_ValueFun:
for (forUnsigned8 rowNr = 0; rowNr < getNrOfAllocatedPins(); rowNr++)
USER_PRINTF("pinDetails[%d] d1:%s d2:%s\n", rowNr, getNthAllocatedPinObject(rowNr).details, pinObjects[0].details);
mdl->setValue(var, JsonString(getNthAllocatedPinObject(rowNr).details, JsonString::Copied), rowNr);
return true;
case f_UIFun:
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModPins.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class SysModPins:public SysModule {

static bool updateGPIO(JsonObject var, unsigned8 rowNr, unsigned8 funType);

private:
static bool pinsChanged; //update pins table if pins changed
private:
};

static SysModPins *pins;
2 changes: 1 addition & 1 deletion src/Sys/SysModPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ SysModPrint::SysModPrint() :SysModule("Print") {
void SysModPrint::setup() {
SysModule::setup();

parentVar = ui->initSysMod(parentVar, name, 2300);
parentVar = ui->initSysMod(parentVar, name, 2302);

ui->initSelect(parentVar, "pOut", 1, false, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_UIFun:
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SysModSystem::SysModSystem() :SysModule("System") {};

void SysModSystem::setup() {
SysModule::setup();
parentVar = ui->initSysMod(parentVar, name, 2100);
parentVar = ui->initSysMod(parentVar, name, 2000);

ui->initText(parentVar, "serverName", "StarMod", 32, false, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_UIFun:
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SysModUI::SysModUI() :SysModule("UI") {
void SysModUI::setup() {
SysModule::setup();

parentVar = initSysMod(parentVar, name, 4100);
parentVar = initSysMod(parentVar, name, 4101);

JsonObject tableVar = initTable(parentVar, "vlTbl", nullptr, true, [](JsonObject var, unsigned8 rowNr, unsigned8 funType) { switch (funType) { //varFun
case f_UIFun:
Expand Down
1 change: 1 addition & 0 deletions src/Sys/SysModUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class SysModUI:public SysModule {
void loop();
void loop1s();

//order: order%4 determines the column (WIP)
JsonObject initAppMod(JsonObject parent, const char * id, int order = 0) {
JsonObject var = initVarAndUpdate<const char *>(parent, id, "appmod", (const char *)nullptr);
if (order) mdl->varSetDefaultOrder(var, order + 1000);
Expand Down
Loading

0 comments on commit 93bbbc5

Please sign in to comment.