Bryce Williams / Mbed 2 deprecated Eyes_Demo

Dependencies:   4DGL-uLCD-SE Eyes_uLCD-144-G2 mbed

Committer:
electromotivated
Date:
Tue Dec 15 00:37:41 2015 +0000
Revision:
0:eaa800959389
update;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
electromotivated 0:eaa800959389 1 /*
electromotivated 0:eaa800959389 2 Eyes Class produces an LCD Object with Eyes that can look around, blink,
electromotivated 0:eaa800959389 3 convey expressions, etc.
electromotivated 0:eaa800959389 4
electromotivated 0:eaa800959389 5 TODO: Replace "wait()" with Thread::wait() so that this isn't eating
electromotivated 0:eaa800959389 6 up processor time!. Maybe could use a Ticker or Timer interrupt
electromotivated 0:eaa800959389 7 but we don't want to call Eye methods until wait is complete...
electromotivated 0:eaa800959389 8 so that probably isn't a good idea... Thread::wait() is probably
electromotivated 0:eaa800959389 9 best for an end application.
electromotivated 0:eaa800959389 10
electromotivated 0:eaa800959389 11 OR add close_eyes to gesture() method and leave it to user to
electromotivated 0:eaa800959389 12 create blink gestures and other gestures that require waits...
electromotivated 0:eaa800959389 13 this can be mentioned in the header and documentation with
electromotivated 0:eaa800959389 14 solutions the user can use.
electromotivated 0:eaa800959389 15 */
electromotivated 0:eaa800959389 16
electromotivated 0:eaa800959389 17 #include "mbed.h"
electromotivated 0:eaa800959389 18 #include "Eyes.h"
electromotivated 0:eaa800959389 19
electromotivated 0:eaa800959389 20
electromotivated 0:eaa800959389 21 Eyes eyes(p28, p27, p30); // serial tx, serial rx, reset pin;
electromotivated 0:eaa800959389 22 int main() {
electromotivated 0:eaa800959389 23 while(1){
electromotivated 0:eaa800959389 24 int dir = rand()%10;
electromotivated 0:eaa800959389 25 Eyes::DIRECTION direction;
electromotivated 0:eaa800959389 26 switch(dir){
electromotivated 0:eaa800959389 27 case 0:
electromotivated 0:eaa800959389 28 direction = Eyes::U;
electromotivated 0:eaa800959389 29 break;
electromotivated 0:eaa800959389 30 case 1:
electromotivated 0:eaa800959389 31 direction = Eyes::D;
electromotivated 0:eaa800959389 32 break;
electromotivated 0:eaa800959389 33 case 2:
electromotivated 0:eaa800959389 34 direction = Eyes::L;
electromotivated 0:eaa800959389 35 break;
electromotivated 0:eaa800959389 36 case 3:
electromotivated 0:eaa800959389 37 direction = Eyes::R;
electromotivated 0:eaa800959389 38 break;
electromotivated 0:eaa800959389 39 case 4:
electromotivated 0:eaa800959389 40 direction = Eyes::C;
electromotivated 0:eaa800959389 41 break;
electromotivated 0:eaa800959389 42 case 5:
electromotivated 0:eaa800959389 43 direction = Eyes::UL;
electromotivated 0:eaa800959389 44 break;
electromotivated 0:eaa800959389 45 case 6:
electromotivated 0:eaa800959389 46 direction = Eyes::UR;
electromotivated 0:eaa800959389 47 break;
electromotivated 0:eaa800959389 48 case 7:
electromotivated 0:eaa800959389 49 direction = Eyes::DL;
electromotivated 0:eaa800959389 50 break;
electromotivated 0:eaa800959389 51 case 8:
electromotivated 0:eaa800959389 52 direction = Eyes::DR;
electromotivated 0:eaa800959389 53 break;
electromotivated 0:eaa800959389 54 }
electromotivated 0:eaa800959389 55 eyes.look(direction);
electromotivated 0:eaa800959389 56 eyes.draw(); // Call this after calling look() or express()
electromotivated 0:eaa800959389 57 wait((rand()%10 + 1)*0.40);
electromotivated 0:eaa800959389 58 eyes.gesture(Eyes::BLINK);
electromotivated 0:eaa800959389 59 wait((rand()%10 + 1)*0.25);
electromotivated 0:eaa800959389 60 if(rand()%2) eyes.gesture(Eyes::CLOSE);
electromotivated 0:eaa800959389 61 wait((rand()%10 + 1)*0.25);
electromotivated 0:eaa800959389 62 }
electromotivated 0:eaa800959389 63 }