Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P
Diff: Speaker.cpp
- Revision:
- 33:5d86c111d9bc
- Parent:
- 20:e068469ffb89
diff -r c40d581f50af -r 5d86c111d9bc Speaker.cpp
--- a/Speaker.cpp Mon Apr 23 16:05:32 2018 +0000
+++ b/Speaker.cpp Wed Apr 25 15:39:03 2018 +0000
@@ -3,13 +3,14 @@
Speaker::Speaker(PinName pin) : _pin(pin), dc(0.67f / 3.3f) {}
+void Speaker::rawWrite(float value) {
+ _pin = value;
+}
+
void Speaker::write(uint8_t value) {
- const static float alpha = 0.99999f;
float sample = (float)value / UINT8_MAX;
- dc = alpha*dc + (1.0f - alpha)*sample;
-
- _pin = 0.5f + (sample - dc)* 33.0f;
+ _pin = sample;
}
void Speaker::turnOff() {