Skip to content

Commit

Permalink
Merge remote-tracking branch 'ewowi/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudwijma committed Jun 28, 2024
2 parents 0843301 + 374d498 commit c7c7186
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 33 deletions.
3 changes: 1 addition & 2 deletions src/Sys/SysModFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ void SysModFiles::setup() {

}

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

if (filesChanged) {
filesChanged = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SysModFiles: public SysModule {

SysModFiles();
void setup();
void loop();
void loop20ms();
void loop10s();

bool remove(const char * path);
Expand Down
3 changes: 1 addition & 2 deletions src/Sys/SysModInstances.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ class SysModInstances:public SysModule {
}
}

void loop() {
// SysModule::loop();
void loop20ms() { //20 ms instead of loop() tripples the loops/sec!

handleNotifications();

Expand Down
3 changes: 1 addition & 2 deletions src/Sys/SysModModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ void SysModModel::setup() {
#endif //STARBASE_DEVMODE
}

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

if (!cleanUpModelDone) { //do after all setups
cleanUpModelDone = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class SysModModel:public SysModule {

SysModModel();
void setup();
void loop();
void loop20ms();

//scan all vars in the model and remove vars where var["o"] is negative or positive, if ro then remove ro values
void cleanUpModel(JsonObject parent = JsonObject(), bool oPos = true, bool ro = false);
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModPins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void SysModPins::setup() {
#endif
}

void SysModPins::loop() {
void SysModPins::loop20ms() {

if (pinsChanged) {
pinsChanged = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModPins.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SysModPins:public SysModule {

SysModPins();
void setup();
void loop();
void loop20ms();

void allocatePin(unsigned8 pinNr, const char * owner, const char * details);
void deallocatePin(unsigned8 pinNr, const char * owner);
Expand Down
3 changes: 1 addition & 2 deletions src/Sys/SysModPrint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ void SysModPrint::setup() {
ui->initTextArea(parentVar, "log");
}

void SysModPrint::loop() {
// Module::loop();
void SysModPrint::loop20ms() {
if (!setupsDone) setupsDone = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModPrint.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SysModPrint:public SysModule {

SysModPrint();
void setup();
void loop();
void loop20ms();

//generic print function
void printf(const char * format, ...);
Expand Down
2 changes: 0 additions & 2 deletions src/Sys/SysModSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ void SysModSystem::setup() {
}

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

loopCounter++;
now = millis() + timebase;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Sys/SysModUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ void SysModUI::setup() {
}});
}

void SysModUI::loop() {
// SysModule::loop();
void SysModUI::loop20ms() { //never more then 50 times a second!

for (VarLoop &varLoop : loopFunctions) {
if (millis() - varLoop.lastMillis >= varLoop.var["interval"].as<int>()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SysModUI: public SysModule {
//serve index.htm
void setup();

void loop();
void loop20ms();
void loop1s();

//order: order%4 determines the column (WIP)
Expand Down
3 changes: 1 addition & 2 deletions src/Sys/SysModWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ void SysModWeb::setup() {

}

void SysModWeb::loop() {
// SysModule::loop();
void SysModWeb::loop20ms() {

//currently not used as each variable is send individually
if (this->modelUpdated) {
Expand Down
2 changes: 1 addition & 1 deletion src/Sys/SysModWeb.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SysModWeb:public SysModule {
SysModWeb();

void setup();
void loop();
void loop20ms();
void loop1s();

void reboot();
Expand Down
6 changes: 4 additions & 2 deletions src/SysModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SysModule {
const char * name;
bool success;
bool isEnabled;
unsigned long twentyMsMillis = millis() - random(1000); //random so not all 1s are fired at once
unsigned long oneSecondMillis = millis() - random(1000); //random so not all 1s are fired at once
unsigned long tenSecondMillis = millis() - random(10000); //random within a second

Expand All @@ -73,8 +74,9 @@ class SysModule {

virtual void setup() {}

virtual void loop() {}
virtual void loop1s() {}
virtual void loop() {}//24000 fps if no load...
virtual void loop20ms() {} //50fps
virtual void loop1s() {} //1fps
virtual void loop10s() {}

virtual void reboot() {}
Expand Down
6 changes: 5 additions & 1 deletion src/SysModules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void SysModules::setup() {

void SysModules::loop() {
// bool oneSec = false;
bool tenSec = false;
// bool tenSec = false;
// if (millis() - oneSecondMillis >= 1000) {
// oneSecondMillis = millis();
// oneSec = true;
Expand All @@ -104,6 +104,10 @@ void SysModules::loop() {
for (SysModule *module:modules) {
if (module->isEnabled && module->success) {
module->loop();
if (millis() - module->twentyMsMillis >= 20) {
module->twentyMsMillis = millis();
module->loop20ms();
}
if (millis() - module->oneSecondMillis >= 1000) {
module->oneSecondMillis = millis();
module->loop1s();
Expand Down
3 changes: 1 addition & 2 deletions src/User/UserModE131.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ class UserModE131:public SysModule {
}
}

void loop() {
// SysModule::loop();
void loop20ms() {
if(!e131Created) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions src/User/UserModHA.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class UserModHA:public SysModule {

}

void loop() override {
// SysModule::loop();
void loop20ms() override {
mqtt->loop();
}

Expand Down
4 changes: 0 additions & 4 deletions src/User/UserModMDNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class UserModMDNS:public SysModule {

}

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

void onOffChanged() {
if (mdls->isConnected && isEnabled) {

Expand Down
2 changes: 1 addition & 1 deletion src/User/UserModMPU6050.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class UserModMPU6050: public SysModule {
mdl->setValue("mtReady", motionTrackingReady);
}

void loop() {
void loop20ms() { // loop(): 700/s, loop20ms: 3000/s, loop1s(): 5500/s, disabled: 6000/s
// mpu.getMotion6(&accell.x, &accell.y, &accell.z, &gyro.x, &gyro.y, &gyro.z);
// // display tab-separated accel/gyro x/y/z values
// ppf("mpu6050 %d,%d,%d %d,%d,%d\n", accell.x, accell.y, accell.z, gyro.x, gyro.y, gyro.z);
Expand Down

0 comments on commit c7c7186

Please sign in to comment.