SparkFun MY1690 MP3 Decoder Arduino Library  v1.0.0-3-g1b94a17
Library for SparkFun MY1690 MP3 Decoder boards
Loading...
Searching...
No Matches
SparkFunMY1690 Class Reference

A library for controlling the MY1690 Serial MP3 player module. More...

#include <SparkFun_MY1690_MP3_Library.h>

Public Member Functions

 SparkFunMY1690 ()
 
bool begin (Stream &serialPort=Serial, uint8_t pin=255)
 Initializes the MY1690 MP3 player module. More...
 
void play (void)
 Starts playback of the current audio track. More...
 
bool pause (void)
 Pauses the playback of the MP3 decoder. More...
 
bool playNext (void)
 Plays the next track on the SD card. More...
 
bool playPrevious (void)
 Plays the previous track on the SD card. More...
 
bool volumeUp (void)
 Increases the volume of the MP3 decoder by one step. More...
 
bool volumeDown (void)
 Decreases the volume of the MP3 decoder by one step. More...
 
bool reset (void)
 Resets the MY1690 MP3 decoder module to its default state. More...
 
bool fastForward (void)
 Skips forward in the currently playing audio track. More...
 
bool rewind (void)
 Skips backward in the currently playing audio track. More...
 
bool playPause (void)
 Toggles between play and pause states for the MP3 decoder. More...
 
bool stopPlaying (void)
 Stops the currently playing audio track. More...
 
bool setVolume (uint8_t volumeLevel)
 Sets the volume level of the MP3 decoder. More...
 
bool setEQ (uint8_t eqType)
 Sets the equalizer (EQ) type for audio playback. More...
 
bool setPlayMode (uint8_t playMode)
 Sets the play mode for the MP3 decoder. More...
 
bool playTrackNumber (uint16_t trackNumber)
 Plays a specific track by its track number. More...
 
uint8_t getPlayStatus (void)
 Retrieves the current playback status of the MP3 decoder. More...
 
uint8_t getVolume (void)
 Retrieves the current volume level of the MP3 decoder. More...
 
uint8_t getEQ (void)
 Retrieves the current equalizer (EQ) setting of the MP3 decoder. More...
 
uint8_t getPlayMode (void)
 Retrieves the current play mode of the MP3 decoder. More...
 
uint16_t getVersion (void)
 Retrieves the version of the MY1690 MP3 decoder firmware. More...
 
uint16_t getSongCount (void)
 Retrieves the total number of songs available on the SD Card. More...
 
uint16_t getTrackNumber (void)
 Retrieves the current track number being played. More...
 
uint16_t getTrackElapsedTime (void)
 Retrieves the elapsed time of the current track being played. More...
 
uint16_t getTrackTotalTime (void)
 Retrieves the total duration of the current track. More...
 
bool isConnected (void)
 Checks if the MP3 decoder module is connected and responsive. More...
 
bool isPlaying (void)
 Checks if the MP3 decoder is currently playing audio. More...
 
bool setPlayModeFull (void)
 Sets the playback mode to "Full Play Mode". More...
 
bool setPlayModeFolder (void)
 Sets the playback mode to play all songs in the current folder and loop continuously. More...
 
bool setPlayModeSingle (void)
 Sets the MP3 decoder to single play mode. More...
 
bool setPlayModeRandom (void)
 Sets the MP3 decoder to play songs in random order continuously. More...
 
bool setPlayModeNoLoop (void)
 Sets the play mode to "No Loop". More...
 
void sendCommand (uint8_t commandLength)
 
uint16_t getNumberResponse (void)
 
bool getOKResponse (void)
 
bool getSTOPResponse (void)
 
bool getStringResponse (const char *expectedResponse)
 
bool responseAvailable (uint8_t maxTimeout=100)
 
void clearBuffer (void)
 

Public Attributes

uint8_t commandBytes [MP3_NUM_CMD_BYTES]
 

Protected Attributes

Stream * _serialPort
 
uint8_t _busyPin
 

Detailed Description

A library for controlling the MY1690 Serial MP3 player module.

This class provides an interface to control the MY1690 MP3 player module via serial communication. It supports playback control, volume adjustment, equalizer settings, and querying the module's status.

Note
The MY1690 module requires a serial connection and optionally a busy pin.

Constructor & Destructor Documentation

◆ SparkFunMY1690()

SparkFunMY1690::SparkFunMY1690 ( )

Member Function Documentation

◆ begin()

bool SparkFunMY1690::begin ( Stream &  serialPort = Serial,
uint8_t  pin = 255 
)

Initializes the MY1690 MP3 player module.

