SP03 Text to Speech Synthesizer

Revision:
1:58ab657cd515
Parent:
0:2326b6172834
Child:
2:4090898287d5
--- a/SP03.h	Wed May 07 13:52:08 2014 +0000
+++ b/SP03.h	Mon Mar 07 14:38:55 2016 +0000
@@ -1,33 +1,66 @@
 #ifndef Smartlab_Drive_SP03
 #define Smartlab_Drive_SP03
 
-#include "SP03SpeechSetting.h"
 #include "mbed.h"
 
 class SP03
 {
 private:
-    static const uint8_t DEFAULT_ADDRESS = 0xC4;
+    static const char DEFAULT_ADDRESS = 0xC4;
     static const int CLOCK_RATE = 100000;
-    static const uint8_t REGISTER_FOR_COMMAND = 0x00;
-    static const uint8_t REGISTER_FOR_SOFTWARE_REVISION_NUMBER = 0x01;
-    static const uint8_t SPEAK_OUT_THE_BUFFER = 0x40;
-    static const uint8_t DEFAULT_SPEECH_PITCH = 0x03;
+    static const char REGISTER_FOR_COMMAND = 0x00;
+    static const char REGISTER_FOR_SOFTWARE_REVISION_NUMBER = 0x01;
+    static const char SPEAK_OUT_THE_BUFFER = 0x40;
+
+    static const char DEFAULT_SPEECH_PITCH = 0x03;
+    
+    char _volume;
+    
+    char _speed;
 
     I2C i2c_bus;
-
-    void _speak(const char message[],SmartLab_SP03::Speech_Speed speed, SmartLab_SP03::Speech_Volume volume,uint8_t pitch);
 public :
 
+    static const char SPEED_NORMAL  = 0x05;
+    static const char SPEED_FAST = 0x02;
+    static const char SPEED_SLOW = 0x06;
+
+    static const char VOLUME_MAX = 0x00;
+    static const char VOLUME_MEDIUM = 0x03;
+    static const char VOLUME_MIN = 0x06;
+
+    /** Construct
+     *
+     * @param sda I2C sda signal
+     * @param scl I2C scl signal
+     */
     SP03(PinName sda, PinName scl);
 
-    void Speak(const char message[]);
+    /** Set the speed of the speech
+     *
+     * @param message NULL terminated char array
+     */
+    void speak(const char * message);
+
+    /** Set the speed of the speech
+     *
+     * @param speed [SPEED_NORMAL = 0x05, SPEED_FAST = 0x02, SPEED_SLOW = 0x06]
+     */
+    void setSpeed(char speed);
 
-    void Speak(const char message[],SmartLab_SP03::Speech_Speed speed, SmartLab_SP03::Speech_Volume volume);
-    
-    void Speak(const char message[],SmartLab_SP03::Speech_Speed speed, SmartLab_SP03::Speech_Volume volume,uint8_t pitch);
-    
-    bool IsSpeaking();
+    /** Set the volume of the speech
+     *
+     * @param volume [VOLUME_MAX = 0x00, VOLUME_MEDIUM = 0x03, VOLUME_MIN = 0x06]
+     */
+    void setVolume(char volume);
+
+    /** Check if the SP03 is currently talking
+     *
+     * @returns
+     *  ture device is talking and no command can be send,
+     *  false command can be issued
+     */
+    bool isSpeaking();
 };
 
 #endif
\ No newline at end of file