Camera program for buzz booth

Dependencies:   JPEGCamera mbed

Committer:
bfoley13
Date:
Tue Dec 08 00:41:58 2015 +0000
Revision:
0:a9083c11b10b
Camera for buzz booth

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bfoley13 0:a9083c11b10b 1 #define speakf printf
bfoley13 0:a9083c11b10b 2 class emic2 : public Stream
bfoley13 0:a9083c11b10b 3 {
bfoley13 0:a9083c11b10b 4 public :
bfoley13 0:a9083c11b10b 5 emic2(PinName tx, PinName rx): _cmd(tx,rx) {
bfoley13 0:a9083c11b10b 6 _cmd.baud(9600);
bfoley13 0:a9083c11b10b 7 _cmd.putc('X'); //stop talking if reset and not a power on
bfoley13 0:a9083c11b10b 8 _cmd.putc('\r'); // Send a CR in case the system is already up
bfoley13 0:a9083c11b10b 9 wait(1); //delay for emic power on boot or reset respone
bfoley13 0:a9083c11b10b 10 while (_cmd.getc() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':'
bfoley13 0:a9083c11b10b 11 while (_cmd.readable()) _cmd.getc();//flush out buffer just in case
bfoley13 0:a9083c11b10b 12 };
bfoley13 0:a9083c11b10b 13 void ready() {
bfoley13 0:a9083c11b10b 14 while (_cmd.getc() != ':');
bfoley13 0:a9083c11b10b 15 while (_cmd.readable()) _cmd.getc();//flush out recieve buffer just in case
bfoley13 0:a9083c11b10b 16 };
bfoley13 0:a9083c11b10b 17 int readable() {
bfoley13 0:a9083c11b10b 18 return _cmd.readable();
bfoley13 0:a9083c11b10b 19 };
bfoley13 0:a9083c11b10b 20 int getc() {
bfoley13 0:a9083c11b10b 21 return _cmd.getc();
bfoley13 0:a9083c11b10b 22 }
bfoley13 0:a9083c11b10b 23 void volume(int x) {
bfoley13 0:a9083c11b10b 24 speakf("V%D\r",x);
bfoley13 0:a9083c11b10b 25 ready();
bfoley13 0:a9083c11b10b 26 }
bfoley13 0:a9083c11b10b 27 void voice(int x) {
bfoley13 0:a9083c11b10b 28 speakf("N%D\r",x);
bfoley13 0:a9083c11b10b 29 ready();
bfoley13 0:a9083c11b10b 30 }
bfoley13 0:a9083c11b10b 31 protected :
bfoley13 0:a9083c11b10b 32 Serial _cmd;
bfoley13 0:a9083c11b10b 33 //used by printf - supply it and printf works!
bfoley13 0:a9083c11b10b 34 virtual int _putc(int c) {
bfoley13 0:a9083c11b10b 35 _cmd.putc(c);
bfoley13 0:a9083c11b10b 36 return 0;
bfoley13 0:a9083c11b10b 37 };
bfoley13 0:a9083c11b10b 38 virtual int _getc() {
bfoley13 0:a9083c11b10b 39 return -1;
bfoley13 0:a9083c11b10b 40 };
bfoley13 0:a9083c11b10b 41 };
bfoley13 0:a9083c11b10b 42