Elements used in the Balls and Things games for the RETRO.
Dependents: RETRO_BallsAndPaddle RETRO_BallAndHoles
Diff: Accelerometer.cpp
- Revision:
- 1:71185a0aadfc
- Parent:
- 0:3d0db4e183ee
--- a/Accelerometer.cpp Fri Feb 06 09:51:06 2015 +0000 +++ b/Accelerometer.cpp Fri Feb 06 10:18:02 2015 +0000 @@ -11,11 +11,10 @@ this->colors[2] = Color565::Blue; } -void Accelerometer::readRegisters(char address, char* buffer, int len) { -// int nStart=this->tWait.read_ms(); +void Accelerometer::readRegisters(char address, char* buffer, int len) +{ this->i2c.write(i2cAddress, &address, 1, true); this->i2c.read(i2cAddress | 1, buffer, len); -// printDouble((double)this->tWait.read_ms()-nStart, 10, 10); } int Accelerometer::writeRegister(char address, char value) { @@ -24,7 +23,8 @@ return this->i2c.write(i2cAddress, buffer, 2); } -double Accelerometer::convert(char* buffer) { +double Accelerometer::convert(char* buffer) +{ double val = ((buffer[0] << 2) | (buffer[1] >> 6)); if (val > 511.0) @@ -76,7 +76,6 @@ { this->graphX = 0; this->pDisp->clearScreen(); - //this->pDisp->fillRect(0, 0, this->pDisp->getWidth(), this->pDisp->getHeight(), Color565::fromRGB(0x11, 0x33, 0x22)); this->drawAxes(); } @@ -99,4 +98,3 @@ this->drawPoint(2, z); this->graphX++; } -