11/* !
2-  * @file SparkFun_MY1690_MP3_Library .cpp 
3-  * @brief  This is a library written for the MY1690  Serial MP3 player 
2+  * @file SparkFun_SparkFunMY1690_MP3_Library .cpp 
3+  * @brief  This is a library written for the SparkFunMY1690  Serial MP3 player 
44 * 
55 * SparkFun sells these at its website: www.sparkfun.com 
66 * 
77 * Do you like this library? Help support SparkFun. Buy a board! 
88 * https://www.sparkfun.com/products/15050 
99 * 
10-  * https://github.com/sparkfun/SparkFun_MY1690_MP3_Decoder_Arduino_Library  
10+  * https://github.com/sparkfun/SparkFun_SparkFunMY1690_MP3_Decoder_Arduino_Library  
1111 * 
1212 * @author SparkFun Electronics 
1313 * @date 2024 
1717 */  
1818#include  " SparkFun_MY1690_MP3_Library.h" 
1919
20- MY1690::MY1690 ()
20+ SparkFunMY1690::SparkFunMY1690 ()
2121{
2222}
2323
24- bool  MY1690 ::beginuint8_t  pin)
24+ bool  SparkFunMY1690 ::beginuint8_t  pin)
2525{
2626    _serialPort = &serialPort;
2727    _busyPin = pin;
@@ -43,7 +43,7 @@ bool MY1690::begin(Stream &serialPort, uint8_t pin)
4343}
4444
4545//  Try to get the version number from the device
46- uint16_t  MY1690 ::getVersionvoid )
46+ uint16_t  SparkFunMY1690 ::getVersionvoid )
4747{
4848    commandBytes[0 ] = MP3_COMMAND_GET_VERSION_NUMBER;
4949
@@ -71,7 +71,7 @@ uint16_t MY1690::getVersion(void)
7171}
7272
7373//  Verify the device responds correctly with a version number
74- bool  MY1690 ::isConnectedvoid )
74+ bool  SparkFunMY1690 ::isConnectedvoid )
7575{
7676    int  version = getVersion ();
7777    if  (version == 100  || version == 101 )
@@ -81,7 +81,7 @@ bool MY1690::isConnected(void)
8181}
8282
8383//  Play all songs on the SD card, then loop
84- bool  MY1690 ::setPlayModeFullvoid )
84+ bool  SparkFunMY1690 ::setPlayModeFullvoid )
8585{
8686    commandBytes[0 ] = MP3_COMMAND_SET_LOOP_MODE;
8787    commandBytes[1 ] = MP3_LOOP_MODE_FULL;
@@ -90,7 +90,7 @@ bool MY1690::setPlayModeFull(void)
9090}
9191
9292//  Play all songs in the folder, then loop
93- bool  MY1690 ::setPlayModeFoldervoid )
93+ bool  SparkFunMY1690 ::setPlayModeFoldervoid )
9494{
9595    commandBytes[0 ] = MP3_COMMAND_SET_LOOP_MODE;
9696    commandBytes[1 ] = MP3_LOOP_MODE_FOLDER;
@@ -99,7 +99,7 @@ bool MY1690::setPlayModeFolder(void)
9999}
100100
101101//  Play song, then loop
102- bool  MY1690 ::setPlayModeSinglevoid )
102+ bool  SparkFunMY1690 ::setPlayModeSinglevoid )
103103{
104104    commandBytes[0 ] = MP3_COMMAND_SET_LOOP_MODE;
105105    commandBytes[1 ] = MP3_LOOP_MODE_SINGLE;
@@ -108,7 +108,7 @@ bool MY1690::setPlayModeSingle(void)
108108}
109109
110110//  Play random song, then play another random song, with no end
111- bool  MY1690 ::setPlayModeRandomvoid )
111+ bool  SparkFunMY1690 ::setPlayModeRandomvoid )
112112{
113113    commandBytes[0 ] = MP3_COMMAND_SET_LOOP_MODE;
114114    commandBytes[1 ] = MP3_LOOP_MODE_RANDOM;
@@ -117,47 +117,47 @@ bool MY1690::setPlayModeRandom(void)
117117}
118118
119119//  Play a song, then stop
120- bool  MY1690 ::setPlayModeNoLoopvoid )
120+ bool  SparkFunMY1690 ::setPlayModeNoLoopvoid )
121121{
122122    commandBytes[0 ] = MP3_COMMAND_SET_LOOP_MODE;
123123    commandBytes[1 ] = MP3_LOOP_MODE_NO_LOOP;
124124    sendCommand (2 );
125125    return  (getOKResponse ());
126126}
127127
128- uint16_t  MY1690 ::getSongCountvoid )
128+ uint16_t  SparkFunMY1690 ::getSongCountvoid )
129129{
130130    commandBytes[0 ] = MP3_COMMAND_GET_SONG_COUNT;
131131    sendCommand (1 );
132132
133133    return  (getNumberResponse ());
134134}
135135
136- uint16_t  MY1690 ::getTrackNumbervoid )
136+ uint16_t  SparkFunMY1690 ::getTrackNumbervoid )
137137{
138138    commandBytes[0 ] = MP3_COMMAND_GET_CURRENT_TRACK;
139139    sendCommand (1 );
140140
141141    return  (getNumberResponse ());
142142}
143143
144- uint16_t  MY1690 ::getTrackElapsedTimevoid )
144+ uint16_t  SparkFunMY1690 ::getTrackElapsedTimevoid )
145145{
146146    commandBytes[0 ] = MP3_COMMAND_GET_CURRENT_TRACK_TIME;
147147    sendCommand (1 );
148148
149149    return  (getNumberResponse ());
150150}
151151
152- uint16_t  MY1690 ::getTrackTotalTimevoid )
152+ uint16_t  SparkFunMY1690 ::getTrackTotalTimevoid )
153153{
154154    commandBytes[0 ] = MP3_COMMAND_GET_CURRENT_TRACK_TIME_TOTAL;
155155    sendCommand (1 );
156156
157157    return  (getNumberResponse ());
158158}
159159
160- bool  MY1690 ::playTrackNumberuint16_t  trackNumber)
160+ bool  SparkFunMY1690 ::playTrackNumberuint16_t  trackNumber)
161161{
162162    commandBytes[0 ] = MP3_COMMAND_SELECT_TRACK_PLAY;
163163    commandBytes[1 ] = trackNumber >> 8 ;   //  MSB
@@ -166,9 +166,9 @@ bool MY1690::playTrackNumber(uint16_t trackNumber)
166166    return  (getOKResponse ());
167167}
168168
169- bool  MY1690 ::setVolumeuint8_t  volumeLevel)
169+ bool  SparkFunMY1690 ::setVolumeuint8_t  volumeLevel)
170170{
171-     //  Any number above 30 will be automatically set to 30 by MY1690 
171+     //  Any number above 30 will be automatically set to 30 by SparkFunMY1690 
172172    //  Trim value so return is true
173173    if  (volumeLevel > 30 )
174174        volumeLevel = 30 ;
@@ -183,58 +183,58 @@ bool MY1690::setVolume(uint8_t volumeLevel)
183183    return  (false );
184184}
185185
186- uint8_t  MY1690 ::getVolumevoid )
186+ uint8_t  SparkFunMY1690 ::getVolumevoid )
187187{
188188    commandBytes[0 ] = MP3_COMMAND_GET_VOLUME;
189189    sendCommand (1 );
190190    uint8_t  volLevel = getNumberResponse () & 0xFF ;
191191    return  (volLevel);
192192}
193193
194- bool  MY1690 ::volumeUpvoid )
194+ bool  SparkFunMY1690 ::volumeUpvoid )
195195{
196196    commandBytes[0 ] = MP3_COMMAND_VOLUME_UP;
197197    sendCommand (1 );
198198    return  (getOKResponse ());
199199}
200- bool  MY1690 ::volumeDownvoid )
200+ bool  SparkFunMY1690 ::volumeDownvoid )
201201{
202202    commandBytes[0 ] = MP3_COMMAND_VOLUME_DOWN;
203203    sendCommand (1 );
204204    return  (getOKResponse ());
205205}
206206
207- uint8_t  MY1690 ::getEQvoid )
207+ uint8_t  SparkFunMY1690 ::getEQvoid )
208208{
209209    commandBytes[0 ] = MP3_COMMAND_GET_EQ;
210210    sendCommand (1 );
211211    return  (getNumberResponse ());
212212}
213213
214- bool  MY1690 ::setEQuint8_t  eqType)
214+ bool  SparkFunMY1690 ::setEQuint8_t  eqType)
215215{
216216    commandBytes[0 ] = MP3_COMMAND_SET_EQ_MODE;
217217    commandBytes[1 ] = eqType;
218218    sendCommand (2 );
219219    return  (getOKResponse ());
220220}
221221
222- bool  MY1690 ::setPlayModeuint8_t  playMode)
222+ bool  SparkFunMY1690 ::setPlayModeuint8_t  playMode)
223223{
224224    commandBytes[0 ] = MP3_COMMAND_SET_LOOP_MODE;
225225    commandBytes[1 ] = playMode;
226226    sendCommand (2 );
227227    return  (getOKResponse ());
228228}
229229
230- uint8_t  MY1690 ::getPlayModevoid )
230+ uint8_t  SparkFunMY1690 ::getPlayModevoid )
231231{
232232    commandBytes[0 ] = MP3_COMMAND_GET_LOOP_MODE;
233233    sendCommand (1 );
234234    return  (getNumberResponse ());
235235}
236236
237- bool  MY1690 ::isPlayingvoid )
237+ bool  SparkFunMY1690 ::isPlayingvoid )
238238{
239239    if  (_busyPin == 255 )
240240    {
@@ -249,14 +249,14 @@ bool MY1690::isPlaying(void)
249249}
250250
251251//  Responds with '0000 \r\n' (note the space), '0001 \r\n', etc
252- uint8_t  MY1690 ::getPlayStatusvoid )
252+ uint8_t  SparkFunMY1690 ::getPlayStatusvoid )
253253{
254254    commandBytes[0 ] = MP3_COMMAND_GET_STATUS;
255255    sendCommand (1 );
256256    return  (getNumberResponse ());
257257}
258258
259- void  MY1690 ::playvoid )
259+ void  SparkFunMY1690 ::playvoid )
260260{
261261    commandBytes[0 ] = MP3_COMMAND_PLAY;
262262    sendCommand (1 );
@@ -265,21 +265,21 @@ void MY1690::play(void)
265265    //  User can also use the isPlaying() after 30ms to see if song has started
266266}
267267
268- bool  MY1690 ::pausevoid )
268+ bool  SparkFunMY1690 ::pausevoid )
269269{
270270    commandBytes[0 ] = MP3_COMMAND_PAUSE;
271271    sendCommand (1 );
272272    return  (getOKResponse ());
273273}
274274
275- bool  MY1690 ::playNextvoid )
275+ bool  SparkFunMY1690 ::playNextvoid )
276276{
277277    commandBytes[0 ] = MP3_COMMAND_NEXT;
278278    sendCommand (1 );
279279    return  (getOKResponse ());
280280}
281281
282- bool  MY1690 ::playPreviousvoid )
282+ bool  SparkFunMY1690 ::playPreviousvoid )
283283{
284284    commandBytes[0 ] = MP3_COMMAND_PREVIOUS;
285285    sendCommand (1 );
@@ -288,7 +288,7 @@ bool MY1690::playPrevious(void)
288288
289289//  Device responds with 'OK'
290290//  If a song is playing, then ~14ms later 'STOP' is reported
291- bool  MY1690 ::stopPlayingvoid )
291+ bool  SparkFunMY1690 ::stopPlayingvoid )
292292{
293293    //  Use hardware pins or software command
294294    if  (isPlaying () == false )
@@ -308,7 +308,7 @@ bool MY1690::stopPlaying(void)
308308    return  (false );
309309}
310310
311- bool  MY1690 ::resetvoid )
311+ bool  SparkFunMY1690 ::resetvoid )
312312{
313313    //  Device responds with 'OK'
314314    //  Then 'STOPMP3' ~18ms later
@@ -319,34 +319,34 @@ bool MY1690::reset(void)
319319}
320320
321321//  Advance track ~1s
322- bool  MY1690 ::fastForwardvoid )
322+ bool  SparkFunMY1690 ::fastForwardvoid )
323323{
324324    commandBytes[0 ] = MP3_COMMAND_FASTFOWARD;
325325    sendCommand (1 );
326326    return  (getOKResponse ());
327327}
328328
329329//  Rewind track ~1s
330- bool  MY1690 ::rewindvoid )
330+ bool  SparkFunMY1690 ::rewindvoid )
331331{
332332    commandBytes[0 ] = MP3_COMMAND_REWIND;
333333    sendCommand (1 );
334334    return  (getOKResponse ());
335335}
336336
337337//  Toggle play/pause on this track
338- bool  MY1690 ::playPausevoid )
338+ bool  SparkFunMY1690 ::playPausevoid )
339339{
340340    commandBytes[0 ] = MP3_COMMAND_PLAY_PAUSE;
341341    sendCommand (1 );
342342    return  (getOKResponse ());
343343}
344344
345- //  In version 1.1, sometimes MY1690  responds with '0000 \r\n' to a get command. No OK, and a space.
345+ //  In version 1.1, sometimes SparkFunMY1690  responds with '0000 \r\n' to a get command. No OK, and a space.
346346//  Sometimes 'OK0001 \r\n'. Ok, and a space. Yay!
347347//  In version 1.0 it was lower case letters. In v1.1, it's upper case HEX.
348348//  Convert the four letters to a decimal value
349- uint16_t  MY1690 ::getNumberResponsevoid )
349+ uint16_t  SparkFunMY1690 ::getNumberResponsevoid )
350350{
351351    const  uint8_t  maxLength = 9 ;
352352    uint8_t  okResponseOffset = 0 ;
@@ -406,13 +406,13 @@ uint16_t MY1690::getNumberResponse(void)
406406}
407407
408408//  MY1690 responds with OK (no \n \r) in ASCII to a control command
409- bool  MY1690 ::getOKResponsevoid )
409+ bool  SparkFunMY1690 ::getOKResponsevoid )
410410{
411411    return  (getStringResponse (" OK" 
412412}
413413
414414//  Returns true if MY1690 responds with a given string
415- bool  MY1690 ::getStringResponseconst  char  *expectedResponse)
415+ bool  SparkFunMY1690 ::getStringResponseconst  char  *expectedResponse)
416416{
417417    uint8_t  expectedLength = strlen (expectedResponse);
418418
@@ -448,7 +448,7 @@ bool MY1690::getStringResponse(const char *expectedResponse)
448448}
449449
450450//  Returns false if no serial data is seen after maxTimeout
451- bool  MY1690 ::responseAvailableuint8_t  maxTimeout)
451+ bool  SparkFunMY1690 ::responseAvailableuint8_t  maxTimeout)
452452{
453453    uint8_t  counter = 0 ;
454454
@@ -462,7 +462,7 @@ bool MY1690::responseAvailable(uint8_t maxTimeout)
462462    return  (true );
463463}
464464
465- void  MY1690 ::clearBuffervoid )
465+ void  SparkFunMY1690 ::clearBuffervoid )
466466{
467467    while  (_serialPort->available ())
468468    {
@@ -472,7 +472,7 @@ void MY1690::clearBuffer(void)
472472    return ;
473473}
474474
475- void  MY1690 ::sendCommanduint8_t  commandLength)
475+ void  SparkFunMY1690 ::sendCommanduint8_t  commandLength)
476476{
477477    clearBuffer (); //  Clear anything in the buffer
478478
0 commit comments