Sends compass and accelerometer data, receives data and displays on LED matrix

Dependencies:   microbit

Revision:
1:17905d919813
Child:
3:5567512e8de7
Child:
6:e316416cae08
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LedMatrix.cpp	Mon Feb 20 09:12:41 2017 +0000
@@ -0,0 +1,51 @@
+#include "LedMatrix.h"
+
+LedMatrix::LedMatrix()
+{
+    //ledMatrix = vector<vector<int> >(5, vector<int>(5, 0));
+    for (int i = 0; i < 5; ++i)
+    {
+        vector<int> temp;
+        
+        for (int j = 0; j < 5; ++j)
+        {
+            temp.push_back(0);
+        }
+        ledMatrix.push_back(temp);
+    }
+}
+
+/*void LedMatrix::setLedMatrix(ManagedString data)
+{
+    int row, col;
+    row = (int)data.charAt(0);
+    col = (int)data.charAt(1);
+    ledMatrix[row][col] == 0 ? ledMatrix[row][col] = 1 : ledMatrix[row][col] = 0;
+}*/
+
+void LedMatrix::setLedMatrix(int row, int col)
+{
+    ledMatrix[row][col] = ledMatrix[row][col] == 0 ? 1 : 0;
+}
+
+MicroBitImage LedMatrix::getMatrixImage()
+{
+    char* ledStatus;
+    
+    for (int i = 0; i < 5; ++i)
+    {
+        for (int j = 0; j < 5; ++j)
+        {
+            if (j != 4)
+            {
+                ledStatus = ledStatus + (ledMatrix[i][j] == 0 ? '0': '1') + ',';
+            }
+            else
+            {
+                ledStatus = ledStatus + (ledMatrix[i][j] == 0 ? '0': '1') + '\n';
+            }
+        }
+    }
+    MicroBitImage matrixImage(ledStatus);
+    return matrixImage;
+}
\ No newline at end of file