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
Diff: GroveRecorder.cpp
- Revision:
- 0:2d4b0841e58c
diff -r 000000000000 -r 2d4b0841e58c GroveRecorder.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GroveRecorder.cpp Thu Apr 30 19:49:15 2015 +0000
@@ -0,0 +1,45 @@
+#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);
+}
+
\ No newline at end of file
Grove Recorder