Skip to content

Commit

Permalink
main.cpp -> mainStar.h and STARMOD_MAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
ewowi committed Jan 10, 2025
1 parent a51f23d commit 63aaeb9
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 165 deletions.
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ build_flags =
; ${STARBASE_USERMOD_MIDI.build_flags} ;+5%...
; ${STARBASE_USERMOD_HA.build_flags}
${STARBASE_USERMOD_LIVE.build_flags} ;+222.204 bytes 11.7%
-D STARBASE_MAIN
lib_deps =
https://github.com/bblanchon/ArduinoJson.git @ 7.3.0 ;force latest
; https://github.com/Jason2866/ESP32_Show_Info.git
Expand Down
3 changes: 0 additions & 3 deletions src/Sys/SysModWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@

#include "html_ui.h"
#include "html_newui.h"
// #include "WWWData.h"

// #include <ArduinoOTA.h>

//https://techtutorialsx.com/2018/08/24/esp32-web-server-serving-html-from-file-system/
//https://randomnerdtutorials.com/esp32-async-web-server-espasyncwebserver-library/
Expand Down
172 changes: 10 additions & 162 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,167 +9,15 @@
@license For non GPL-v3 usage, commercial licenses must be purchased. Contact [email protected]
*/

#include "SysModule.h"
#include "SysModules.h"
#include "Sys/SysModPrint.h"
#include "Sys/SysModWeb.h"
#include "Sys/SysModUI.h"
#include "Sys/SysModSystem.h"
#include "Sys/SysModFiles.h"
#include "Sys/SysModModel.h"
#include "Sys/SysModNetwork.h"
#include "Sys/SysModPins.h"
#include "Sys/SysModInstances.h"
#include "User/UserModMDNS.h"
SysModules *mdls;
SysModPrint *print;
SysModWeb *web;
SysModUI *ui;
SysModSystem *sys;
SysModFiles *files;
SysModModel *mdl;
SysModNetwork *net;
SysModPins *pinsM;
SysModInstances *instances;
UserModMDNS *mdns;
#ifdef STARLIGHT
#include "App/LedModEffects.h"
#include "App/LedModFixture.h"
#include "App/LedModFixtureGen.h"
LedModFixture *fix;
LedModFixtureGen *lfg;
LedModEffects *eff;
#ifdef STARLIGHT_USERMOD_ARTNET
#include "User/UserModArtNet.h"
UserModArtNet *artnetmod;
#endif
#ifdef STARLIGHT_USERMOD_DDP
#include "User/UserModDDP.h"
UserModDDP *ddpmod;
#endif
#endif
#ifdef STARBASE_USERMOD_E131
#include "User/UserModE131.h"
UserModE131 *e131mod;
#endif
#ifdef STARBASE_USERMOD_HA
#include "User/UserModHA.h"
UserModHA *hamod;
#endif
#ifdef STARBASE_USERMOD_MPU6050
#include "User/UserModMPU6050.h"
UserModMPU6050 *mpu6050;
#endif
#ifdef STARBASE_USERMOD_MIDI
#include "User/UserModMidi.h"
UserModMidi *midi;
#endif
#ifdef STARBASE_USERMOD_LIVE
#include "User/UserModLive.h"
UserModLive *liveM;
#endif
#ifdef STARLIGHT_USERMOD_AUDIOSYNC
#include "User/UserModAudioSync.h"
UserModAudioSync *audioSync;
#endif

SET_LOOP_TASK_STACK_SIZE(16 * 1024); // 16KB
#ifdef STARBASE_MAIN
#include "mainStar.h"
void setup() {
setupStar();
}

