Sends compass and accelerometer data, receives data and displays on LED matrix
Diff: LedMatrix.cpp
- Revision:
- 3:5567512e8de7
- Parent:
- 1:17905d919813
- Child:
- 4:7f5e478f945c
--- a/LedMatrix.cpp Mon Feb 20 09:33:31 2017 +0000 +++ b/LedMatrix.cpp Mon Feb 20 15:26:27 2017 +0000 @@ -30,7 +30,7 @@ MicroBitImage LedMatrix::getMatrixImage() { - char* ledStatus; + char* ledStatus = new char[50]; for (int i = 0; i < 5; ++i) { @@ -38,11 +38,13 @@ { if (j != 4) { - ledStatus = ledStatus + (ledMatrix[i][j] == 0 ? '0': '1') + ','; + ledStatus[i*10 + j*2] = (ledMatrix[i][j] == 0 ? '0' : '1'); + ledStatus[i*10 + j*2 + 1] = ','; } else { - ledStatus = ledStatus + (ledMatrix[i][j] == 0 ? '0': '1') + '\n'; + ledStatus[i*10 + j*2] = (ledMatrix[i][j] == 0 ? '0' : '1'); + ledStatus[i*10 + j*2 + 1] = '\n'; } } }