智也 大野
/
HeptaXbee_CountUp
Xbee countUP
Fork of HeptaXbee_CountUp by
hepta_sat/HeptaVoice.h@0:0a7fa0911e6c, 2016-12-09 (annotated)
- Committer:
- tomoya123
- Date:
- Fri Dec 09 04:58:00 2016 +0000
- Revision:
- 0:0a7fa0911e6c
Xbee CountUP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tomoya123 | 0:0a7fa0911e6c | 1 | #include "mbed.h" |
tomoya123 | 0:0a7fa0911e6c | 2 | |
tomoya123 | 0:0a7fa0911e6c | 3 | #pragma once |
tomoya123 | 0:0a7fa0911e6c | 4 | |
tomoya123 | 0:0a7fa0911e6c | 5 | #define AQTK_I2C_ADDR (0x2E<<1) |
tomoya123 | 0:0a7fa0911e6c | 6 | #define AQTK_STARTUP_WAIT_MS 80 |
tomoya123 | 0:0a7fa0911e6c | 7 | #define AQTK_POLL_WAIT_MS 10 |
tomoya123 | 0:0a7fa0911e6c | 8 | |
tomoya123 | 0:0a7fa0911e6c | 9 | /** HeptaVoice class |
tomoya123 | 0:0a7fa0911e6c | 10 | * |
tomoya123 | 0:0a7fa0911e6c | 11 | * AquesTalk pico LSI I2C interface |
tomoya123 | 0:0a7fa0911e6c | 12 | * Example: |
tomoya123 | 0:0a7fa0911e6c | 13 | * @code |
tomoya123 | 0:0a7fa0911e6c | 14 | * #include "HeptaVoice.h" |
tomoya123 | 0:0a7fa0911e6c | 15 | * HeptaVoice talk(P0_10,P0_11); // I2C sda scl |
tomoya123 | 0:0a7fa0911e6c | 16 | * |
tomoya123 | 0:0a7fa0911e6c | 17 | * int main() { |
tomoya123 | 0:0a7fa0911e6c | 18 | * talk.Synthe("konnichiwa."); |
tomoya123 | 0:0a7fa0911e6c | 19 | * for(int n = 1; ; n++) { |
tomoya123 | 0:0a7fa0911e6c | 20 | * char buf[32]; |
tomoya123 | 0:0a7fa0911e6c | 21 | * snprintf(buf, sizeof(buf), "<NUMK VAL=%d>.", n); |
tomoya123 | 0:0a7fa0911e6c | 22 | * talk.Synthe(buf); |
tomoya123 | 0:0a7fa0911e6c | 23 | * } |
tomoya123 | 0:0a7fa0911e6c | 24 | * } |
tomoya123 | 0:0a7fa0911e6c | 25 | * @endcode |
tomoya123 | 0:0a7fa0911e6c | 26 | * |
tomoya123 | 0:0a7fa0911e6c | 27 | */ |
tomoya123 | 0:0a7fa0911e6c | 28 | class HeptaVoice { |
tomoya123 | 0:0a7fa0911e6c | 29 | public: |
tomoya123 | 0:0a7fa0911e6c | 30 | /** Create a AquesTalk pico LSI I2C interface |
tomoya123 | 0:0a7fa0911e6c | 31 | * |
tomoya123 | 0:0a7fa0911e6c | 32 | * @param sda I2C data pin |
tomoya123 | 0:0a7fa0911e6c | 33 | * @param scl I2C clock pin |
tomoya123 | 0:0a7fa0911e6c | 34 | * @param addr I2C address |
tomoya123 | 0:0a7fa0911e6c | 35 | */ |
tomoya123 | 0:0a7fa0911e6c | 36 | HeptaVoice(PinName sda, PinName scl, int addr = AQTK_I2C_ADDR); |
tomoya123 | 0:0a7fa0911e6c | 37 | bool IsActive(int timeout_ms = 500); |
tomoya123 | 0:0a7fa0911e6c | 38 | void Synthe(const char* msg); |
tomoya123 | 0:0a7fa0911e6c | 39 | void Write(const char* msg); |
tomoya123 | 0:0a7fa0911e6c | 40 | bool IsBusy(); |
tomoya123 | 0:0a7fa0911e6c | 41 | private: |
tomoya123 | 0:0a7fa0911e6c | 42 | int _addr; |
tomoya123 | 0:0a7fa0911e6c | 43 | I2C _i2c; |
tomoya123 | 0:0a7fa0911e6c | 44 | Timer _poll_wait; |
tomoya123 | 0:0a7fa0911e6c | 45 | }; |