mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.2 MiniMP3
This commit is contained in:
parent
eb4b58b191
commit
48a7d9ec88
27
libraries/MiniMP3/.arduino-ci.yml
Normal file
27
libraries/MiniMP3/.arduino-ci.yml
Normal file
@ -0,0 +1,27 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
# - esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
4
libraries/MiniMP3/.github/FUNDING.yml
vendored
Normal file
4
libraries/MiniMP3/.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: RobTillaart
|
||||
|
13
libraries/MiniMP3/.github/workflows/arduino-lint.yml
vendored
Normal file
13
libraries/MiniMP3/.github/workflows/arduino-lint.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
name: Arduino-lint
|
||||
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: arduino/arduino-lint-action@v1
|
||||
with:
|
||||
library-manager: update
|
||||
compliance: strict
|
17
libraries/MiniMP3/.github/workflows/arduino_test_runner.yml
vendored
Normal file
17
libraries/MiniMP3/.github/workflows/arduino_test_runner.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Arduino CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
runTest:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
18
libraries/MiniMP3/.github/workflows/jsoncheck.yml
vendored
Normal file
18
libraries/MiniMP3/.github/workflows/jsoncheck.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: JSON check
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**.json'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
pattern: "\\.json$"
|
||||
|
21
libraries/MiniMP3/CHANGELOG.md
Normal file
21
libraries/MiniMP3/CHANGELOG.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Change Log MINIMP3
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.1.2] - 2023-05-01
|
||||
- refactor & revitalize code
|
||||
- create changelog.md
|
||||
- create a repository
|
||||
- add Stream parameter in constructor
|
||||
- redo readme.md
|
||||
|
||||
|
||||
## [0.1.1] - 2018-06-12
|
||||
- added volume, equalizer
|
||||
|
||||
## [0.1.0] - 2018-06-11
|
||||
- initial version (play, stop, reset)
|
21
libraries/MiniMP3/LICENSE
Normal file
21
libraries/MiniMP3/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018-2023 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
173
libraries/MiniMP3/MiniMP3.cpp
Normal file
173
libraries/MiniMP3/MiniMP3.cpp
Normal file
@ -0,0 +1,173 @@
|
||||
//
|
||||
// FILE: MiniMP3.cpp
|
||||
// AUTHOR: Rob.Tillaart@gmail.com
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: Arduino library for DFRobotics MP3 player and compatibles.
|
||||
|
||||
|
||||
#include "MiniMP3.h"
|
||||
|
||||
|
||||
// CONSTANTS
|
||||
#define MP3_MAX_VOLUME 30
|
||||
|
||||
|
||||
// COMMANDS
|
||||
#define MP3_NEXT 0x01
|
||||
#define MP3_PREV 0x02
|
||||
#define MP3_PLAY 0x03
|
||||
#define MP3_VOL_INCR 0x04
|
||||
#define MP3_VOL_DECR 0x05
|
||||
#define MP3_VOL_SET 0x06
|
||||
#define MP3_EQUAL 0x07
|
||||
#define MP3_PLAYMODE 0x08
|
||||
#define MP3_PLAYSOURCE 0x09
|
||||
#define MP3_LOWPOWER 0x0A
|
||||
#define MP3_POWER 0x0B
|
||||
#define MP3_RESET 0x0C
|
||||
#define MP3_PLAYBACK 0x0D
|
||||
#define MP3_PAUSE 0x0E
|
||||
#define MP3_PLAY_FOLDER 0x0F
|
||||
#define MP3_VOL_ADJUST_SET 0x10
|
||||
#define MP3_REPEAT 0x11
|
||||
|
||||
|
||||
// QUERIES
|
||||
// not supported (yet)
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// PUBLIC
|
||||
//
|
||||
MINIMP3::MINIMP3(Stream * stream)
|
||||
{
|
||||
_stream = stream;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// PLAY
|
||||
//
|
||||
void MINIMP3::play(uint16_t track)
|
||||
{
|
||||
command(MP3_PLAY, track);
|
||||
}
|
||||
|
||||
// void MINIMP3::playFolder(uint8_t folder, uint8_t track)
|
||||
// {
|
||||
// command(MP3_PLAY_FOLDER, folder, track);
|
||||
// }
|
||||
|
||||
void MINIMP3::next()
|
||||
{
|
||||
command(MP3_NEXT);
|
||||
}
|
||||
|
||||
void MINIMP3::prev()
|
||||
{
|
||||
command(MP3_PREV);
|
||||
}
|
||||
|
||||
void MINIMP3::stop()
|
||||
{
|
||||
command(0x15);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// CONTROL
|
||||
//
|
||||
void MINIMP3::pause()
|
||||
{
|
||||
command(MP3_PAUSE);
|
||||
}
|
||||
|
||||
void MINIMP3::reset()
|
||||
{
|
||||
command(MP3_RESET);
|
||||
}
|
||||
|
||||
void MINIMP3::lowPower()
|
||||
{
|
||||
command(MP3_LOWPOWER);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// VOLUME
|
||||
//
|
||||
void MINIMP3::volume(uint16_t vol)
|
||||
{
|
||||
if (vol > MP3_MAX_VOLUME) vol = MP3_MAX_VOLUME;
|
||||
command(MP3_VOL_SET, 256 + vol);
|
||||
}
|
||||
|
||||
void MINIMP3::volumeUp()
|
||||
{
|
||||
command(MP3_VOL_INCR);
|
||||
}
|
||||
|
||||
void MINIMP3::volumeDown()
|
||||
{
|
||||
command(MP3_VOL_DECR);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// EQUALIZER
|
||||
//
|
||||
void MINIMP3::equalizer(uint8_t mode)
|
||||
{
|
||||
if (mode > 5) mode = MP3_EQ_NORMAL;
|
||||
command(MP3_EQUAL, mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// PRIVATE
|
||||
//
|
||||
void MINIMP3::command(uint8_t cmd, uint16_t arg)
|
||||
{
|
||||
uint8_t arg2 = arg & 0xFF;
|
||||
uint8_t arg1 = arg >> 8;
|
||||
command(cmd, arg1, arg2);
|
||||
}
|
||||
|
||||
|
||||
void MINIMP3::command(uint8_t cmd, uint8_t arg1, uint8_t arg2)
|
||||
{
|
||||
uint8_t buffer[10] = {0x7E, // Start == $
|
||||
0xFF, // version
|
||||
0x06, // length
|
||||
cmd,
|
||||
0x00, // 0 = no feedback
|
||||
arg1, // param 1
|
||||
arg2, // param 2
|
||||
0x00, // CheckSumHigh
|
||||
0x00, // CheckSumLow
|
||||
0xEF // End Byte
|
||||
};
|
||||
|
||||
uint16_t chksum = 0;
|
||||
for (int i = 1; i < 7; i++ )
|
||||
{
|
||||
chksum += buffer[i];
|
||||
}
|
||||
chksum = -chksum;
|
||||
buffer[7] = (chksum >> 8); // CheckSumHigh
|
||||
buffer[8] = (chksum & 0xFF); // CheckSumLow
|
||||
|
||||
_stream->write(buffer, 10);
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
75
libraries/MiniMP3/MiniMP3.h
Normal file
75
libraries/MiniMP3/MiniMP3.h
Normal file
@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
//
|
||||
// FILE: MiniMP3.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// PURPOSE: Arduino library for DFRobotics MP3 player and compatibles.
|
||||
// URL: https://github.com/RobTillaart/MINIMP3
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#define MINIMP3_LIB_VERSION (F("0.1.2"))
|
||||
|
||||
|
||||
// EQUALIZER MODI
|
||||
#define MP3_EQ_NORMAL 0
|
||||
#define MP3_EQ_POP 1
|
||||
#define MP3_EQ_ROCK 2
|
||||
#define MP3_EQ_JAZZ 3
|
||||
#define MP3_EQ_CLASSIC 4
|
||||
#define MP3_EQ_BASS 5
|
||||
|
||||
|
||||
// PLAYBACK MODI
|
||||
// to be implemented
|
||||
#define MP3_MODE_REPEAT 0
|
||||
#define MP3_MODE_FREPEAT 1
|
||||
#define MP3_MODE_SREPEAT 2
|
||||
#define MP3_MODE_RANDOM 3
|
||||
|
||||
|
||||
// PLAYBACK SOURCE
|
||||
// to be implemented?
|
||||
#define MP3_DEVICE_U 0
|
||||
#define MP3_DEVICE_TF 1
|
||||
#define MP3_DEVICE_AUX 2
|
||||
#define MP3_DEVICE_SLEEP 3
|
||||
#define MP3_DEVICE_FLASH 4
|
||||
|
||||
|
||||
class MINIMP3
|
||||
{
|
||||
public:
|
||||
MINIMP3(Stream * stream = &Serial);
|
||||
|
||||
// plays SD:/MP3/####.mp3
|
||||
void play(uint16_t track);
|
||||
// void playFolder(uint8_t folder, uint8_t track);
|
||||
void next();
|
||||
void prev();
|
||||
void stop();
|
||||
void pause();
|
||||
|
||||
void reset();
|
||||
void lowPower();
|
||||
|
||||
// volume = 0.. 30
|
||||
void volume(uint16_t vol = 0);
|
||||
void volumeUp();
|
||||
void volumeDown();
|
||||
|
||||
// mode = 0..5
|
||||
void equalizer(uint8_t mode = MP3_EQ_NORMAL);
|
||||
|
||||
|
||||
private:
|
||||
Stream * _stream;
|
||||
|
||||
void command(uint8_t cmd, uint16_t arg = 0x0000);
|
||||
void command(uint8_t cmd, uint8_t arg1, uint8_t arg2);
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
136
libraries/MiniMP3/README.md
Normal file
136
libraries/MiniMP3/README.md
Normal file
@ -0,0 +1,136 @@
|
||||
|
||||
[![Arduino CI](https://github.com/RobTillaart/MiniMP3/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![Arduino-lint](https://github.com/RobTillaart/MiniMP3/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/MiniMP3/actions/workflows/arduino-lint.yml)
|
||||
[![JSON check](https://github.com/RobTillaart/MiniMP3/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/MiniMP3/actions/workflows/jsoncheck.yml)
|
||||
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/MiniMP3.svg)](https://github.com/RobTillaart/MiniMP3/issues)
|
||||
|
||||
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MiniMP3/blob/master/LICENSE)
|
||||
[![GitHub release](https://img.shields.io/github/release/RobTillaart/MiniMP3.svg?maxAge=3600)](https://github.com/RobTillaart/MiniMP3/releases)
|
||||
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/MiniMP3.svg)](https://registry.platformio.org/libraries/robtillaart/MiniMP3)
|
||||
|
||||
|
||||
# MiniMP3 Library
|
||||
|
||||
Arduino library for DFRobotics MP3 player and compatibles.
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
**Experimental**
|
||||
|
||||
MiniMP3 is an Arduino library to control the DFRobotics MP3 player and compatibles.
|
||||
Goal is to have basic control of the device via hardware Serial or software Serial.
|
||||
|
||||
If you need complete control including all kinds of feedback events like
|
||||
"card inserted" you need to use the DFRobotics library.
|
||||
|
||||
This library is work in progress.
|
||||
|
||||
|
||||
#### Schema
|
||||
|
||||
```
|
||||
MINI MP3
|
||||
+-----__-----+
|
||||
VCC | | BUSY
|
||||
RX | | USB-
|
||||
TX | | USB+
|
||||
DAC_R | | ADKEY_2
|
||||
DAC_L | +------+ | ADKEY_1
|
||||
SPK_1 | | | | IO_2
|
||||
GND | | SD | | GND
|
||||
SPK_2 | | CARD | | IO_1
|
||||
+--+------+--+
|
||||
|
||||
When connecting to a 5V MCU, you need to add a 1K resistor between the
|
||||
Serial TX and RX as the MiniMP3 is 3V3. Otherwise a big HUM.
|
||||
```
|
||||
|
||||
|
||||
#### Links
|
||||
|
||||
- https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299 (extended library)
|
||||
|
||||
|
||||
## Interface
|
||||
|
||||
```cpp
|
||||
#include "MiniMP3.h"
|
||||
```
|
||||
|
||||
#### Constructor
|
||||
|
||||
- **MiniMP3(Stream \* stream = &Serial)** Can be used with software or hardware Serial.
|
||||
Default stream is Serial.
|
||||
- **void reset()** reset the player.
|
||||
- **void lowPower()** set the player in low power mode.
|
||||
|
||||
|
||||
#### Basic controls
|
||||
|
||||
- **void play(uint16_t track)** plays SD:/MP3/track.mp3
|
||||
- **void next()** go to next track.
|
||||
- **void prev()** go to previous track.
|
||||
- **void pause()** pause playing
|
||||
- **void stop()** stop playing.
|
||||
|
||||
|
||||
#### Volume
|
||||
|
||||
- **void volume(uint16_t vol = 0)** set volume range 0..30.
|
||||
- default volume off.
|
||||
- **void volumeUp()** increase volume one step.
|
||||
- **void volumeDown()** decrease volume one step.
|
||||
- **void equalizer(uint8_t mode = MP3_EQ_NORMAL)**
|
||||
- Set equalizer mode, see options below.
|
||||
|
||||
|
||||
#### Equalizer modi
|
||||
|
||||
| Mode | value | notes |
|
||||
|:-----------------|:-------:|:---------:|
|
||||
| MP3_EQ_NORMAL | 0 | default
|
||||
| MP3_EQ_POP | 1 |
|
||||
| MP3_EQ_ROCK | 2 |
|
||||
| MP3_EQ_JAZZ | 3 |
|
||||
| MP3_EQ_CLASSIC | 4 |
|
||||
| MP3_EQ_BASS | 5 |
|
||||
|
||||
|
||||
## Future
|
||||
|
||||
#### Must
|
||||
|
||||
- improve documentation
|
||||
|
||||
#### Should
|
||||
|
||||
- test
|
||||
- keep it minimal.
|
||||
|
||||
#### Could
|
||||
|
||||
- add playBack modi.
|
||||
- test different models
|
||||
- add examples
|
||||
- implement playlists
|
||||
- implement "skip_search" (play 10 seconds of each file).
|
||||
- implement randomizer
|
||||
- add unit tests (possible?)
|
||||
- get current track
|
||||
- last track
|
||||
- last mode
|
||||
|
||||
#### Wont
|
||||
|
||||
- implement query commands
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
If you appreciate my libraries, you can support the development and maintenance.
|
||||
Improve the quality of the libraries by providing issues and Pull Requests, or
|
||||
donate through PayPal or GitHub sponsors.
|
||||
|
||||
Thank you,
|
||||
|
27
libraries/MiniMP3/examples/MINIMP3_test/.arduino-ci.yml
Normal file
27
libraries/MiniMP3/examples/MINIMP3_test/.arduino-ci.yml
Normal file
@ -0,0 +1,27 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
# - esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
96
libraries/MiniMP3/examples/MINIMP3_test/MINIMP3_test.ino
Normal file
96
libraries/MiniMP3/examples/MINIMP3_test/MINIMP3_test.ino
Normal file
@ -0,0 +1,96 @@
|
||||
// FILE: MINIMP3_test.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: test
|
||||
// URL: https://github.com/RobTillaart/MINIMP3
|
||||
//
|
||||
//
|
||||
// MINI MP3
|
||||
// +-----__-----+
|
||||
// VCC | | BUSY
|
||||
// RX | | USB-
|
||||
// TX | | USB+
|
||||
// DAC_R | | ADKEY_2
|
||||
// DAC_L | +------+ | ADKEY_1
|
||||
// SPK_1 | | | | IO_2
|
||||
// GND | | SD | | GND
|
||||
// SPK_2 | | CARD | | IO_1
|
||||
// +--+------+--+
|
||||
//
|
||||
// When connecting to a 5V MCU, you need to add a 1K resistor between
|
||||
// the Serial TX and RX as the MINIMP3 is 3V3. Otherwise a big HUM.
|
||||
//
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "MiniMP3.h"
|
||||
#include "SoftwareSerial.h"
|
||||
|
||||
SoftwareSerial sws(6, 7); // RX, TX
|
||||
|
||||
|
||||
MINIMP3 MP3(&sws);
|
||||
|
||||
uint8_t vol = 10;
|
||||
uint8_t eq = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
|
||||
sws.begin(9600);
|
||||
|
||||
MP3.reset();
|
||||
delay(3000);
|
||||
MP3.play(1);
|
||||
MP3.volume(10);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (Serial.available())
|
||||
{
|
||||
char c = Serial.read();
|
||||
switch (c)
|
||||
{
|
||||
case '0'...'9':
|
||||
MP3.play(c - '0');
|
||||
break;
|
||||
case 'n':
|
||||
MP3.next();
|
||||
break;
|
||||
case 'p':
|
||||
MP3.prev();
|
||||
break;
|
||||
case '+':
|
||||
if (vol < 20) vol++;
|
||||
MP3.volume(vol);
|
||||
break;
|
||||
case '-':
|
||||
if (vol > 0) vol--;
|
||||
MP3.volume(vol);
|
||||
break;
|
||||
case 'e':
|
||||
if (eq > 5) eq = 0;
|
||||
MP3.equalizer(eq);
|
||||
break;
|
||||
case 's':
|
||||
MP3.pause();
|
||||
break;
|
||||
case '?':
|
||||
Serial.println("0..9 play song");
|
||||
Serial.println("n = next");
|
||||
Serial.println("p = previous");
|
||||
Serial.println("+ = volume up");
|
||||
Serial.println("- = volume down");
|
||||
Serial.println("e = next equalizer");
|
||||
Serial.println("s = stop");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -0,0 +1,27 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
# - uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
- mega2560
|
||||
- rpipico
|
@ -0,0 +1,93 @@
|
||||
// FILE: MINIMP3_test_HW_serial.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// URL: https://github.com/RobTillaart/MINIMP3
|
||||
//
|
||||
//
|
||||
// MINI MP3
|
||||
// +-----__-----+
|
||||
// VCC | | BUSY
|
||||
// RX | | USB-
|
||||
// TX | | USB+
|
||||
// DAC_R | | ADKEY_2
|
||||
// DAC_L | +------+ | ADKEY_1
|
||||
// SPK_1 | | | | IO_2
|
||||
// GND | | SD | | GND
|
||||
// SPK_2 | | CARD | | IO_1
|
||||
// +--+------+--+
|
||||
//
|
||||
// When connecting to a 5V MCU, you need to add a 1K resistor between
|
||||
// the Serial TX and RX as the MINIMP3 is 3V3. Otherwise a big HUM.
|
||||
//
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "MiniMP3.h"
|
||||
|
||||
|
||||
MINIMP3 MP3(&Serial2); // to be used with e.g. MEGA
|
||||
|
||||
uint8_t vol = 10;
|
||||
uint8_t eq = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
|
||||
Serial2.begin(9600);
|
||||
|
||||
MP3.reset();
|
||||
delay(3000);
|
||||
MP3.play(1);
|
||||
MP3.volume(10);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (Serial.available())
|
||||
{
|
||||
char c = Serial.read();
|
||||
switch (c)
|
||||
{
|
||||
case '0'...'9':
|
||||
MP3.play(c - '0');
|
||||
break;
|
||||
case 'n':
|
||||
MP3.next();
|
||||
break;
|
||||
case 'p':
|
||||
MP3.prev();
|
||||
break;
|
||||
case '+':
|
||||
if (vol < 20) vol++;
|
||||
MP3.volume(vol);
|
||||
break;
|
||||
case '-':
|
||||
if (vol > 0) vol--;
|
||||
MP3.volume(vol);
|
||||
break;
|
||||
case 'e':
|
||||
if (eq > 5) eq = 0;
|
||||
MP3.equalizer(eq);
|
||||
break;
|
||||
case 's':
|
||||
MP3.pause();
|
||||
break;
|
||||
case '?':
|
||||
Serial.println("0..9 play song");
|
||||
Serial.println("n = next");
|
||||
Serial.println("p = previous");
|
||||
Serial.println("+ = volume up");
|
||||
Serial.println("- = volume down");
|
||||
Serial.println("e = next equalizer");
|
||||
Serial.println("s = stop");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -0,0 +1,27 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
# - m4
|
||||
# - esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
@ -0,0 +1,98 @@
|
||||
// FILE: MINIMP3_test_SW_serial.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo
|
||||
// URL: https://github.com/RobTillaart/MINIMP3
|
||||
//
|
||||
//
|
||||
// MINI MP3
|
||||
// +-----__-----+
|
||||
// VCC | | BUSY
|
||||
// RX | | USB-
|
||||
// TX | | USB+
|
||||
// DAC_R | | ADKEY_2
|
||||
// DAC_L | +------+ | ADKEY_1
|
||||
// SPK_1 | | | | IO_2
|
||||
// GND | | SD | | GND
|
||||
// SPK_2 | | CARD | | IO_1
|
||||
// +--+------+--+
|
||||
//
|
||||
// When connecting to a 5V MCU, you need to add a 1K resistor between
|
||||
// the Serial TX and RX as the MINIMP3 is 3V3. Otherwise a big HUM.
|
||||
//
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "MiniMP3.h"
|
||||
|
||||
#include "SoftwareSerial.h"
|
||||
|
||||
SoftwareSerial sws(6, 7); // RX, TX
|
||||
|
||||
|
||||
MINIMP3 MP3(&sws);
|
||||
|
||||
uint8_t vol = 10;
|
||||
uint8_t eq = 0;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
Serial.println();
|
||||
Serial.println(__FILE__);
|
||||
|
||||
sws.begin(9600);
|
||||
|
||||
MP3.reset();
|
||||
delay(3000);
|
||||
MP3.play(1);
|
||||
MP3.volume(10);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (Serial.available())
|
||||
{
|
||||
char c = Serial.read();
|
||||
switch (c)
|
||||
{
|
||||
case '0'...'9':
|
||||
MP3.play(c - '0');
|
||||
break;
|
||||
case 'n':
|
||||
MP3.next();
|
||||
break;
|
||||
case 'p':
|
||||
MP3.prev();
|
||||
break;
|
||||
case '+':
|
||||
if (vol < 20) vol++;
|
||||
MP3.volume(vol);
|
||||
break;
|
||||
case '-':
|
||||
if (vol > 0) vol--;
|
||||
MP3.volume(vol);
|
||||
break;
|
||||
case 'e':
|
||||
if (eq > 5) eq = 0;
|
||||
MP3.equalizer(eq);
|
||||
break;
|
||||
case 's':
|
||||
MP3.pause();
|
||||
break;
|
||||
case '?':
|
||||
Serial.println("0..9 play song");
|
||||
Serial.println("n = next");
|
||||
Serial.println("p = previous");
|
||||
Serial.println("+ = volume up");
|
||||
Serial.println("- = volume down");
|
||||
Serial.println("e = next equalizer");
|
||||
Serial.println("s = stop");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
47
libraries/MiniMP3/keywords.txt
Normal file
47
libraries/MiniMP3/keywords.txt
Normal file
@ -0,0 +1,47 @@
|
||||
# Syntax Colouring Map For MINIMP3
|
||||
|
||||
# Data types (KEYWORD1)
|
||||
MINIMP3 KEYWORD1
|
||||
|
||||
# Methods and Functions (KEYWORD2)
|
||||
play KEYWORD2
|
||||
next KEYWORD2
|
||||
prev KEYWORD2
|
||||
stop KEYWORD2
|
||||
pause KEYWORD2
|
||||
|
||||
reset KEYWORD2
|
||||
lowPower KEYWORD2
|
||||
|
||||
volume KEYWORD2
|
||||
volumeUp KEYWORD2
|
||||
volumeDown KEYWORD2
|
||||
|
||||
equalizer KEYWORD2
|
||||
|
||||
|
||||
# Instances (KEYWORD2)
|
||||
|
||||
|
||||
# Constants (LITERAL1)
|
||||
MINIMP3_LIB_VERSION LITERAL1
|
||||
|
||||
MP3_EQ_NORMAL LITERAL1
|
||||
MP3_EQ_POP LITERAL1
|
||||
MP3_EQ_ROCK LITERAL1
|
||||
MP3_EQ_JAZZ LITERAL1
|
||||
MP3_EQ_CLASSIC LITERAL1
|
||||
MP3_EQ_BASS LITERAL1
|
||||
|
||||
MP3_PBM_REPEAT LITERAL1
|
||||
MP3_PBM_FREPEAT LITERAL1
|
||||
MP3_PBM_SREPEAT LITERAL1
|
||||
MP3_PBM_RANDOM LITERAL1
|
||||
|
||||
MP3_DEVICE_U LITERAL1
|
||||
MP3_DEVICE_TF LITERAL1
|
||||
MP3_DEVICE_AUX LITERAL1
|
||||
MP3_DEVICE_SLEEP LITERAL1
|
||||
MP3_DEVICE_FLASH LITERAL1
|
||||
|
||||
|
23
libraries/MiniMP3/library.json
Normal file
23
libraries/MiniMP3/library.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "MiniMP3",
|
||||
"keywords": "MP3,DFURobotics",
|
||||
"description": "Arduino library for DFRobotics MP3 player and compatibles.",
|
||||
"authors":
|
||||
[
|
||||
{
|
||||
"name": "Rob Tillaart",
|
||||
"email": "Rob.Tillaart@gmail.com",
|
||||
"maintainer": true
|
||||
}
|
||||
],
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/MiniMP3.git"
|
||||
},
|
||||
"version":"0.1.2",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
"headers": "MiniMP3.h"
|
||||
}
|
11
libraries/MiniMP3/library.properties
Normal file
11
libraries/MiniMP3/library.properties
Normal file
@ -0,0 +1,11 @@
|
||||
name=MiniMP3
|
||||
version=0.1.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Minimal MP3 DFURobotics library for Arduino.
|
||||
paragraph=
|
||||
category=Other
|
||||
url=https://github.com/RobTillaart/MiniMP3.git
|
||||
architectures=*
|
||||
includes=MiniMP3.h
|
||||
depends=
|
61
libraries/MiniMP3/test/unit_test_001.cpp
Normal file
61
libraries/MiniMP3/test/unit_test_001.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// FILE: unit_test_001.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2023-08-31
|
||||
// PURPOSE: unit tests for the MiniMP3
|
||||
// https://github.com/RobTillaart/MiniMP3
|
||||
// https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md
|
||||
//
|
||||
|
||||
// supported assertions
|
||||
// ----------------------------
|
||||
// assertEqual(expected, actual); // a == b
|
||||
// assertNotEqual(unwanted, actual); // a != b
|
||||
// assertComparativeEquivalent(expected, actual); // abs(a - b) == 0 or (!(a > b) && !(a < b))
|
||||
// assertComparativeNotEquivalent(unwanted, actual); // abs(a - b) > 0 or ((a > b) || (a < b))
|
||||
// assertLess(upperBound, actual); // a < b
|
||||
// assertMore(lowerBound, actual); // a > b
|
||||
// assertLessOrEqual(upperBound, actual); // a <= b
|
||||
// assertMoreOrEqual(lowerBound, actual); // a >= b
|
||||
// assertTrue(actual);
|
||||
// assertFalse(actual);
|
||||
// assertNull(actual);
|
||||
|
||||
// // special cases for floats
|
||||
// assertEqualFloat(expected, actual, epsilon); // fabs(a - b) <= epsilon
|
||||
// assertNotEqualFloat(unwanted, actual, epsilon); // fabs(a - b) >= epsilon
|
||||
// assertInfinity(actual); // isinf(a)
|
||||
// assertNotInfinity(actual); // !isinf(a)
|
||||
// assertNAN(arg); // isnan(a)
|
||||
// assertNotNAN(arg); // !isnan(a)
|
||||
|
||||
#include <ArduinoUnitTests.h>
|
||||
|
||||
|
||||
#include "MiniMP3.h"
|
||||
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "MINIMP3_LIB_VERSION: %s\n", (char *) MINIMP3_LIB_VERSION);
|
||||
}
|
||||
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest(test_constructor)
|
||||
{
|
||||
MINIMP3 MP3;
|
||||
|
||||
assertEqual(1,1); // dummy keeps build-CI happy
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
Loading…
x
Reference in New Issue
Block a user