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

Dependencies:   microbit

Revision:
8:c0e98b2fc93a
Parent:
7:e3d1f064894b
--- a/main.cpp	Thu Feb 23 15:37:20 2017 +0000
+++ b/main.cpp	Fri Feb 24 13:16:04 2017 +0000
@@ -43,15 +43,11 @@
     serial.send(getMessage(), ASYNC);
 }  
 
-void switchLedMatrix(LedMatrix matrix)
+void switchLedMatrix(ManagedString buffer, LedMatrix& myLedMatrix)
 {
-    ManagedString buffer = readData();
     int offsetToGetInt = 48;
-    if (buffer.length() != 0)
-    {
-        matrix.setLedMatrix((int)buffer.charAt(0) - offsetToGetInt, (int)buffer.charAt(1) - offsetToGetInt);
-        uBit.display.print(matrix.getMatrixImage());
-    }
+    myLedMatrix.setLedMatrix((int)buffer.charAt(0) - offsetToGetInt, (int)buffer.charAt(1) - offsetToGetInt);
+    uBit.display.print(myLedMatrix.getMatrixImage());
 }
 
 
@@ -61,7 +57,11 @@
     LedMatrix myLedMatrix;
     while(1)
     {   
-        switchLedMatrix(myLedMatrix);
+        ManagedString buffer = readData();
+        if (buffer.length() != 0)
+        {
+            switchLedMatrix(buffer, myLedMatrix);
+        }
         sendData();
         uBit.sleep(500);
     }