Production Test Program (PTP) for the LPC4088 Experiment Base Board
Dependencies: EALib I2S LM75B SDFileSystem mbed
Diff: TestAudio.cpp
- Revision:
- 7:48375cb50f3a
- Parent:
- 6:4d97917c7dea
--- a/TestAudio.cpp Tue Sep 09 14:20:12 2014 +0000 +++ b/TestAudio.cpp Thu Sep 25 07:17:44 2014 +0000 @@ -157,7 +157,7 @@ _i2sTx.masterslave(I2S_SLAVE); _i2sTx.start(); - + int lastVol = -1000; // value not important do { //check if joystick-down pressed = play wave-file @@ -184,7 +184,15 @@ _codec.input_mute(false); } - _codec.headphone_volume(_aIn); + //attempt to filter out the small variations in analog values and + //only update volume when a "large enough" change is detected. + float v = _aIn; + int val = ((int)(v*1000))>>2; + if (val != lastVol) { + _codec.headphone_volume(v); + lastVol = val; + } + //_codec.headphone_volume(_aIn); wait(0.25); } while (up.read() != 0);