Skip to content

Commit

Permalink
Fix PWMAudio::write(buffer, len) (#2202)
Browse files Browse the repository at this point in the history
PWMAudio was only ever writing one half the buffer passed in because
of an off-by-2 error.  Fixes the sine output in KeyboardPiano.
  • Loading branch information
earlephilhower authored Jun 5, 2024
1 parent 8bc8c82 commit 9039089
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libraries/PWMAudio/src/PWMAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ size_t PWMAudio::write(const uint8_t *buffer, size_t size) {
return writtenSize;
} else {
p++;
size -= 4;
writtenSize += 4;
size -= 2;
writtenSize += 2;
}
}
return writtenSize;
Expand Down Expand Up @@ -288,4 +288,4 @@ void PWMAudio::find_pacer_fraction(int target, uint16_t *numerator, uint16_t *de
last_target = target;
*numerator = bestNum;
*denominator = bestDenom;
}
}

0 comments on commit 9039089

Please sign in to comment.