Sound update

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

Revision:
12:5d913b57da7c
diff -r e00a208bd85a -r 5d913b57da7c bluefruit_controller.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluefruit_controller.h	Wed Nov 30 21:20:21 2022 +0000
@@ -0,0 +1,50 @@
+
+#ifndef __BLUEFRUIT_CONTROLLER_HPP
+#define __BLUEFRUIT_CONTROLLER_HPP
+
+#include "mbed.h"
+
+enum ButtonId {
+    BUTTON_A = 0,
+    BUTTON_B = 1,
+    BUTTON_X = 2,
+    BUTTON_Y = 3,
+    BUTTON_UP = 4,
+    BUTTON_DOWN = 5,
+    BUTTON_LEFT = 6,
+    BUTTON_RIGHT = 7
+};
+
+/**
+ * \brief Encapsulates the controller functionality of the Bluefruit module
+ *      through the default app.
+ */
+class BluefruitController : public Serial
+{
+public:
+    BluefruitController(PinName tx, PinName rx, int baud = 9600);
+
+    void parseMessage();
+
+    void reset();
+
+    float quaternion[4];
+    bool button[8];
+
+private:
+    static const int BUFFER_SIZE = 20;
+
+    void parseButton();
+    void parseQuaternion();
+
+    /// Holds the parse state
+    int state;
+    char msg_tag;
+    
+    // Buffer in which messages are read
+    char buff[BUFFER_SIZE];
+    int buff_i;
+    int buff_len;
+};
+
+#endif