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: 4DGL-uLCD-SE PinDetect SDFileSystem Speaker TextLCD mbed wave_player
Fork of musicplayer by
Diff: EasyVR.cpp
- Revision:
- 2:84f06fb95343
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/EasyVR.cpp Mon Mar 14 23:31:18 2016 +0000
@@ -0,0 +1,59 @@
+#pragma once
+#include "EasyVR.h"
+
+EasyVR::EasyVR(PinName tx,PinName rx):_easyVR(tx,rx)
+{
+}
+
+EasyVR::~EasyVR()
+{
+}
+
+void EasyVR::sendCmd(uint8_t c)
+{
+ _easyVR.putc(c);
+ wait(0.001);
+}
+
+void EasyVR::sendArg(int8_t c)
+{
+ _easyVR.putc(c + ARG_ZERO);
+ wait(0.001);
+}
+
+int8_t EasyVR::recv(int8_t time)
+{
+ while(!_easyVR.readable() && time != 0)
+ {
+ if(time>0)
+ time--;
+ wait(0.001);
+ }
+ return _easyVR.getc();
+}
+
+void EasyVR::decrypt(char* arg)
+{
+ *arg = *arg - ARG_ZERO;
+}
+
+bool EasyVR::awake(int timeOut)
+{
+ bool isAwake=0;
+
+ while (timeOut>0)
+ {
+ _easyVR.putc(CMD_BREAK);
+ if(_easyVR.getc()==CMD_TIMEOUT)
+ {
+ isAwake = 1;
+ }
+
+ if(timeOut>0)
+ {
+ timeOut--;
+ }
+ wait(0.001);
+ }
+ return isAwake;
+}
\ No newline at end of file
