Security System

Dependencies:   mbed ID12RFID TextLCD keypad

Committer:
mabelliard
Date:
Sun Nov 28 23:21:59 2021 +0000
Revision:
1:43e6a97f7d4d
A

Who changed what in which revision?

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