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
Speaker.cpp@33:5d86c111d9bc, 2018-04-25 (annotated)
- Committer:
- Nurchu
- Date:
- Wed Apr 25 15:39:03 2018 +0000
- Revision:
- 33:5d86c111d9bc
- Parent:
- 20:e068469ffb89
Fixed a few bugs
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Nurchu | 14:4637a9f02919 | 1 | #include "Speaker.h" |
| Nurchu | 14:4637a9f02919 | 2 | #define UINT8_MAX 255 |
| Nurchu | 14:4637a9f02919 | 3 | |
| Nurchu | 14:4637a9f02919 | 4 | Speaker::Speaker(PinName pin) : _pin(pin), dc(0.67f / 3.3f) {} |
| Nurchu | 12:efcfe4c0d9f2 | 5 | |
| Nurchu | 33:5d86c111d9bc | 6 | void Speaker::rawWrite(float value) { |
| Nurchu | 33:5d86c111d9bc | 7 | _pin = value; |
| Nurchu | 33:5d86c111d9bc | 8 | } |
| Nurchu | 33:5d86c111d9bc | 9 | |
| Nurchu | 14:4637a9f02919 | 10 | void Speaker::write(uint8_t value) { |
| Nurchu | 14:4637a9f02919 | 11 | float sample = (float)value / UINT8_MAX; |
| Nurchu | 14:4637a9f02919 | 12 | |
| Nurchu | 33:5d86c111d9bc | 13 | _pin = sample; |
| Nurchu | 20:e068469ffb89 | 14 | } |
| Nurchu | 20:e068469ffb89 | 15 | |
| Nurchu | 20:e068469ffb89 | 16 | void Speaker::turnOff() { |
| Nurchu | 20:e068469ffb89 | 17 | _pin = 0.0f; |
| Nurchu | 14:4637a9f02919 | 18 | } |