Brian Daniels / ISD1820P

Dependents:   Seeed_Grove_Recorder_Example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ISD1820P.cpp Source File

ISD1820P.cpp

00001 #include "ISD1820P.h"
00002 
00003 ISD1820P::ISD1820P(PinName recordPin, PinName playPin)
00004         : maxSoundTime(defaultMaxSoundTime), record(recordPin, 0), play(playPin, 0) {
00005     // Empty
00006 }
00007 
00008 void ISD1820P::stopRecording() {
00009     record = 0;
00010 }
00011 
00012 void ISD1820P::startRecording(float time) {
00013     if (!record) {
00014         if (time > maxSoundTime) {
00015             time = maxSoundTime;
00016         }        
00017         
00018         record = 1;
00019         recordTimeout.attach(this, &ISD1820P::stopRecording, time);
00020     }
00021 }
00022 
00023 void ISD1820P::startRecordingMaxTime() {
00024     startRecording(maxSoundTime);
00025 }
00026 
00027 void ISD1820P::stopPlaying() {
00028     play = 0;
00029 }
00030 
00031 void ISD1820P::startPlaying(float time) {
00032     if (!play && !record) {
00033         if (time > maxSoundTime) {
00034             time = maxSoundTime;
00035         }
00036         
00037         play = 1;
00038         playTimeout.attach(this, &ISD1820P::stopPlaying, time);
00039     }
00040 }
00041 
00042 void ISD1820P::startPlayingMaxTime() {
00043     startPlaying(maxSoundTime);
00044 }
00045