Parameters
serialPortThe serial port to communicate with the MY1690 module. Defaults to Serial.
pinThe busy pin used to monitor the module's status. Pass 255 if no busy pin is used. Defaults to 255.
Returns
Returns true if the initialization was successful, false otherwise.
Note
Call this method before using any other functions in the class.

◆ clearBuffer()

void SparkFunMY1690::clearBuffer ( void  )

◆ fastForward()

bool SparkFunMY1690::fastForward ( void  )

Skips forward in the currently playing audio track.

This function advances the playback position of the current audio track.

Returns
true if the operation was successful, false otherwise.

◆ getEQ()

uint8_t SparkFunMY1690::getEQ ( void  )

Retrieves the current equalizer (EQ) setting of the MP3 decoder.

Returns
uint8_t The current EQ setting, a value of 0 to 5 (None\POP\ROCK\JAZZ\CLASSIC\BASS)

◆ getNumberResponse()

uint16_t SparkFunMY1690::getNumberResponse ( void  )

◆ getOKResponse()

bool SparkFunMY1690::getOKResponse ( void  )

◆ getPlayMode()

uint8_t SparkFunMY1690::getPlayMode ( void  )

Retrieves the current play mode of the MP3 decoder.

Returns
uint8_t The current play mode. 0‑4(Full/Folder/Single/Random/No Loop)

◆ getPlayStatus()

uint8_t SparkFunMY1690::getPlayStatus ( void  )

Retrieves the current playback status of the MP3 decoder.

Returns
uint8_t The playback status, 0(Stop) 1(Play) 2(Pause) 3(Fast forward) 4(Rewind)

◆ getSongCount()

uint16_t SparkFunMY1690::getSongCount ( void  )

Retrieves the total number of songs available on the SD Card.

Returns
uint16_t The total count of songs. 1‑65535

◆ getSTOPResponse()

bool SparkFunMY1690::getSTOPResponse ( void  )

◆ getStringResponse()

bool SparkFunMY1690::getStringResponse ( const char *  expectedResponse)

◆ getTrackElapsedTime()

uint16_t SparkFunMY1690::getTrackElapsedTime ( void  )

Retrieves the elapsed time of the current track being played.

Returns
uint16_t The elapsed time in seconds since the track started playing.

◆ getTrackNumber()

uint16_t SparkFunMY1690::getTrackNumber ( void  )

Retrieves the current track number being played.

Returns
uint16_t The track number currently being played. (1‑65536)

◆ getTrackTotalTime()

uint16_t SparkFunMY1690::getTrackTotalTime ( void  )

Retrieves the total duration of the current track.

Returns
uint16_t The total time of the track in seconds.

◆ getVersion()

uint16_t SparkFunMY1690::getVersion ( void  )

Retrieves the version of the MY1690 MP3 decoder firmware.

Returns
uint16_t The version number of the firmware.

◆ getVolume()

uint8_t SparkFunMY1690::getVolume ( void  )

Retrieves the current volume level of the MP3 decoder.

Returns
uint8_t The current volume level (0-30).

◆ isConnected()

bool SparkFunMY1690::isConnected ( void  )

Checks if the MP3 decoder module is connected and responsive.

Returns
true if the module is connected and operational, false otherwise.

◆ isPlaying()

bool SparkFunMY1690::isPlaying ( void  )

Checks if the MP3 decoder is currently playing audio.

Returns
true if audio is playing, false otherwise.

◆ pause()

bool SparkFunMY1690::pause ( void  )

Pauses the playback of the MP3 decoder.

This function pauses the current audio playback. Playback can be resumed using the appropriate resume function provided by the library.

Returns
true if the pause operation was successful, false otherwise.

◆ play()

void SparkFunMY1690::play ( void  )

Starts playback of the current audio track.

This function initiates the playback of the audio track currently loaded in the MP3 decoder. Ensure that the decoder is properly initialized and a track is loaded before calling this function.

◆ playNext()

bool SparkFunMY1690::playNext ( void  )

Plays the next track on the SD card.

This function advances to the next track and starts playback. It is typically used to skip to the next audio file in a sequence.

Returns
true if the next track was successfully started, false otherwise.

◆ playPause()

bool SparkFunMY1690::playPause ( void  )

Toggles between play and pause states for the MP3 decoder.

This function switches the MP3 decoder between playing and paused states. If the decoder is currently playing, it will pause. If it is paused, it will resume playing.

Returns
true if the operation was successful, false otherwise.

◆ playPrevious()

bool SparkFunMY1690::playPrevious ( void  )

Plays the previous track on the SD card.

This function attempts to switch to and play the previous track. The behavior may depend on the current state of the playback and the implementation of the playlist or queue.

Returns
true if the operation was successful, false otherwise.

◆ playTrackNumber()

