Sends compass and accelerometer data, receives data and displays on LED matrix
LedMatrix.cpp
- Committer:
- kinga
- Date:
- 2017-02-20
- Revision:
- 3:5567512e8de7
- Parent:
- 1:17905d919813
- Child:
- 4:7f5e478f945c
File content as of revision 3:5567512e8de7:
#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 = new char[50]; for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { if (j != 4) { ledStatus[i*10 + j*2] = (ledMatrix[i][j] == 0 ? '0' : '1'); ledStatus[i*10 + j*2 + 1] = ','; } else { ledStatus[i*10 + j*2] = (ledMatrix[i][j] == 0 ? '0' : '1'); ledStatus[i*10 + j*2 + 1] = '\n'; } } } MicroBitImage matrixImage(ledStatus); return matrixImage; }