Library for googly eyes

Dependents:   Eyes_Demo

Committer:
electromotivated
Date:
Tue Dec 15 00:42:09 2015 +0000
Revision:
1:0791bb5735b4
Parent:
0:06df44729143
Child:
2:9dd81fc2623f
Added notes;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
electromotivated 0:06df44729143 1 /*
electromotivated 0:06df44729143 2 Library for the 4DGL uLCD-144-G2 LCD Display that Makes and
electromotivated 0:06df44729143 3 Contols Eyes.
electromotivated 0:06df44729143 4
electromotivated 0:06df44729143 5 TODO: Allow user to define eye color, size, etc.
electromotivated 0:06df44729143 6 Allow user to adjust serial baudrate, etc.
electromotivated 1:0791bb5735b4 7 Fix memory leak? LCD stops working and displays
electromotivated 1:0791bb5735b4 8 some weird stuff after running for awhile, this
electromotivated 1:0791bb5735b4 9 needs fixin'
electromotivated 0:06df44729143 10 */
electromotivated 0:06df44729143 11
electromotivated 0:06df44729143 12 #ifndef EYES_H
electromotivated 0:06df44729143 13 #define EYES_H
electromotivated 0:06df44729143 14
electromotivated 0:06df44729143 15 #include "mbed.h"
electromotivated 0:06df44729143 16 #include "uLCD_4DGL.h"
electromotivated 0:06df44729143 17 #include "Timeout.h"
electromotivated 0:06df44729143 18
electromotivated 0:06df44729143 19 class Eyes{
electromotivated 0:06df44729143 20 public:
electromotivated 0:06df44729143 21 enum EXPRESSION{NORMAL, SUPRISED, SCARED, ANGRY};
electromotivated 0:06df44729143 22 enum DIRECTION{U = 270, D = 90, L = 0, R = 180, C,
electromotivated 0:06df44729143 23 UL= 315, UR= 225,DL= 45, DR = 135};
electromotivated 0:06df44729143 24 enum GESTURE{BLINK, CLOSE};
electromotivated 0:06df44729143 25 typedef struct{int x; int y;}Coord_t;
electromotivated 0:06df44729143 26
electromotivated 0:06df44729143 27 /*
electromotivated 0:06df44729143 28 Constructor for Eyes Objects
electromotivated 0:06df44729143 29 */
electromotivated 0:06df44729143 30 Eyes(PinName tx, PinName rx, PinName reset);
electromotivated 0:06df44729143 31
electromotivated 0:06df44729143 32 /*
electromotivated 0:06df44729143 33 Change the active direction eyes look.
electromotivated 0:06df44729143 34 @param direction The direction to look
electromotivated 0:06df44729143 35 */
electromotivated 0:06df44729143 36 void look(DIRECTION direction);
electromotivated 0:06df44729143 37
electromotivated 0:06df44729143 38 /*
electromotivated 0:06df44729143 39 Display a gesture.
electromotivated 0:06df44729143 40
electromotivated 0:06df44729143 41 BLINK is random ~100 to ~400ms. For user defined blink duration
electromotivated 0:06df44729143 42 call CLOSE, then draw() some user defined time later.
electromotivated 0:06df44729143 43
electromotivated 0:06df44729143 44 NOTE: Some gestures use a timer interrupt to make a
electromotivated 0:06df44729143 45 callback to complete a gesture, such as BLINK. Although this should
electromotivated 0:06df44729143 46 be ok, as the draw method is called on the interrupt and simply
electromotivated 0:06df44729143 47 redraws eyes with current setting, the user should be aware if they
electromotivated 0:06df44729143 48 are getting some weird side effects.
electromotivated 0:06df44729143 49
electromotivated 0:06df44729143 50 @param gesture The gesture to display
electromotivated 0:06df44729143 51 */
electromotivated 0:06df44729143 52 void gesture(GESTURE gesture);
electromotivated 0:06df44729143 53
electromotivated 0:06df44729143 54 /*
electromotivated 0:06df44729143 55 Draw eyes conveying given expression (keeps current look direction)
electromotivated 0:06df44729143 56 @param expression The expression of the eyes
electromotivated 0:06df44729143 57 */
electromotivated 0:06df44729143 58 void express(EXPRESSION expression);
electromotivated 0:06df44729143 59
electromotivated 0:06df44729143 60 /*
electromotivated 0:06df44729143 61 Draw Eyes. Uses the currently active direction and expression.
electromotivated 0:06df44729143 62 Call this after calling express() and or look() methods, this
electromotivated 0:06df44729143 63 allows greater flexibility to user and reduces calls to draw
electromotivated 0:06df44729143 64 as user can set both expression and direction and make a single
electromotivated 0:06df44729143 65 call to draw.
electromotivated 0:06df44729143 66 */
electromotivated 0:06df44729143 67 void draw();
electromotivated 0:06df44729143 68
electromotivated 0:06df44729143 69 private:
electromotivated 0:06df44729143 70 uLCD_4DGL lcd; // serial tx, serial rx, reset pin;
electromotivated 0:06df44729143 71 Timeout callback_timer;
electromotivated 0:06df44729143 72
electromotivated 0:06df44729143 73 EXPRESSION active_expression;
electromotivated 0:06df44729143 74 DIRECTION active_direction;
electromotivated 0:06df44729143 75 /*TODO: Make these user defined*/
electromotivated 0:06df44729143 76 int eye_radius;
electromotivated 0:06df44729143 77 int iris_radius;
electromotivated 0:06df44729143 78 int pupil_radius;
electromotivated 0:06df44729143 79 /******************************/
electromotivated 0:06df44729143 80 Coord_t right_eye_center;
electromotivated 0:06df44729143 81 Coord_t left_eye_center;
electromotivated 0:06df44729143 82 Coord_t eye_direction_offset; // Updated by look direction
electromotivated 0:06df44729143 83 // Used to apply an offset to
electromotivated 0:06df44729143 84 // iris and pupils to make
electromotivated 0:06df44729143 85 // eyes look in a direction
electromotivated 0:06df44729143 86 };
electromotivated 0:06df44729143 87
electromotivated 0:06df44729143 88 #endif