//setup all modules
void setup() {

mdls = new SysModules();

print = new SysModPrint();
files = new SysModFiles();
mdl = new SysModModel();
net = new SysModNetwork();
web = new SysModWeb();
ui = new SysModUI();
sys = new SysModSystem();
pinsM = new SysModPins();
instances = new SysModInstances();
mdns = new UserModMDNS();
#ifdef STARLIGHT
eff = new LedModEffects();
fix = new LedModFixture();
lfg = new LedModFixtureGen();
#ifdef STARLIGHT_USERMOD_ARTNET
artnetmod = new UserModArtNet();
#endif
#ifdef STARLIGHT_USERMOD_DDP
ddpmod = new UserModDDP();
#endif
#endif
#ifdef STARBASE_USERMOD_E131
e131mod = new UserModE131();
#endif
#ifdef STARBASE_USERMOD_HA
hamod = new UserModHA();
#endif
#ifdef STARBASE_USERMOD_MPU6050
mpu6050 = new UserModMPU6050();
#endif
#ifdef STARBASE_USERMOD_MIDI
midi = new UserModMidi();
#endif
#ifdef STARBASE_USERMOD_LIVE
liveM = new UserModLive();
#endif
#ifdef STARLIGHT_USERMOD_AUDIOSYNC
audioSync = new UserModAudioSync();
#endif

//Reorder with care! this is the order in which setup and loop is executed
//If changed make sure Modules.enabled.chFun executes var["value"].to<JsonArray>(); and saveModel!
//Default: add below, not in between
#ifdef STARLIGHT
mdls->add(fix);
mdls->add(eff);
mdls->add(lfg);
#endif
mdls->add(files);
mdls->add(sys);
mdls->add(pinsM);
mdls->add(print);
mdls->add(web);
mdls->add(net);
#ifdef STARLIGHT
#ifdef STARLIGHT_USERMOD_DDP
mdls->add(ddpmod);
#endif
#ifdef STARLIGHT_USERMOD_ARTNET
mdls->add(artnetmod);
#endif
#endif
#ifdef STARBASE_USERMOD_E131
mdls->add(e131mod);
#endif
#ifdef STARBASE_USERMOD_HA
mdls->add(hamod); //no ui
#endif
#ifdef STARBASE_USERMOD_MPU6050
mdls->add(mpu6050);
#endif
#ifdef STARBASE_USERMOD_MIDI
mdls->add(midi);
#endif
mdls->add(mdl);
mdls->add(ui);
#ifdef STARLIGHT_USERMOD_AUDIOSYNC
mdls->add(audioSync); //no ui
#endif
mdls->add(mdns); //no ui
mdls->add(instances);
#ifdef STARBASE_USERMOD_LIVE
mdls->add(liveM);
#endif

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

//loop all modules
void loop() {
mdls->loop();
}
//loop all modules
void loop() {
loopStar();
}
#endif
175 changes: 175 additions & 0 deletions src/mainStar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/*
@title StarBase
@file mainStar.h
@date 20241219
@repo https://github.com/ewowi/StarBase, submit changes to this file as PRs to ewowi/StarBase
@Authors https://github.com/ewowi/StarBase/commits/main
@Copyright © 2024 Github StarBase Commit Authors
@license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
@license For non GPL-v3 usage, commercial licenses must be purchased. Contact [email protected]
*/

#include "SysModule.h"
#include "SysModules.h"
#include "Sys/SysModPrint.h"
#include "Sys/SysModWeb.h"
#include "Sys/SysModUI.h"
#include "Sys/SysModSystem.h"
#include "Sys/SysModFiles.h"
#include "Sys/SysModModel.h"
#include "Sys/SysModNetwork.h"
#include "Sys/SysModPins.h"
#include "Sys/SysModInstances.h"
#include "User/UserModMDNS.h"
SysModules *mdls;
SysModPrint *print;
SysModWeb *web;
SysModUI *ui;
SysModSystem *sys;
SysModFiles *files;
SysModModel *mdl;
SysModNetwork *net;
SysModPins *pinsM;
SysModInstances *instances;
UserModMDNS *mdns;
#ifdef STARLIGHT
#include "App/LedModEffects.h"
#include "App/LedModFixture.h"
#include "App/LedModFixtureGen.h"
LedModFixture *fix;
LedModFixtureGen *lfg;
LedModEffects *eff;
#ifdef STARLIGHT_USERMOD_ARTNET
#include "User/UserModArtNet.h"
UserModArtNet *artnetmod;
#endif
#ifdef STARLIGHT_USERMOD_DDP
#include "User/UserModDDP.h"
UserModDDP *ddpmod;
#endif
#endif
#ifdef STARBASE_USERMOD_E131
#include "User/UserModE131.h"
UserModE131 *e131mod;
#endif
#ifdef STARBASE_USERMOD_HA
#include "User/UserModHA.h"
UserModHA *hamod;
#endif
#ifdef STARBASE_USERMOD_MPU6050
#include "User/UserModMPU6050.h"
UserModMPU6050 *mpu6050;
#endif
#ifdef STARBASE_USERMOD_MIDI
#include "User/UserModMidi.h"
UserModMidi *midi;
#endif
#ifdef STARBASE_USERMOD_LIVE
#include "User/UserModLive.h"
UserModLive *liveM;
#endif
#ifdef STARLIGHT_USERMOD_AUDIOSYNC
#include "User/UserModAudioSync.h"
UserModAudioSync *audioSync;
#endif

SET_LOOP_TASK_STACK_SIZE(16 * 1024); // 16KB

//setup all modules
void setupStar() {

mdls = new SysModules();

print = new SysModPrint();
files = new SysModFiles();
mdl = new SysModModel();
net = new SysModNetwork();
web = new SysModWeb();
ui = new SysModUI();
sys = new SysModSystem();
pinsM = new SysModPins();
instances = new SysModInstances();
mdns = new UserModMDNS();
#ifdef STARLIGHT
eff = new LedModEffects();
fix = new LedModFixture();
lfg = new LedModFixtureGen();
#ifdef STARLIGHT_USERMOD_ARTNET
artnetmod = new UserModArtNet();
#endif
#ifdef STARLIGHT_USERMOD_DDP
ddpmod = new UserModDDP();
#endif
#endif
#ifdef STARBASE_USERMOD_E131
e131mod = new UserModE131();
#endif
#ifdef STARBASE_USERMOD_HA
hamod = new UserModHA();
#endif
#ifdef STARBASE_USERMOD_MPU6050
mpu6050 = new UserModMPU6050();
#endif
#ifdef STARBASE_USERMOD_MIDI
midi = new UserModMidi();
#endif
#ifdef STARBASE_USERMOD_LIVE
liveM = new UserModLive();
#endif
#ifdef STARLIGHT_USERMOD_AUDIOSYNC
audioSync = new UserModAudioSync();
#endif

//Reorder with care! this is the order in which setup and loop is executed
//If changed make sure Modules.enabled.chFun executes var["value"].to<JsonArray>(); and saveModel!
//Default: add below, not in between
#ifdef STARLIGHT
mdls->add(fix);
mdls->add(eff);
mdls->add(lfg);
#endif
mdls->add(files);
mdls->add(sys);
mdls->add(pinsM);
mdls->add(print);
mdls->add(web);
mdls->add(net);
#ifdef STARLIGHT
#ifdef STARLIGHT_USERMOD_DDP
mdls->add(ddpmod);
#endif
#ifdef STARLIGHT_USERMOD_ARTNET
mdls->add(artnetmod);
#endif
#endif
#ifdef STARBASE_USERMOD_E131
mdls->add(e131mod);
#endif
#ifdef STARBASE_USERMOD_HA
mdls->add(hamod); //no ui
#endif
#ifdef STARBASE_USERMOD_MPU6050
mdls->add(mpu6050);
#endif
#ifdef STARBASE_USERMOD_MIDI
mdls->add(midi);
#endif
mdls->add(mdl);
mdls->add(ui);
#ifdef STARLIGHT_USERMOD_AUDIOSYNC
mdls->add(audioSync); //no ui
#endif
mdls->add(mdns); //no ui
mdls->add(instances);
#ifdef STARBASE_USERMOD_LIVE
mdls->add(liveM);
#endif

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

//loop all modules
void loopStar() {
mdls->loop();
}

0 comments on commit 63aaeb9

Please sign in to comment.