Skip to content

Commit

Permalink
Merge pull request #18 from netmindz/new-frame-only
Browse files Browse the repository at this point in the history
New frame only
  • Loading branch information
ewowi authored Aug 7, 2023
2 parents 7dbd855 + 9332377 commit 6767200
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/App/AppModLeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class AppModLeds:public Module {
public:
unsigned long frameMillis = 0;
unsigned long frameCounter = 0;
bool newFrame = false;

//need to make these static as they are called in lambda functions
static uint16_t fps;
Expand Down Expand Up @@ -248,6 +249,8 @@ class AppModLeds:public Module {
if(millis() - frameMillis >= 1000.0/fps) {
frameMillis = millis();

newFrame = true;

Effect* effect = effects[mdl->getValue("fx")];
effect->loop();

Expand All @@ -257,6 +260,9 @@ class AppModLeds:public Module {
frameCounter++;
call++;
}
else {
newFrame = false;
}
if (millis() - secondMillis >= 1000 || !secondMillis) {
secondMillis = millis();
mdl->setValueV("realFps", "%lu /s", frameCounter);
Expand Down
2 changes: 2 additions & 0 deletions src/User/UserModArtNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class UserModArtNet:public Module {

if(!isConnected) return;

if(!lds->newFrame) return;

// calculate the number of UDP packets we need to send
bool isRGBW = false;

Expand Down
2 changes: 2 additions & 0 deletions src/User/UserModDDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class UserModDDP:public Module {

if(!isConnected) return;

if(!lds->newFrame) return;

// calculate the number of UDP packets we need to send
bool isRGBW = false;

Expand Down

0 comments on commit 6767200

Please sign in to comment.