Small tweaks and an update limiter for the esp32

This commit is contained in:
2024-06-07 08:12:49 -04:00
parent b64d946165
commit 37bc951b0b
7 changed files with 1897 additions and 1387 deletions

View File

@@ -113,18 +113,30 @@ void parseData(int * args, int argsLength){
// --------------------------------------------------
// ----------------- SETUP AND LOOP -----------------
// --------------------------------------------------
uint32_t boardStateTimer{0};
bool boardStateHasChanged{false};
uint32_t boardStateMaxUpdatePeriod{15}; // this is a little faster than 60fps
void setup() {
Serial.begin(9600);
// SerialBT.begin("blockPartyBT");
Color colors[] = {Color(255, 0, 0), Color(0, 0, 0), Color(0, 0, 0)};
board.SetStackColors(2, colors);
boardStateTimer = millis();
}
void loop() {
if(board.BoardStateHasChanged()){
boardStateHasChanged = true;
}
if(millis() - boardStateTimer > boardStateMaxUpdatePeriod && boardStateHasChanged){
boardStateTimer = millis();
printBoardState();
boardStateHasChanged = false;
}
// DO serial processing