ATP3011 is text speech LSI by AquesTalk pico. This librarry supports I2C interface and "printf()" C format. If ATP3011 talk number or alphabet you select printf(), otherwise, you have to use speech(). When you use printf(), the string must have "\n".

Committer:
AkinoriHashimoto
Date:
Mon Oct 19 02:53:39 2015 +0000
Revision:
1:18e2be0c89a4
Parent:
0:f4577c59b4f5
Adj. miss spell.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AkinoriHashimoto 1:18e2be0c89a4 1 /** ATP3011 is Text Speech LSI by AquesTalk.
AkinoriHashimoto 0:f4577c59b4f5 2 * This librarry supports I2C interface and "printf()" C format.
AkinoriHashimoto 0:f4577c59b4f5 3 * If ATP3011 talk number or alphabet you select printf(),
AkinoriHashimoto 1:18e2be0c89a4 4 * otherwise, you have to use speech().
AkinoriHashimoto 0:f4577c59b4f5 5 * When you use printf(), the string must have "\n".
AkinoriHashimoto 0:f4577c59b4f5 6 *
AkinoriHashimoto 1:18e2be0c89a4 7 * @code.
AkinoriHashimoto 0:f4577c59b4f5 8 * I2C i2c(p9, p10);
AkinoriHashimoto 0:f4577c59b4f5 9 * ATP3011 talk(i2c);
AkinoriHashimoto 0:f4577c59b4f5 10 * //or ATP3011 talk(p9, p10);
AkinoriHashimoto 1:18e2be0c89a4 11 * talk.speech("#K");
AkinoriHashimoto 1:18e2be0c89a4 12 * talk.speech("tesu'to.");
AkinoriHashimoto 0:f4577c59b4f5 13 * talk.printf("denwaba'ngo-wa,<NUM VAL=0%d-%d-%d>,desu'.\n", 120, 123, 456);
AkinoriHashimoto 0:f4577c59b4f5 14 * char *chr= "abc123";
AkinoriHashimoto 0:f4577c59b4f5 15 * talk.printf("nyu-ryoku wa <ALPHA VAL=%s> de'su.\n", chr);
AkinoriHashimoto 0:f4577c59b4f5 16 * float dist= 3.14;
AkinoriHashimoto 0:f4577c59b4f5 17 * int lateTime= 7;
AkinoriHashimoto 0:f4577c59b4f5 18 * talk.printf("konosaki;<NUMK VAL=%.2f COUNTER=kiro>/ju-taichu-.tu-kadi'kann wa;<NUMK VAL=%d COUNTER=funn> de'su.\n", dist, lateTime);
AkinoriHashimoto 1:18e2be0c89a4 19 * @endcode
AkinoriHashimoto 0:f4577c59b4f5 20 */
AkinoriHashimoto 0:f4577c59b4f5 21
AkinoriHashimoto 0:f4577c59b4f5 22 #pragma once
AkinoriHashimoto 0:f4577c59b4f5 23
AkinoriHashimoto 0:f4577c59b4f5 24 #include "mbed.h"
AkinoriHashimoto 0:f4577c59b4f5 25
AkinoriHashimoto 0:f4577c59b4f5 26 #define MAX_CHAR 127
AkinoriHashimoto 0:f4577c59b4f5 27
AkinoriHashimoto 0:f4577c59b4f5 28 class ATP3011 : public Stream{
AkinoriHashimoto 0:f4577c59b4f5 29 public:
AkinoriHashimoto 0:f4577c59b4f5 30 ATP3011(PinName sda, PinName scl, char addr = 0x2E<<1);
AkinoriHashimoto 0:f4577c59b4f5 31 ATP3011(I2C &_i2c, char addr = 0x2E<<1);
AkinoriHashimoto 0:f4577c59b4f5 32
AkinoriHashimoto 0:f4577c59b4f5 33 /** Return message.
AkinoriHashimoto 0:f4577c59b4f5 34 */
AkinoriHashimoto 0:f4577c59b4f5 35 static const int SUCCESS, BUSY, READY, TIME_OUT;
AkinoriHashimoto 0:f4577c59b4f5 36 static const int ERR_I2C, ERR_OTHER, ERR_TooLeng;
AkinoriHashimoto 0:f4577c59b4f5 37
AkinoriHashimoto 0:f4577c59b4f5 38 // if you send number or alphabet, you can use printf().
AkinoriHashimoto 1:18e2be0c89a4 39 // oterwise, you have to use speech().
AkinoriHashimoto 0:f4577c59b4f5 40
AkinoriHashimoto 1:18e2be0c89a4 41 /** speech message.
AkinoriHashimoto 0:f4577c59b4f5 42 * @param msg; if string, it's necessaly ".".
AkinoriHashimoto 0:f4577c59b4f5 43 * @param timeout; if 0 ms, func wait to ready without timeout.
AkinoriHashimoto 0:f4577c59b4f5 44 * @return; above Return message.
AkinoriHashimoto 0:f4577c59b4f5 45 */
AkinoriHashimoto 1:18e2be0c89a4 46 int speech(const char *msg, int timeout_ms= 0);
AkinoriHashimoto 0:f4577c59b4f5 47
AkinoriHashimoto 0:f4577c59b4f5 48 /** check Busy.
AkinoriHashimoto 0:f4577c59b4f5 49 * @return; READY, BUSY, ERR_I2C, ERR_OTHER.
AkinoriHashimoto 0:f4577c59b4f5 50 */
AkinoriHashimoto 0:f4577c59b4f5 51 int chkBusy();
AkinoriHashimoto 0:f4577c59b4f5 52
AkinoriHashimoto 0:f4577c59b4f5 53 void init(char _addr);
AkinoriHashimoto 0:f4577c59b4f5 54
AkinoriHashimoto 0:f4577c59b4f5 55
AkinoriHashimoto 0:f4577c59b4f5 56 private:
AkinoriHashimoto 0:f4577c59b4f5 57 char addr;
AkinoriHashimoto 0:f4577c59b4f5 58 I2C i2c;
AkinoriHashimoto 0:f4577c59b4f5 59 Timer timer; // if send or read to ATP3011, timer is reseted.
AkinoriHashimoto 0:f4577c59b4f5 60
AkinoriHashimoto 0:f4577c59b4f5 61 char chr[MAX_CHAR];
AkinoriHashimoto 0:f4577c59b4f5 62 int send(int timeout_ms= 0);
AkinoriHashimoto 0:f4577c59b4f5 63
AkinoriHashimoto 0:f4577c59b4f5 64 // virtual func for printf() in Stream-class.
AkinoriHashimoto 0:f4577c59b4f5 65 virtual int _putc(int val);
AkinoriHashimoto 0:f4577c59b4f5 66 virtual int _getc();
AkinoriHashimoto 0:f4577c59b4f5 67
AkinoriHashimoto 0:f4577c59b4f5 68 void initChar();
AkinoriHashimoto 0:f4577c59b4f5 69 };
AkinoriHashimoto 0:f4577c59b4f5 70
AkinoriHashimoto 0:f4577c59b4f5 71 // EOF