Skip to content

Commit

Permalink
Decrease missed packets when using marker: sendData set to false as q…
Browse files Browse the repository at this point in the history
…uickly as possible so it can be set to true again by the interrupt handler while sending data is still in progress
  • Loading branch information
loostrum committed Nov 28, 2024
1 parent 294db03 commit 80cceed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion device/PowerSensor/PowerSensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ void setup() {

void loop() {
if (sendData) {
sendData = false;
// copy serialData to avoid overwrite by next values in IRQ handler
uint8_t serialDataToSend[sizeof(serialData)];
memcpy(serialDataToSend, serialData, sizeof(serialData));
Expand All @@ -421,7 +422,6 @@ void loop() {
sendMarkers--;
}
Serial.write(serialDataToSend, sizeof(serialDataToSend));
sendData = false;
}
// check for serial events
serialEvent();
Expand Down

0 comments on commit 80cceed

Please sign in to comment.