bool SparkFunMY1690::playTrackNumber ( uint16_t  trackNumber)

Plays a specific track by its track number.

Parameters
trackNumberThe track number to play (1-based index).
Returns
true if the command to play the track was successfully sent, false otherwise.

◆ reset()

bool SparkFunMY1690::reset ( void  )

Resets the MY1690 MP3 decoder module to its default state.

It can be used to recover from errors or reinitialize the module.

Returns
true if the reset operation was successful, false otherwise.

◆ responseAvailable()

bool SparkFunMY1690::responseAvailable ( uint8_t  maxTimeout = 100)

◆ rewind()

bool SparkFunMY1690::rewind ( void  )

Skips backward in the currently playing audio track.

This function rewinds the playback position of the current audio track.

Returns
true if the operation was successful, false otherwise.

◆ sendCommand()

void SparkFunMY1690::sendCommand ( uint8_t  commandLength)

◆ setEQ()

bool SparkFunMY1690::setEQ ( uint8_t  eqType)

Sets the equalizer (EQ) type for audio playback.

Parameters
eqTypeThe EQ type to set. 0: None, 1: Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass
Returns
true if the EQ type was successfully set, false otherwise.

◆ setPlayMode()

bool SparkFunMY1690::setPlayMode ( uint8_t  playMode)

Sets the play mode for the MP3 decoder.

Parameters
playModeThe desired play mode to set. 0‑4((Full/Folder/Single/Random/No Loop)
Returns
true if the play mode was successfully set, false otherwise.

◆ setPlayModeFolder()

bool SparkFunMY1690::setPlayModeFolder ( void  )

Sets the playback mode to play all songs in the current folder and loop continuously.

This function configures the MP3 decoder to sequentially play all audio files within the current folder. Once all files have been played, playback will loop back to the first file in the folder and continue indefinitely.

Returns
true if the playback mode was successfully set, false otherwise.

◆ setPlayModeFull()

bool SparkFunMY1690::setPlayModeFull ( void  )

Sets the playback mode to "Full Play Mode".

In this mode, the device will play all songs on the SD card sequentially and then loop back to the beginning once all songs have been played.

Returns
true if the playback mode was successfully set, false otherwise.

◆ setPlayModeNoLoop()

bool SparkFunMY1690::setPlayModeNoLoop ( void  )

Sets the play mode to "No Loop".

This function configures the MP3 decoder to play a song once and then stop. It disables any looping behavior, ensuring that the playback halts after the current track finishes.

Returns
true if the play mode was successfully set, false otherwise.

◆ setPlayModeRandom()

bool SparkFunMY1690::setPlayModeRandom ( void  )

Sets the MP3 decoder to play songs in random order continuously.

This function enables a play mode where the MP3 decoder selects a random song to play, and upon completion, selects another random song. This process continues indefinitely without stopping.

Returns
true if the play mode was successfully set to random, false otherwise.

◆ setPlayModeSingle()

bool SparkFunMY1690::setPlayModeSingle ( void  )

Sets the MP3 decoder to single play mode.

In single play mode, the MP3 decoder will play the current song and then loop it continuously.

Returns
true if the play mode was successfully set, false otherwise.

◆ setVolume()

bool SparkFunMY1690::setVolume ( uint8_t  volumeLevel)

Sets the volume level of the MP3 decoder.

Parameters
volumeLevelThe desired volume level (0-30), where 0 is mute and 30 is the maximum volume.
Returns
true if the volume was successfully set, false otherwise.

◆ stopPlaying()

bool SparkFunMY1690::stopPlaying ( void  )

Stops the currently playing audio track.

This function halts playback of the audio track that is currently being played. It ensures that the MP3 decoder stops processing the audio stream.

Returns
true if the playback was successfully stopped, false otherwise.

◆ volumeDown()

bool SparkFunMY1690::volumeDown ( void  )

Decreases the volume of the MP3 decoder by one step.

This function adjusts the volume level of the MP3 decoder to a lower setting.

Returns
true if the volume was successfully decreased, false if the volume is already at the minimum level.

◆ volumeUp()

bool SparkFunMY1690::volumeUp ( void  )

Increases the volume of the MP3 decoder by one step.

This function adjusts the volume level of the MP3 decoder to a higher setting.

Returns
true if the volume was successfully increased, false if the volume is already at the maximum level.

Member Data Documentation

◆ _busyPin

uint8_t SparkFunMY1690::_busyPin
protected

◆ _serialPort

Stream* SparkFunMY1690::_serialPort
protected

◆ commandBytes

uint8_t SparkFunMY1690::commandBytes[MP3_NUM_CMD_BYTES]

The documentation for this class was generated from the following files: