Skip to content

Commit

Permalink
Renaming SysModule and SysModules + small changes
Browse files Browse the repository at this point in the history
AppModLeds
- bri: use log and stage as custom properties

SysjsonRDWS.writeJsonDocToFile and SysModFiles.seqNrToName: close file explicitly

SysModNetwork: forceReconnect not static

SysModPrint:
- show core L or A
- add printClient

SysModSystem
- bugfix: version: no setValue in uiFun !!!

SysModUI: initVarAndUpdate: remove custom parameter

Module
- Rename Module to SysModule

SysModModules
- Rename SysModModules to SysModules
- not inheriting from module!

UserModInstances
- add fx, on and bri as columns (WIP)

UserModWLEDAudio
- check if connected in loop!
  • Loading branch information
ewowi committed Oct 31, 2023
1 parent 05d88a2 commit 0352610
Show file tree
Hide file tree
Showing 34 changed files with 1,070 additions and 205 deletions.
828 changes: 828 additions & 0 deletions data/model.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/App/AppEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ class GEQEffect:public Effect {
ui->initSlider(parentVar, "fadeOut", 255);
ui->initSlider(parentVar, "ripple", 255);
ui->initCheckBox(parentVar, "colorBars");
ui->initCheckBox(parentVar, "smoothBars");
ui->initCheckBox(parentVar, "smoothBars", true); //default on

// Nice an effect can register it's own DMX channel, but not a fan of repeating the range and type of the param

Expand Down
10 changes: 5 additions & 5 deletions src/App/AppModLedFixGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
*/

#include "Module.h"
#include "SysModule.h"

class GenFix {

Expand Down Expand Up @@ -496,14 +496,14 @@ class GenFix {

};

class AppModLedFixGen:public Module {
class AppModLedFixGen:public SysModule {

public:

AppModLedFixGen() :Module("LedFixGen") {};
AppModLedFixGen() :SysModule("LedFixGen") {};

void setup() {
Module::setup();
SysModule::setup();
USER_PRINT_FUNCTION("%s %s\n", __PRETTY_FUNCTION__, name);

parentVar = ui->initModule(parentVar, name);
Expand Down Expand Up @@ -541,7 +541,7 @@ class AppModLedFixGen:public Module {
}

void loop() {
// Module::loop();
// SysModule::loop();
}

enum Fixtures
Expand Down
20 changes: 13 additions & 7 deletions src/App/AppModLeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
*/

#include "Module.h"
#include "SysModule.h"

#include "AppLedsV.h"
#include "AppEffects.h"
Expand All @@ -31,7 +31,7 @@ inline uint16_t getRGBWsize(uint16_t nleds){
//https://github.com/FastLED/FastLED/blob/master/examples/DemoReel100/DemoReel100.ino
//https://blog.ja-ke.tech/2019/06/02/neopixel-performance.html

class AppModLeds:public Module {
class AppModLeds:public SysModule {

public:
bool newFrame = false; //for other modules (DDP)
Expand All @@ -41,19 +41,23 @@ class AppModLeds:public Module {
bool doMap = false;
Effects effects;

AppModLeds() :Module("Leds") {};
AppModLeds() :SysModule("Leds") {};

void setup() {
Module::setup();
SysModule::setup();
USER_PRINT_FUNCTION("%s %s\n", __PRETTY_FUNCTION__, name);

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

ui->initCheckBox(parentVar, "on");
ui->initCheckBox(parentVar, "on", false, false, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "On");
}, [](JsonObject var) { //chFunFun
ui->valChangedForInstancesTemp = true;
});
// ui->initCheckBox(parentVar, "v");

//logarithmic slider (10)
ui->initSlider(parentVar, "bri", 5, 0, 255, 10, false, [](JsonObject var) { //uiFun
JsonObject var = ui->initSlider(parentVar, "bri", 10, 0, 255, 10, false, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Brightness");
}, [](JsonObject var) { //chFun
uint8_t bri = var["value"];
Expand All @@ -65,6 +69,8 @@ class AppModLeds:public Module {
USER_PRINTF("Set Brightness to %d -> b:%d r:%d\n", var["value"].as<int>(), bri, result);
ui->valChangedForInstancesTemp = true;
});
var["log"] = true;
var["stage"] = true;

ui->initCanvas(parentVar, "pview", -1, false, [](JsonObject var) { //uiFun
web->addResponse(var["id"], "label", "Preview");
Expand Down Expand Up @@ -217,7 +223,7 @@ class AppModLeds:public Module {
}

void loop() {
// Module::loop();
// SysModule::loop();

//set new frame
if (millis() - frameMillis >= 1000.0/fps) {
Expand Down
1 change: 1 addition & 0 deletions src/Sys/SysJsonRDWS.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class JsonRDWS {
//serializeJson
void writeJsonDocToFile(JsonDocument* dest) {
writeJsonVariantToFile(dest->as<JsonVariant>());
f.close();
files->filesChange();
}

Expand Down
7 changes: 4 additions & 3 deletions src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

bool SysModFiles::filesChanged = false;

SysModFiles::SysModFiles() :Module("Files") {
SysModFiles::SysModFiles() :SysModule("Files") {
USER_PRINT_FUNCTION("%s %s\n", __PRETTY_FUNCTION__, name);

if (!LittleFS.begin(true)) { //true: formatOnFail
Expand All @@ -32,7 +32,7 @@ SysModFiles::SysModFiles() :Module("Files") {

//setup filesystem
void SysModFiles::setup() {
Module::setup();
SysModule::setup();
parentVar = ui->initModule(parentVar, name);

JsonObject tableVar = ui->initTable(parentVar, "fileTbl", nullptr, false, [this](JsonObject var) { //uiFun
Expand Down Expand Up @@ -84,7 +84,7 @@ void SysModFiles::setup() {
}

void SysModFiles::loop(){
// Module::loop();
// SysModule::loop();

// if (millis() - secondMillis >= 10000) {
// secondMillis = millis();
Expand Down Expand Up @@ -163,6 +163,7 @@ bool SysModFiles::seqNrToName(char * fileName, size_t seqNr) {
root.close();
strncat(fileName, "/", 31); //add root prefix, fileName is 32 bytes but sizeof doesn't know so cheating
strncat(fileName, file.name(), 31);
file.close();
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Sys/SysModFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/

#pragma once
#include "Module.h"
#include "SysModule.h"
#include "LittleFS.h"

class SysModFiles:public Module {
class SysModFiles: public SysModule {

public:
SysModFiles();
Expand Down
11 changes: 5 additions & 6 deletions src/Sys/SysModModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

#include "SysModModel.h"
#include "Module.h"
#include "SysModule.h"
#include "SysModWeb.h"
#include "SysModPrint.h"
#include "SysModUI.h"
Expand All @@ -18,7 +18,7 @@

DynamicJsonDocument * SysModModel::model = nullptr;

SysModModel::SysModModel() :Module("Model") {
SysModModel::SysModModel() :SysModule("Model") {
model = new DynamicJsonDocument(24576);

JsonArray root = model->to<JsonArray>(); //create
Expand All @@ -37,7 +37,7 @@ SysModModel::SysModModel() :Module("Model") {
}

void SysModModel::setup() {
Module::setup();
SysModule::setup();

USER_PRINT_FUNCTION("%s %s\n", __PRETTY_FUNCTION__, name);

Expand Down Expand Up @@ -76,7 +76,7 @@ void SysModModel::setup() {
}

void SysModModel::loop() {
// Module::loop();
// SysModule::loop();

if (!cleanUpModelDone) { //do after all setups
cleanUpModelDone = true;
Expand Down Expand Up @@ -234,7 +234,6 @@ JsonObject SysModModel::setValueB(const char * id, bool value, uint8_t rowNr) {

//Set value with argument list
JsonObject SysModModel::setValueV(const char * id, const char * format, ...) {
// return JsonObject();
va_list args;
va_start(args, format);

Expand All @@ -254,7 +253,7 @@ JsonObject SysModModel::setValueP(const char * id, const char * format, ...) {
// size_t len = vprintf(format, args);
char value[128];
vsnprintf(value, sizeof(value)-1, format, args);
// USER_PRINTF("%s\n", value);
USER_PRINTF("%s\n", value);

va_end(args);

Expand Down
4 changes: 2 additions & 2 deletions src/Sys/SysModModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
*/

#pragma once
#include "Module.h"
#include "SysModule.h"

#include "ArduinoJson.h"

class SysModModel:public Module {
class SysModModel:public SysModule {

public:

Expand Down
37 changes: 0 additions & 37 deletions src/Sys/SysModModules.h

This file was deleted.

23 changes: 9 additions & 14 deletions src/Sys/SysModNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@
*/

#include "SysModNetwork.h"
#include "Module.h"
#include "SysModModules.h"

#include "SysModules.h"
#include "SysModPrint.h"
#include "SysModWeb.h"
#include "SysModUI.h"
#include "SysModModel.h"

#include <WiFi.h>

//init static variables (https://www.tutorialspoint.com/cplusplus/cpp_static_members.htm)
bool SysModNetwork::forceReconnect = false;

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

//setup wifi an async webserver
void SysModNetwork::setup() {
Module::setup();
SysModule::setup();
USER_PRINT_FUNCTION("%s %s\n", __PRETTY_FUNCTION__, name);

parentVar = ui->initModule(parentVar, name);
Expand All @@ -36,7 +31,7 @@ void SysModNetwork::setup() {
});
ui->initButton(parentVar, "connect", nullptr, false, [](JsonObject var) {
web->addResponse(var["id"], "comment", "Force reconnect (you loose current connection)");
}, [](JsonObject var) {
}, [this](JsonObject var) {
forceReconnect = true;
});
ui->initText(parentVar, "nwstatus", nullptr, 32, true, [](JsonObject var) { //uiFun
Expand All @@ -50,7 +45,7 @@ void SysModNetwork::setup() {
}

void SysModNetwork::loop() {
// Module::loop();
// SysModule::loop();

handleConnection();
}
Expand Down Expand Up @@ -90,7 +85,7 @@ void SysModNetwork::handleConnection() {

interfacesInited = true;

SysModModules::newConnection = true; // send all modules connect notification
SysModules::newConnection = true; // send all modules connect notification

// shut down AP
if (apActive) { //apBehavior != AP_BEHAVIOR_ALWAYS
Expand Down Expand Up @@ -139,11 +134,11 @@ void SysModNetwork::initAP() {
{
mdl->setValueP("nwstatus", "AP %s / %s @ %s", apSSID, apPass, WiFi.softAPIP().toString().c_str());

SysModModules::newConnection = true; // send all modules connect notification

dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
dnsServer.start(53, "*", WiFi.softAPIP());
apActive = true;

SysModules::newConnection = true; // send all modules connect notification
}

apActive = true;
}
7 changes: 4 additions & 3 deletions src/Sys/SysModNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
@license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
*/

#include "Module.h"
#include "SysModule.h"

#include <DNSServer.h>

class SysModNetwork:public Module {
class SysModNetwork:public SysModule {

public:

Expand Down Expand Up @@ -41,7 +41,8 @@ class SysModNetwork:public Module {
DNSServer dnsServer;
bool noWifiSleep = true;

static bool forceReconnect;
//init static variables (https://www.tutorialspoint.com/cplusplus/cpp_static_members.htm)
bool forceReconnect = false;
};

static SysModNetwork *net;
4 changes: 2 additions & 2 deletions src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
PinObject SysModPins::pinObjects[NUM_PINS];
bool SysModPins::pinsChanged = false;

SysModPins::SysModPins() :Module("Pins") {
SysModPins::SysModPins() :SysModule("Pins") {
USER_PRINT_FUNCTION("%s %s\n", __PRETTY_FUNCTION__, name);

pinMode(2, OUTPUT);
Expand All @@ -32,7 +32,7 @@ SysModPins::SysModPins() :Module("Pins") {
};

void SysModPins::setup() {
Module::setup();
SysModule::setup();
USER_PRINT_FUNCTION("%s %s\n", __PRETTY_FUNCTION__, name);

parentVar = ui->initModule(parentVar, name);
Expand Down
Loading

0 comments on commit 0352610

Please sign in to comment.