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
Microphone.cpp@8:0222df74596e, 2018-04-18 (annotated)
- Committer:
- Nurchu
- Date:
- Wed Apr 18 15:22:38 2018 +0000
- Revision:
- 8:0222df74596e
- Parent:
- 7:0ac1f1ca8aa6
- Child:
- 33:5d86c111d9bc
Fixed some compile errors
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nurchu | 2:dc046ff72566 | 1 | #include "Microphone.h" |
Nurchu | 7:0ac1f1ca8aa6 | 2 | #define UINT8_MAX 255 |
Nurchu | 2:dc046ff72566 | 3 | |
Nurchu | 6:7c72902a735f | 4 | Microphone::Microphone (PinName pin): |
Nurchu | 2:dc046ff72566 | 5 | _pin(pin) |
Nurchu | 2:dc046ff72566 | 6 | {} |
Nurchu | 2:dc046ff72566 | 7 | |
Nurchu | 6:7c72902a735f | 8 | float Microphone::read() |
Nurchu | 2:dc046ff72566 | 9 | { |
Nurchu | 2:dc046ff72566 | 10 | return _pin.read(); |
Nurchu | 2:dc046ff72566 | 11 | } |
Nurchu | 2:dc046ff72566 | 12 | |
Nurchu | 6:7c72902a735f | 13 | inline Microphone::operator float () |
Nurchu | 2:dc046ff72566 | 14 | { |
Nurchu | 2:dc046ff72566 | 15 | return _pin.read(); |
Nurchu | 6:7c72902a735f | 16 | } |
Nurchu | 6:7c72902a735f | 17 | |
Nurchu | 6:7c72902a735f | 18 | uint8_t Microphone::getData() |
Nurchu | 6:7c72902a735f | 19 | { |
Nurchu | 7:0ac1f1ca8aa6 | 20 | // This can be better but this should work for now |
Nurchu | 8:0222df74596e | 21 | return (read() - (0.67/3.3)) * UINT8_MAX; |
Nurchu | 2:dc046ff72566 | 22 | } |