Elements used in the Balls and Things games for the RETRO.
Dependents: RETRO_BallsAndPaddle RETRO_BallAndHoles
Revision 1:71185a0aadfc, committed 2015-02-06
- Comitter:
- maxint
- Date:
- Fri Feb 06 10:18:02 2015 +0000
- Parent:
- 0:3d0db4e183ee
- Child:
- 2:74bc9b16fb88
- Commit message:
- tiny bit of cleanup
Changed in this revision
--- 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++; } -
--- a/SoundFX.h Fri Feb 06 09:51:06 2015 +0000 +++ b/SoundFX.h Fri Feb 06 10:18:02 2015 +0000 @@ -6,7 +6,6 @@ { public: SoundFX(); - void checkPwm(); void reset(); void beep(int nDuration=1); void beepShort(); @@ -20,12 +19,6 @@ void musicCompleted(void); private: - static const int BOUNCE1_SOUND_TICKS = 1; - static const int BOUNCE2_SOUND_TICKS = 2; - -// PwmOut pwm; -// int pwmTicksLeft; bool fMute; MusicEngine music; - };
--- a/SoundFx.cpp Fri Feb 06 09:51:06 2015 +0000 +++ b/SoundFx.cpp Fri Feb 06 10:18:02 2015 +0000 @@ -1,49 +1,19 @@ #include "SoundFX.h" -SoundFX::SoundFX() : -// pwm(P0_18), - music(P0_18) +SoundFX::SoundFX() : music(P0_18) { -// this->pwmTicksLeft=0; this->fMute=false; music.setCompletionCallback(this, &SoundFX::musicCompleted); } -void SoundFX::checkPwm() -{ -/* - if(this->fMute || this->pwmTicksLeft == 0) - this->pwm.write(0.0); - else - { - this->pwmTicksLeft--; - this->pwm.write(0.5); - } -*/ -} - void SoundFX::musicCompleted(void) { -/* - PwmOut pwm(P0_18); - pwm = 0.0; - pwm.period(0.1); - pwm.write(0.00); -*/ + } void SoundFX::reset() { -/* - this->pwmTicksLeft=0; - this->pwm.period_ms(1); - this->pwm.write(0.00); -*/ -/* - PwmOut pwm(P0_18); - pwm.write(0.00); -*/ } void SoundFX::setMute(bool fMute) @@ -62,17 +32,14 @@ { if(this->fMute) return; -// this->pwmTicksLeft = nDuration; + music.play("T240 L16 O6 C"); } void SoundFX::beepShort() { if(this->fMute) return; -/* - this->pwm.period_ms(2); - this->pwmTicksLeft = SoundFX::BOUNCE1_SOUND_TICKS; -*/ + music.play("T240 L32 O6 C"); } @@ -80,11 +47,6 @@ { if(this->fMute) return; - -/* - this->pwm.period_ms(1); - this->pwmTicksLeft = SoundFX::BOUNCE2_SOUND_TICKS; -*/ music.play("T240 L8 O5 C"); } @@ -92,12 +54,6 @@ { if(this->fMute) return; -/* - this->pwm.period(1.0/220); - this->pwm.write(0.5); - wait_ms(150); - this->pwm.write(0.0); -*/ music.play("T180 L4 O3 C"); } @@ -112,22 +68,6 @@ { if(this->fMute) return; -/* - this->pwm.period(1.0/220); - this->pwm.write(0.5); - wait_ms(150); - this->pwm.write(0.0); - - this->pwm.period(1.0/196); - this->pwm.write(0.5); - wait_ms(150); - this->pwm.write(0.0); - - this->pwm.period(1.0/164.81); - this->pwm.write(0.5); - wait_ms(150); - this->pwm.write(0.0); -*/ // music.setCompletionCallback(this, &SoundFX::musicCompleted); //music.play("T224L8O5CL16>C<P16GP16L8EL16P16>C<GP16L8E.L16P16L8C#L16>C#<P16G#P16L8FL16P16>C#<G#P16L8F.L16P16L8CL16>C<P16GP16L8EL16P16>C<GP16L8E.L16P16D#EFP16FF#GP16GG#AP16L8>C<P8L4>C"); music.play("T120 O3 L16 F L4 C F L8 C");