Sends compass and accelerometer data, receives data and displays on LED matrix
LedMatrix.cpp
- Committer:
- kinga
- Date:
- 2017-02-20
- Revision:
- 1:17905d919813
- Child:
- 3:5567512e8de7
- Child:
- 6:e316416cae08
File content as of revision 1:17905d919813:
#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; }