|
1 |
| -/* |
2 |
| - This is a library written for the MY1690 Serial MP3 player |
3 |
| - SparkFun sells these at its website: www.sparkfun.com |
4 |
| - Do you like this library? Help support SparkFun. Buy a board! |
5 |
| - https://www.sparkfun.com/products/15050 |
6 |
| -
|
7 |
| - https://github.com/sparkfun/SparkFun_MY1690_MP3_Decoder_Arduino_Library |
8 |
| -
|
9 |
| - This program is distributed in the hope that it will be useful, |
10 |
| - but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
| - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
| - GNU General Public License for more details. |
13 |
| -
|
14 |
| - You should have received a copy of the GNU General Public License |
15 |
| - along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 |
| -*/ |
17 |
| - |
| 1 | +/*! |
| 2 | + * @file SparkFun_MY1690_MP3_Library.cpp |
| 3 | + * @brief This is a library written for the MY1690 Serial MP3 player |
| 4 | + * |
| 5 | + * SparkFun sells these at its website: www.sparkfun.com |
| 6 | + * |
| 7 | + * Do you like this library? Help support SparkFun. Buy a board! |
| 8 | + * https://www.sparkfun.com/products/15050 |
| 9 | + * |
| 10 | + * https://github.com/sparkfun/SparkFun_MY1690_MP3_Decoder_Arduino_Library |
| 11 | + * |
| 12 | + * @author SparkFun Electronics |
| 13 | + * @date 2024 |
| 14 | + * @copyright Copyright (c) 2025, SparkFun Electronics Inc. This project is released under the MIT License. |
| 15 | + * |
| 16 | + * SPDX-License-Identifier: MIT |
| 17 | + */ |
18 | 18 | #include "SparkFun_MY1690_MP3_Library.h"
|
19 | 19 |
|
20 | 20 | MY1690::MY1690()
|
@@ -49,20 +49,20 @@ uint16_t MY1690::getVersion(void)
|
49 | 49 |
|
50 | 50 | // Sometimes it responds with 'OK1.1\r\n'
|
51 | 51 | sendCommand(1);
|
52 |
| - if(getStringResponse("OK1.1\r\n") == true) |
| 52 | + if (getStringResponse("OK1.1\r\n") == true) |
53 | 53 | return (101);
|
54 | 54 |
|
55 | 55 | // Sometimes it responds with '1.1\r\n'
|
56 | 56 | sendCommand(1);
|
57 |
| - if(getStringResponse("1.1\r\n") == true) |
| 57 | + if (getStringResponse("1.1\r\n") == true) |
58 | 58 | return (101);
|
59 | 59 |
|
60 | 60 | sendCommand(1);
|
61 |
| - if(getStringResponse("OK1.0\r\n") == true) |
| 61 | + if (getStringResponse("OK1.0\r\n") == true) |
62 | 62 | return (100);
|
63 | 63 |
|
64 | 64 | sendCommand(1);
|
65 |
| - if(getStringResponse("1.0\r\n") == true) |
| 65 | + if (getStringResponse("1.0\r\n") == true) |
66 | 66 | return (100);
|
67 | 67 |
|
68 | 68 | sendCommand(1);
|
@@ -170,7 +170,7 @@ bool MY1690::setVolume(uint8_t volumeLevel)
|
170 | 170 | {
|
171 | 171 | // Any number above 30 will be automatically set to 30 by MY1690
|
172 | 172 | // Trim value so return is true
|
173 |
| - if(volumeLevel > 30) |
| 173 | + if (volumeLevel > 30) |
174 | 174 | volumeLevel = 30;
|
175 | 175 |
|
176 | 176 | commandBytes[0] = MP3_COMMAND_SET_VOLUME;
|
@@ -290,15 +290,15 @@ bool MY1690::playPrevious(void)
|
290 | 290 | // If a song is playing, then ~14ms later 'STOP' is reported
|
291 | 291 | bool MY1690::stopPlaying(void)
|
292 | 292 | {
|
293 |
| - //Use hardware pins or software command |
| 293 | + // Use hardware pins or software command |
294 | 294 | if (isPlaying() == false)
|
295 | 295 | return (true);
|
296 | 296 |
|
297 | 297 | commandBytes[0] = MP3_COMMAND_STOP;
|
298 | 298 | sendCommand(1);
|
299 |
| - |
300 |
| - //v1.1 doesn't respond with OK or STOP, instead the isPlaying can be used |
301 |
| - //getOKResponse(); |
| 299 | + |
| 300 | + // v1.1 doesn't respond with OK or STOP, instead the isPlaying can be used |
| 301 | + // getOKResponse(); |
302 | 302 |
|
303 | 303 | delay(10); // IC takes 5ms to stop a track
|
304 | 304 |
|
@@ -369,17 +369,17 @@ uint16_t MY1690::getNumberResponse(void)
|
369 | 369 | }
|
370 | 370 | else if (i <= (3 + okResponseOffset))
|
371 | 371 | {
|
372 |
| - //Added because getVersion response is three characters long |
373 |
| - if (incoming != '\r' && incoming != '\n') |
| 372 | + // Added because getVersion response is three characters long |
| 373 | + if (incoming != '\r' && incoming != '\n') |
374 | 374 | {
|
375 |
| - // Convert ASCII HEX values to decimal |
376 |
| - responseValue <<= 4; |
377 |
| - if (incoming >= '0' && incoming <= '9') |
378 |
| - responseValue += (incoming - '0'); |
379 |
| - else if (incoming >= 'A' && incoming <= 'Z') |
380 |
| - responseValue += (incoming - 'A') + 10; |
381 |
| - else if (incoming >= 'a' && incoming <= 'z') |
382 |
| - responseValue += (incoming - 'a') + 10; |
| 375 | + // Convert ASCII HEX values to decimal |
| 376 | + responseValue <<= 4; |
| 377 | + if (incoming >= '0' && incoming <= '9') |
| 378 | + responseValue += (incoming - '0'); |
| 379 | + else if (incoming >= 'A' && incoming <= 'Z') |
| 380 | + responseValue += (incoming - 'A') + 10; |
| 381 | + else if (incoming >= 'a' && incoming <= 'z') |
| 382 | + responseValue += (incoming - 'a') + 10; |
383 | 383 | }
|
384 | 384 | }
|
385 | 385 | else if (incoming == '\n')
|
|
0 commit comments