Skip to content

Commit

Permalink
Merge branch 'master' into playback-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwargo authored Nov 28, 2023
2 parents 4357fbc + 0fec0f9 commit 938e12a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Adafruit_VS1053.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,23 @@ void Adafruit_VS1053_FilePlayer::feedBuffer_noLock(void) {
}
}

// get current playback speed. 0 or 1 indicates normal speed
uint16_t Adafruit_VS1053_FilePlayer::getPlaySpeed() {
noInterrupts();
sciWrite(VS1053_SCI_WRAMADDR, VS1053_PARA_PLAYSPEED);
uint16_t speed = sciRead(VS1053_SCI_WRAM);
interrupts();
return speed;
}

// set playback speed: 0 or 1 for normal speed, 2 for 2x, 3 for 3x, etc.
void Adafruit_VS1053_FilePlayer::setPlaySpeed(uint16_t speed) {
noInterrupts();
sciWrite(VS1053_SCI_WRAMADDR, VS1053_PARA_PLAYSPEED);
sciWrite(VS1053_SCI_WRAM, speed);
interrupts();
}

/***************************************************************/

/* VS1053 'low level' interface */
Expand Down
13 changes: 13 additions & 0 deletions Adafruit_VS1053.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ typedef volatile RwReg PortReg; //!< Type definition/alias used to specify the
0x0E //!< SCI_AICTRL register 2. Used to access the user's application program
#define VS1053_SCI_AICTRL3 \
0x0F //!< SCI_AICTRL register 3. Used to access the user's application program
#define VS1053_SCI_WRAM 0x06 //!< RAM write/read
#define VS1053_SCI_WRAMADDR 0x07 //!< Base address for RAM write/read

#define VS1053_PARA_PLAYSPEED 0x1E04 //!< 0,1 = normal speed, 2 = 2x, 3 = 3x etc

#define VS1053_DATABUFFERLEN 32 //!< Length of the data buffer

Expand Down Expand Up @@ -399,6 +403,15 @@ class Adafruit_VS1053_FilePlayer : public Adafruit_VS1053 {
* @return Returns true when looped playback is enabled
*/
boolean playbackLooped();
* @brief Determine current playback speed
* @return Returns playback speed, i.e. 1 for 1x, 2 for 2x, 3 for 3x
*/
uint16_t getPlaySpeed();
/*!
* @brief Set playback speed
* @param speed Set playback speed, i.e. 1 for 1x, 2 for 2x, 3 for 3x
*/
void setPlaySpeed(uint16_t speed);

private:
void feedBuffer_noLock(void);
Expand Down

0 comments on commit 938e12a

Please sign in to comment.