USB stick covox & pwm wav player
Dependents: wave_player_pwm_and_covox_lib
Diff: wave_player.cpp
- Revision:
- 2:da5d90e12f27
- Parent:
- 0:62c18ade9a60
- Child:
- 3:97da0d3bf0cd
--- 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; } } -