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.
Dependents: Seeed_Grove_Recorder_Example
GroveRecorder.cpp
- Committer:
- bridadan
- Date:
- 2015-04-30
- Revision:
- 0:2d4b0841e58c
File content as of revision 0:2d4b0841e58c:
#include "GroveRecorder.h"
GroveRecorder::GroveRecorder(PinName recordPin, PinName playPin)
: maxSoundTime(defaultMaxSoundTime), record(recordPin, 0), play(playPin, 0) {
// Empty
}
void GroveRecorder::stopRecording() {
record = 0;
}
void GroveRecorder::startRecording(float time) {
if (!record) {
if (time > maxSoundTime) {
time = maxSoundTime;
}
record = 1;
recordTimeout.attach(this, &GroveRecorder::stopRecording, time);
}
}
void GroveRecorder::startRecordingMaxTime() {
startRecording(maxSoundTime);
}
void GroveRecorder::stopPlaying() {
play = 0;
}
void GroveRecorder::startPlaying(float time) {
if (!play && !record) {
if (time > maxSoundTime) {
time = maxSoundTime;
}
play = 1;
playTimeout.attach(this, &GroveRecorder::stopPlaying, time);
}
}
void GroveRecorder::startPlayingMaxTime() {
startPlaying(maxSoundTime);
}
Grove Recorder