made it do pwmout and dacout
Fork of wave_player by
Revision 2:da5d90e12f27, committed 2014-12-05
- Comitter:
- lenhardt
- Date:
- Fri Dec 05 02:31:00 2014 +0000
- Parent:
- 1:acc3e18e77ad
- Commit message:
- overloaded play function to have pwmout and dacout
Changed in this revision
wave_player.cpp | Show annotated file Show diff for this revision Revisions of this file |
wave_player.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r acc3e18e77ad -r da5d90e12f27 wave_player.cpp --- a/wave_player.cpp Tue Jan 18 03:57:27 2011 +0000 +++ b/wave_player.cpp Fri Dec 05 02:31:00 2014 +0000 @@ -18,10 +18,12 @@ //----------------------------------------------------------------------------- // constructor -- accepts an mbed pin to use for AnalogOut. Only p18 will work -wave_player::wave_player(AnalogOut *_dac) +wave_player::wave_player(AnalogOut *_dac, PwmOut *_pwm) { + wave_PWM = _pwm; wave_DAC=_dac; wave_DAC->write_u16(32768); //DAC is 0-3.3V, so idles at ~1.6V + *wave_PWM = 32768; verbosity=0; } @@ -205,7 +207,7 @@ printf("ISR rdptr %d got %u\n",DAC_rptr,DAC_fifo[DAC_rptr]); #endif wave_DAC->write_u16(DAC_fifo[DAC_rptr]); + wave_PWM->write(float(DAC_fifo[DAC_rptr]/65536.0)); DAC_rptr=(DAC_rptr+1) & 0xff; } } -
diff -r acc3e18e77ad -r da5d90e12f27 wave_player.h --- a/wave_player.h Tue Jan 18 03:57:27 2011 +0000 +++ b/wave_player.h Fri Dec 05 02:31:00 2014 +0000 @@ -37,7 +37,7 @@ * * @param _dac pointer to an AnalogOut object to which the samples are sent. */ -wave_player(AnalogOut *_dac); +wave_player(AnalogOut *_dac, PwmOut *_pwm); /** the player function. * @@ -62,6 +62,7 @@ void dac_out(void); int verbosity; AnalogOut *wave_DAC; +PwmOut *wave_PWM; Ticker tick; unsigned short DAC_fifo[256]; short DAC_wptr; @@ -69,4 +70,3 @@ short DAC_on; }; -