Jay Balar / Mbed 2 deprecated 4180_Project_3

Dependencies:   4DGL-uLCD-SE Physac-MBED PinDetect SDFileSystem mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bluefruit_controller.h Source File

bluefruit_controller.h

00001 
00002 #ifndef __BLUEFRUIT_CONTROLLER_HPP
00003 #define __BLUEFRUIT_CONTROLLER_HPP
00004 
00005 #include "mbed.h"
00006 
00007 enum ButtonId {
00008     BUTTON_A = 0,
00009     BUTTON_B = 1,
00010     BUTTON_X = 2,
00011     BUTTON_Y = 3,
00012     BUTTON_UP = 4,
00013     BUTTON_DOWN = 5,
00014     BUTTON_LEFT = 6,
00015     BUTTON_RIGHT = 7
00016 };
00017 
00018 /**
00019  * \brief Encapsulates the controller functionality of the Bluefruit module
00020  *      through the default app.
00021  */
00022 class BluefruitController : public Serial
00023 {
00024 public:
00025     BluefruitController(PinName tx, PinName rx, int baud = 9600);
00026 
00027     void parseMessage();
00028 
00029     void reset();
00030 
00031     float quaternion[4];
00032     bool button[8];
00033 
00034 private:
00035     static const int BUFFER_SIZE = 20;
00036 
00037     void parseButton();
00038     void parseQuaternion();
00039 
00040     /// Holds the parse state
00041     int state;
00042     char msg_tag;
00043     
00044     // Buffer in which messages are read
00045     char buff[BUFFER_SIZE];
00046     int buff_i;
00047     int buff_len;
00048 };
00049 
00050 #endif