![]() |
SparkFun MY1690 MP3 Decoder Arduino Library
v1.0.0-3-g1b94a17
Library for SparkFun MY1690 MP3 Decoder boards
|
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 |
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.
SparkFunMY1690::SparkFunMY1690 | ( | ) |
bool SparkFunMY1690::begin | ( | Stream & | serialPort = Serial , |
uint8_t | pin = 255 |
||
) |
Initializes the MY1690 MP3 player module.
serialPort | The serial port to communicate with the MY1690 module. Defaults to Serial . |
pin | The busy pin used to monitor the module's status. Pass 255 if no busy pin is used. Defaults to 255. |
true
if the initialization was successful, false
otherwise.void SparkFunMY1690::clearBuffer | ( | void | ) |
bool SparkFunMY1690::fastForward | ( | void | ) |
Skips forward in the currently playing audio track.
This function advances the playback position of the current audio track.
uint8_t SparkFunMY1690::getEQ | ( | void | ) |
Retrieves the current equalizer (EQ) setting of the MP3 decoder.
uint16_t SparkFunMY1690::getNumberResponse | ( | void | ) |
bool SparkFunMY1690::getOKResponse | ( | void | ) |
uint8_t SparkFunMY1690::getPlayMode | ( | void | ) |
Retrieves the current play mode of the MP3 decoder.
uint8_t SparkFunMY1690::getPlayStatus | ( | void | ) |
Retrieves the current playback status of the MP3 decoder.
uint16_t SparkFunMY1690::getSongCount | ( | void | ) |
Retrieves the total number of songs available on the SD Card.
bool SparkFunMY1690::getSTOPResponse | ( | void | ) |
bool SparkFunMY1690::getStringResponse | ( | const char * | expectedResponse | ) |
uint16_t SparkFunMY1690::getTrackElapsedTime | ( | void | ) |
Retrieves the elapsed time of the current track being played.
uint16_t SparkFunMY1690::getTrackNumber | ( | void | ) |
Retrieves the current track number being played.
uint16_t SparkFunMY1690::getTrackTotalTime | ( | void | ) |
Retrieves the total duration of the current track.
uint16_t SparkFunMY1690::getVersion | ( | void | ) |
Retrieves the version of the MY1690 MP3 decoder firmware.
uint8_t SparkFunMY1690::getVolume | ( | void | ) |
Retrieves the current volume level of the MP3 decoder.
bool SparkFunMY1690::isConnected | ( | void | ) |
Checks if the MP3 decoder module is connected and responsive.
bool SparkFunMY1690::isPlaying | ( | void | ) |
Checks if the MP3 decoder is currently playing audio.
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.
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.
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.
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.
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.
bool SparkFunMY1690::playTrackNumber | ( | uint16_t | trackNumber | ) |
Plays a specific track by its track number.
trackNumber | The track number to play (1-based index). |
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.
bool SparkFunMY1690::responseAvailable | ( | uint8_t | maxTimeout = 100 | ) |
bool SparkFunMY1690::rewind | ( | void | ) |
Skips backward in the currently playing audio track.
This function rewinds the playback position of the current audio track.
void SparkFunMY1690::sendCommand | ( | uint8_t | commandLength | ) |
bool SparkFunMY1690::setEQ | ( | uint8_t | eqType | ) |
Sets the equalizer (EQ) type for audio playback.
eqType | The EQ type to set. 0: None, 1: Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass |
bool SparkFunMY1690::setPlayMode | ( | uint8_t | playMode | ) |
Sets the play mode for the MP3 decoder.
playMode | The desired play mode to set. 0‑4((Full/Folder/Single/Random/No Loop) |
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.
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.
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.
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.
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.
bool SparkFunMY1690::setVolume | ( | uint8_t | volumeLevel | ) |
Sets the volume level of the MP3 decoder.
volumeLevel | The desired volume level (0-30), where 0 is mute and 30 is the maximum volume. |
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.
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.
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.
|
protected |
|
protected |
uint8_t SparkFunMY1690::commandBytes[MP3_NUM_CMD_BYTES] |