Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed FATFileSystem
Diff: WDplayer/WDplayer.cpp
- Revision:
- 12:ff8d26124c38
- Parent:
- 11:7f3e9bc7366d
- Child:
- 17:7d4d8905b608
--- a/WDplayer/WDplayer.cpp Sun May 05 03:45:29 2019 +0000 +++ b/WDplayer/WDplayer.cpp Sun May 05 19:32:58 2019 +0000 @@ -33,11 +33,11 @@ _fptr = NULL; _tck = 0; lock = false; - vtck = 8000; + vtck = 4000; cache = NULL; _dac->period( _pwmfreq / 4.0f); if (allocate) { - cache = (unsigned char*)std::calloc(8000,sizeof(unsigned char)); + cache = (unsigned char*)std::calloc(4000,sizeof(unsigned char)); } }; @@ -84,30 +84,30 @@ fseek(_fptr,44,SEEK_SET); //Reset State and Locational Variables lock = false; - vtck = 8000; + vtck = 4000; _tck = 0; } //CORE ENGINE WRITING - if (_tck + 4000 >= _length) { + if (_tck + 2000 >= _length) { _fptr = NULL; _tck = 0; vtck = 0; - } else if (vtck > 4001 && !lock) { + } else if (vtck > 2001 && !lock) { //Block 1 Update - for (int i = 0; i <= 4000; i++) { + for (int i = 0; i <= 2000; i++) { fread(buffer,1,1,_fptr); cache[i] = ((unsigned char)buffer[0]); } lock = true; - _tck = _tck + 4000; - } else if (vtck < 3999 && lock) { + _tck = _tck + 2000; + } else if (vtck < 1999 && lock) { //Block 2 Update - for (int i = 4001; i <= 8000; i++) { + for (int i = 2001; i <= 4000; i++) { fread(buffer,1,1,_fptr); cache[i] = ((int)buffer[0]); } lock = false; - _tck = _tck + 4000; + _tck = _tck + 2000; } } @@ -116,17 +116,25 @@ ISR.attach(callback(this,&WDplayer::ISRtck),_pwmfreq); } +void WDplayer::ISRpause() { + ISR.detach(); +} + +void WDplayer::ISRresume() { + ISR.attach(callback(this,&WDplayer::ISRtck),_pwmfreq); +} + void WDplayer::ISRreset() { free(cache); lock = false; - vtck = 8000; + vtck = 4000; _tck = 0; ISR.detach(); } void WDplayer::ISRtck() { _dac->write( cache[vtck] / 255.00 ); - if (vtck == 8000) { + if (vtck == 4000) { vtck = -1; } vtck++;