2018-09-07 06:59:08 +01:00
|
|
|
/*
|
2019-10-27 10:13:24 +00:00
|
|
|
xdrv_14_mp3.ino - MP3 support for Tasmota
|
2018-09-07 09:54:24 +01:00
|
|
|
|
2021-01-01 12:44:04 +00:00
|
|
|
Copyright (C) 2021 gemu2015, mike2nl and Theo Arends
|
2018-09-07 09:54:24 +01:00
|
|
|
|
2018-09-07 06:59:08 +01:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2018-09-07 09:54:24 +01:00
|
|
|
|
2018-09-07 06:59:08 +01:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2018-09-07 09:54:24 +01:00
|
|
|
|
2018-09-07 06:59:08 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------
|
|
|
|
Version yyyymmdd Action Description
|
|
|
|
--------------------------------------------------------------------------------------------
|
2022-06-22 22:47:32 +01:00
|
|
|
|
2022-06-24 13:55:19 +01:00
|
|
|
1.0.0.6 20220624 added - Busy flag on optional GPIO pin
|
2022-06-22 22:47:32 +01:00
|
|
|
added - command for MP3Folder, folder/track format
|
|
|
|
added - an event so that busy flag can be used in Berry
|
|
|
|
ToDo - test changes with SV17F
|
|
|
|
ToDo - change MP3Folder format to use two arguments MP3Folder 3,9
|
|
|
|
- Tom@lafleur.us
|
|
|
|
|
2021-01-21 14:10:17 +00:00
|
|
|
1.0.0.5 20210121 added - support for DY_SV17F Player (#define USE_DY_SV17F)
|
|
|
|
- cmds supported:
|
|
|
|
- track
|
2021-01-21 14:15:54 +00:00
|
|
|
- stop
|
2021-01-21 14:10:17 +00:00
|
|
|
- volume
|
|
|
|
- play
|
|
|
|
- play /path
|
|
|
|
|
2018-10-04 07:25:32 +01:00
|
|
|
1.0.0.4 20181003 added - MP3Reset command in case that the player do rare things
|
|
|
|
- and needs a reset, the default volume will be set again too
|
|
|
|
added - MP3_CMD_RESET_VALUE for the player reset function
|
|
|
|
cleaned - some comments and added function text header
|
|
|
|
fixed - missing void's in function calls
|
|
|
|
added - MP3_CMD_DAC command to switch off/on the dac outputs
|
|
|
|
tested - works with MP3Device 1 = USB STick, or MP3Device 2 = SD-Card
|
|
|
|
- after power and/or reset the SD-Card(2) is the default device
|
|
|
|
- DAC looks working too on a headset. Had no amplifier for test
|
|
|
|
---
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
1.0.0.3 20180915 added - select device for SD-Card or USB Stick, default will be SD-Card
|
|
|
|
tested - works by MP3Device 1 = USB STick, or MP3Device 2 = SD-Card
|
|
|
|
- after power and/or reset the SD-Card(2) is the default device
|
|
|
|
---
|
2018-11-11 15:52:09 +00:00
|
|
|
1.0.0.2 20180912 added - again some if-commands to switch() because of new commands
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
---
|
|
|
|
1.0.0.1 20180911 added - command eq (equalizer 0..5)
|
|
|
|
tested - works in console with MP3EQ 1, the value can be 0..5
|
|
|
|
added - USB device selection via command in console
|
|
|
|
tested - looks like it is working
|
|
|
|
erased - code for USB device about some errors, will be added in a next release
|
|
|
|
---
|
|
|
|
1.0.0.1 20180910 changed - command real MP3Stop in place of pause/stop used in the original version
|
2018-11-11 15:52:09 +00:00
|
|
|
changed - the command MP3Play e.g. 001 to MP3Track e.g. 001,
|
|
|
|
added - new normal command MP3Play and MP3Pause
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
---
|
2018-11-11 15:52:09 +00:00
|
|
|
1.0.0.0 20180907 merged - by arendst
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
changed - the driver name from xdrv_91_mp3.ino to xdrv_14_mp3.ino
|
|
|
|
---
|
2018-11-11 15:52:09 +00:00
|
|
|
0.9.0.3 20180906 request - Pull Request
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
changed - if-commands to switch() for faster response
|
|
|
|
---
|
|
|
|
0.9.0.2 20180906 cleaned - source code for faster reading
|
|
|
|
---
|
|
|
|
0.9.0.1 20180905 added - #include <TasmotaSerial.h> because compiler error (Arduino IDE v1.8.5)
|
|
|
|
---
|
|
|
|
0.9.0.0 20180901 started - further development by mike2nl - https://github.com/mike2nl/Sonoff-Tasmota
|
|
|
|
base - code base from gemu2015 ;-) - https://github.com/gemu2015/Sonoff-Tasmota
|
2019-10-27 10:13:24 +00:00
|
|
|
forked - from arendst/tasmota - https://github.com/arendst/Tasmota
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
|
|
|
|
Ver 12.1.0.4x
|
2022-06-23 15:39:10 +01:00
|
|
|
/include/tasmota/tasmota_template.h
|
2022-06-22 22:47:32 +01:00
|
|
|
@ line 56
|
|
|
|
GPIO_MP3_DFR562, // RB-DFR-562, DFPlayer Mini MP3 Player
|
|
|
|
GPIO_MP3_DFR562_BUSY, // RB-DFR-562, DFPlayer Mini MP3 Player busy flag
|
|
|
|
|
|
|
|
@ Line 290
|
|
|
|
D_SENSOR_DFR562 "|" D_SENSOR_DFR562_BUSY "|"
|
|
|
|
|
|
|
|
@ line 870
|
|
|
|
#ifdef USE_MP3_PLAYER
|
|
|
|
AGPIO(GPIO_MP3_DFR562), // RB-DFR-562, DFPlayer Mini MP3 Player Serial interface
|
|
|
|
AGPIO(GPIO_MP3_DFR562_BUSY),// RB-DFR-562, DFPlayer Mini MP3 Player optional Busy flag
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/tasmota/language/el_GB.h
|
|
|
|
@ line 634
|
|
|
|
#define D_SENSOR_DFR562 "MP3 Player"
|
|
|
|
#define D_SENSOR_DFR562_BUSY "MP3 Busy"
|
|
|
|
|
2018-09-07 06:59:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef USE_MP3_PLAYER
|
2018-09-07 09:54:24 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* MP3 control for RB-DFR-562 DFRobot mini MP3 player
|
|
|
|
* https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299
|
|
|
|
\*********************************************************************************************/
|
2018-09-07 06:59:08 +01:00
|
|
|
|
2018-11-07 09:30:03 +00:00
|
|
|
#define XDRV_14 14
|
|
|
|
|
2018-09-07 06:59:08 +01:00
|
|
|
#include <TasmotaSerial.h>
|
|
|
|
|
|
|
|
TasmotaSerial *MP3Player;
|
|
|
|
|
2018-10-04 07:25:32 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* constants
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2018-09-07 06:59:08 +01:00
|
|
|
#define D_CMND_MP3 "MP3"
|
2018-09-07 09:54:24 +01:00
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
const char S_JSON_MP3_COMMAND_NVALUE[] PROGMEM = "{\"" D_CMND_MP3 "%s\":%d}";
|
|
|
|
const char S_JSON_MP3_COMMAND[] PROGMEM = "{\"" D_CMND_MP3 "%s\"}";
|
|
|
|
const char kMP3_Commands[] PROGMEM = "Track|Folder|Play|Pause|Stop|Volume|EQ|Device|Reset|DAC"; // <-------- trl
|
|
|
|
uint32_t MP2BusyFlag; // low is busy
|
|
|
|
|
2018-10-04 07:25:32 +01:00
|
|
|
|
|
|
|
/*********************************************************************************************\
|
|
|
|
* enumerationsines
|
|
|
|
\*********************************************************************************************/
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
|
|
|
|
enum MP3_Commands { // commands useable in console or rules
|
|
|
|
CMND_MP3_TRACK, // MP3Track 001...255
|
2022-06-22 22:47:32 +01:00
|
|
|
CMND_MP3_FOLDER, // MP3Folder folder 01-99, track 0001...0255 // <-------- trl
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
CMND_MP3_PLAY, // MP3Play, after pause or normal start to play
|
|
|
|
CMND_MP3_PAUSE, // MP3Pause
|
|
|
|
CMND_MP3_STOP, // MP3Stop, real stop, original version was pause function
|
|
|
|
CMND_MP3_VOLUME, // MP3Volume 0..100
|
|
|
|
CMND_MP3_EQ, // MP3EQ 0..5
|
2018-10-04 07:25:32 +01:00
|
|
|
CMND_MP3_DEVICE, // sd-card: 02, usb-stick: 01
|
|
|
|
CMND_MP3_RESET, // MP3Reset, a fresh and default restart
|
|
|
|
CMND_MP3_DAC }; // set dac, 1=off, 0=on, DAC is turned on (0) by default
|
|
|
|
|
2018-11-11 15:52:09 +00:00
|
|
|
|
2018-10-04 07:25:32 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* command defines
|
|
|
|
\*********************************************************************************************/
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
#define MP3_CMD_RESET_VALUE 0x00 // mp3 reset command value
|
2018-10-04 07:25:32 +01:00
|
|
|
// player commands
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
#define MP3_CMD_TRACK 0x03 // specify playback of a track, e.g. MP3Track 003
|
2022-06-22 22:47:32 +01:00
|
|
|
#define MP3_CMD_FOLDER 0x0f // specify playback of a track, e.g. MP3Folder 03,0255 <-------------- TRL
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
#define MP3_CMD_PLAY 0x0d // Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device
|
2018-11-11 15:52:09 +00:00
|
|
|
#define MP3_CMD_PAUSE 0x0e // Pause, was original designed as stop, see data sheet
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
#define MP3_CMD_STOP 0x16 // Stop, it's a real stop now, in the original version it was a pause command
|
|
|
|
#define MP3_CMD_VOLUME 0x06 // specifies the volume and means a console input as 0..100
|
|
|
|
#define MP3_CMD_EQ 0x07 // specify EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass
|
|
|
|
#define MP3_CMD_DEVICE 0x09 // specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up
|
2018-10-04 07:25:32 +01:00
|
|
|
#define MP3_CMD_RESET 0x0C // send a reset command to start fresh
|
|
|
|
#define MP3_CMD_DAC 0x1A // activate or deactivate the DAC output for an external amplifier, DAC is turned on by default
|
|
|
|
|
|
|
|
/*********************************************************************************************\
|
|
|
|
* calculate the checksum
|
|
|
|
* starts with cmd[1] with a length of 6 bytes
|
|
|
|
\*********************************************************************************************/
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
|
2018-09-07 06:59:08 +01:00
|
|
|
uint16_t MP3_Checksum(uint8_t *array)
|
|
|
|
{
|
|
|
|
uint16_t checksum = 0;
|
2019-06-30 15:44:36 +01:00
|
|
|
for (uint32_t i = 0; i < 6; i++) {
|
2018-09-07 06:59:08 +01:00
|
|
|
checksum += array[i];
|
|
|
|
}
|
|
|
|
checksum = checksum^0xffff;
|
2018-10-04 07:25:32 +01:00
|
|
|
return (checksum+1);
|
2018-09-07 06:59:08 +01:00
|
|
|
}
|
|
|
|
|
2018-10-04 07:25:32 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* init player
|
|
|
|
* define serial tx port fixed with 9600 baud
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
void MP3PlayerInit(void)
|
|
|
|
{
|
2020-04-26 16:33:27 +01:00
|
|
|
MP3Player = new TasmotaSerial(-1, Pin(GPIO_MP3_DFR562));
|
2022-06-22 22:47:32 +01:00
|
|
|
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
// start serial communication fixed to 9600 baud
|
2022-06-22 22:47:32 +01:00
|
|
|
if (MP3Player->begin(9600))
|
|
|
|
{
|
2018-09-07 06:59:08 +01:00
|
|
|
MP3Player->flush();
|
2018-10-04 07:25:32 +01:00
|
|
|
delay(1000);
|
|
|
|
MP3_CMD(MP3_CMD_RESET, MP3_CMD_RESET_VALUE); // reset the player to defaults
|
|
|
|
delay(3000);
|
2018-10-23 14:51:51 +01:00
|
|
|
MP3_CMD(MP3_CMD_VOLUME, MP3_VOLUME); // after reset set volume depending on the entry in the my_user_config.h
|
2022-06-22 22:47:32 +01:00
|
|
|
|
2018-09-07 06:59:08 +01:00
|
|
|
}
|
2022-06-22 22:47:32 +01:00
|
|
|
|
|
|
|
if (PinUsed(GPIO_MP3_DFR562_BUSY)) // optional MP3 player busy pin...
|
|
|
|
{
|
|
|
|
pinMode(Pin(GPIO_MP3_DFR562_BUSY), INPUT); // set pin to Input
|
|
|
|
}
|
|
|
|
|
2018-10-04 07:25:32 +01:00
|
|
|
return;
|
2018-09-07 06:59:08 +01:00
|
|
|
}
|
|
|
|
|
2021-01-21 14:10:17 +00:00
|
|
|
|
|
|
|
#ifdef USE_DY_SV17F
|
|
|
|
|
|
|
|
/*********************************************************************************************\
|
|
|
|
* specific for DY_SV17F
|
|
|
|
* create the MP3 commands payload, and send it via serial interface to the MP3 player
|
|
|
|
* only track,play,stop and volume supported
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
void MP3_SendCmd(uint8_t *scmd, uint8_t len)
|
|
|
|
{
|
2021-01-21 14:10:17 +00:00
|
|
|
uint16_t sum = 0;
|
2022-06-22 22:47:32 +01:00
|
|
|
for (uint32_t cnt = 0; cnt < len; cnt++)
|
|
|
|
{
|
2021-01-21 14:10:17 +00:00
|
|
|
sum += scmd[cnt];
|
|
|
|
}
|
|
|
|
scmd[len] = sum;
|
|
|
|
MP3Player->write(scmd, len + 1);
|
|
|
|
}
|
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
void MP3_CMD(uint8_t mp3cmd, uint16_t val)
|
|
|
|
{
|
2021-01-21 14:10:17 +00:00
|
|
|
uint8_t scmd[8];
|
|
|
|
uint8_t len = 0;
|
|
|
|
scmd[0]=0xAA;
|
2022-06-22 22:47:32 +01:00
|
|
|
switch (mp3cmd)
|
|
|
|
{
|
2021-01-21 14:10:17 +00:00
|
|
|
case MP3_CMD_TRACK:
|
|
|
|
scmd[1]=0x07;
|
|
|
|
scmd[2]=0x02;
|
|
|
|
scmd[3]=val>>8;
|
|
|
|
scmd[4]=val;
|
|
|
|
MP3_SendCmd(scmd, 5);
|
2022-06-22 22:47:32 +01:00
|
|
|
|
2021-01-21 14:10:17 +00:00
|
|
|
case MP3_CMD_PLAY:
|
|
|
|
scmd[1]=0x02;
|
|
|
|
scmd[2]=0x00;
|
|
|
|
scmd[3]=0xAC;
|
|
|
|
len = 4;
|
|
|
|
break;
|
2022-06-22 22:47:32 +01:00
|
|
|
|
2021-01-21 14:10:17 +00:00
|
|
|
case MP3_CMD_STOP:
|
|
|
|
scmd[1]=0x10;
|
|
|
|
scmd[2]=0x00;
|
|
|
|
scmd[3]=0xBA;
|
|
|
|
len = 4;
|
|
|
|
break;
|
|
|
|
case MP3_CMD_VOLUME:
|
|
|
|
scmd[1]=0x13;
|
|
|
|
scmd[2]=0x01;
|
|
|
|
scmd[3]=val;
|
|
|
|
len = 4;
|
|
|
|
break;
|
2022-06-22 22:47:32 +01:00
|
|
|
|
2021-01-21 14:10:17 +00:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MP3_SendCmd(scmd, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2018-10-04 07:25:32 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* create the MP3 commands payload, and send it via serial interface to the MP3 player
|
|
|
|
* data length is 6 = 6 bytes [FF 06 09 00 00 00] but not counting the start, end, and verification.
|
|
|
|
* {start byte, version, length, command, feedback, para MSB, para LSB, chks MSB, chks LSB, end byte};
|
|
|
|
* {cmd[0] , cmd[1] , cmd[2], cmd[3] , cmd[4] , cmd[5] , cmd[6] , cmd[7] , cmd[8] , cmd[9] };
|
|
|
|
* {0x7e , 0xff , 6 , 0 , 0/1 , 0 , 0 , 0 , 0 , 0xef };
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
void MP3_CMD(uint8_t mp3cmd,uint16_t val)
|
|
|
|
{
|
2018-10-04 07:25:32 +01:00
|
|
|
uint8_t i = 0;
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
uint8_t cmd[10] = {0x7e,0xff,6,0,0,0,0,0,0,0xef}; // fill array
|
|
|
|
cmd[3] = mp3cmd; // mp3 command value
|
2018-10-04 07:25:32 +01:00
|
|
|
cmd[4] = 0; // feedback, 1=yes, 0=no, yet not use
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
cmd[5] = val>>8; // data value, shift 8 byte right
|
|
|
|
cmd[6] = val; // data value low byte
|
2018-10-04 07:25:32 +01:00
|
|
|
uint16_t chks = MP3_Checksum(&cmd[1]); // see calculate the checksum
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
cmd[7] = chks>>8; // checksum. shift 8 byte right
|
|
|
|
cmd[8] = chks; // checksum low byte
|
|
|
|
MP3Player->write(cmd, sizeof(cmd)); // write mp3 data array to player
|
2018-10-04 07:25:32 +01:00
|
|
|
delay(1000);
|
2022-06-22 22:47:32 +01:00
|
|
|
if (mp3cmd == MP3_CMD_RESET)
|
|
|
|
{
|
2018-10-23 14:51:51 +01:00
|
|
|
MP3_CMD(MP3_CMD_VOLUME, MP3_VOLUME); // after reset set volume depending on the entry in the my_user_config.h
|
2018-10-04 07:25:32 +01:00
|
|
|
}
|
|
|
|
return;
|
2018-09-07 06:59:08 +01:00
|
|
|
}
|
2021-01-21 14:10:17 +00:00
|
|
|
#endif // USE_DY_SV17F
|
2022-06-22 22:47:32 +01:00
|
|
|
|
2018-10-04 07:25:32 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* check the MP3 commands
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
bool MP3PlayerCmd(void)
|
|
|
|
{
|
2018-09-07 06:59:08 +01:00
|
|
|
char command[CMDSZ];
|
2019-01-28 13:08:33 +00:00
|
|
|
bool serviced = true;
|
2018-09-07 06:59:08 +01:00
|
|
|
uint8_t disp_len = strlen(D_CMND_MP3);
|
2018-09-07 09:54:24 +01:00
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
if (!strncasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_MP3), disp_len)) // prefix
|
|
|
|
{
|
2018-09-07 06:59:08 +01:00
|
|
|
int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic + disp_len, kMP3_Commands);
|
2018-11-11 15:52:09 +00:00
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
switch (command_code)
|
|
|
|
{
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
case CMND_MP3_TRACK:
|
2022-06-22 22:47:32 +01:00
|
|
|
case CMND_MP3_FOLDER: // <-------- trl
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
case CMND_MP3_VOLUME:
|
|
|
|
case CMND_MP3_EQ:
|
|
|
|
case CMND_MP3_DEVICE:
|
2018-10-04 07:25:32 +01:00
|
|
|
case CMND_MP3_DAC:
|
2022-06-22 22:47:32 +01:00
|
|
|
// play a track, set volume, select EQ, specify file device
|
|
|
|
if (XdrvMailbox.data_len > 0)
|
|
|
|
{
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
if (command_code == CMND_MP3_TRACK) { MP3_CMD(MP3_CMD_TRACK, XdrvMailbox.payload); }
|
2022-06-22 22:47:32 +01:00
|
|
|
if (command_code == CMND_MP3_FOLDER) { MP3_CMD(MP3_CMD_FOLDER, XdrvMailbox.payload); } // <-------- trl
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
if (command_code == CMND_MP3_VOLUME) { MP3_CMD(MP3_CMD_VOLUME, XdrvMailbox.payload * 30 / 100); }
|
|
|
|
if (command_code == CMND_MP3_EQ) { MP3_CMD(MP3_CMD_EQ, XdrvMailbox.payload); }
|
|
|
|
if (command_code == CMND_MP3_DEVICE) { MP3_CMD(MP3_CMD_DEVICE, XdrvMailbox.payload); }
|
2018-10-04 07:25:32 +01:00
|
|
|
if (command_code == CMND_MP3_DAC) { MP3_CMD(MP3_CMD_DAC, XdrvMailbox.payload); }
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
}
|
2019-03-23 16:00:59 +00:00
|
|
|
Response_P(S_JSON_MP3_COMMAND_NVALUE, command, XdrvMailbox.payload);
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
break;
|
2022-06-22 22:47:32 +01:00
|
|
|
|
2021-01-21 14:10:17 +00:00
|
|
|
#ifndef USE_DY_SV17F
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
case CMND_MP3_PLAY:
|
2021-01-21 14:10:17 +00:00
|
|
|
#endif // USE_DY_SV17F
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
case CMND_MP3_PAUSE:
|
|
|
|
case CMND_MP3_STOP:
|
2018-10-04 07:25:32 +01:00
|
|
|
case CMND_MP3_RESET:
|
2018-11-11 15:52:09 +00:00
|
|
|
// play or re-play after pause, pause, stop,
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
if (command_code == CMND_MP3_PLAY) { MP3_CMD(MP3_CMD_PLAY, 0); }
|
|
|
|
if (command_code == CMND_MP3_PAUSE) { MP3_CMD(MP3_CMD_PAUSE, 0); }
|
|
|
|
if (command_code == CMND_MP3_STOP) { MP3_CMD(MP3_CMD_STOP, 0); }
|
2018-10-04 07:25:32 +01:00
|
|
|
if (command_code == CMND_MP3_RESET) { MP3_CMD(MP3_CMD_RESET, 0); }
|
2019-03-23 16:00:59 +00:00
|
|
|
Response_P(S_JSON_MP3_COMMAND, command, XdrvMailbox.payload);
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
break;
|
2021-01-21 14:10:17 +00:00
|
|
|
|
|
|
|
#ifdef USE_DY_SV17F
|
|
|
|
case CMND_MP3_PLAY:
|
2022-06-22 22:47:32 +01:00
|
|
|
if (XdrvMailbox.data_len > 0)
|
|
|
|
{
|
2021-01-21 14:10:17 +00:00
|
|
|
uint8_t scmd[64];
|
|
|
|
scmd[0] = 0xAA;
|
|
|
|
scmd[1] = 0x08;
|
|
|
|
scmd[2] = XdrvMailbox.data_len + 1;
|
|
|
|
scmd[3] = 2;
|
|
|
|
char *cp = XdrvMailbox.data;
|
|
|
|
scmd[4] = *cp;
|
|
|
|
for (uint8_t i = 1; i < XdrvMailbox.data_len; i++) {
|
|
|
|
if (cp[i]=='.') {
|
|
|
|
scmd[i + 4] = '*';
|
|
|
|
} else {
|
|
|
|
scmd[i + 4] = toupper(cp[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MP3_SendCmd(scmd, XdrvMailbox.data_len + 4);
|
|
|
|
Response_P(S_JSON_COMMAND_SVALUE, command, XdrvMailbox.data);
|
2022-06-22 22:47:32 +01:00
|
|
|
} else
|
|
|
|
{
|
2021-01-21 14:10:17 +00:00
|
|
|
MP3_CMD(MP3_CMD_PLAY, 0);
|
2022-06-22 22:47:32 +01:00
|
|
|
Response_P(S_JSON_MP3_COMMAND, command, XdrvMailbox.payload)
|
2021-01-21 14:10:17 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif // USE_DY_SV17F
|
2022-06-22 22:47:32 +01:00
|
|
|
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
default:
|
2018-10-04 07:25:32 +01:00
|
|
|
// else for Unknown command
|
|
|
|
serviced = false;
|
Added version info and new MP3 Player commands
- Added the version information to have some little hints what is done.
- Added new commands and changed two commands from the first version.
-- Intention was to get as less of commands as needed.
-- There will be possible a version with much more function and serial->read.
Command list:
- MP3TRACK
-- specify playback of a track, e.g. MP3Track 003.
- MP3PLAY
-- Play, works as a normal play on a real MP3 Player, starts at 001.mp3 file on the selected device.
- MP3PAUSE
-- Pause, was original designed as stop, see data sheet.
- MP3STOP
-- Stop, it's a real stop now, in the original version it was a pause command.
- MP3VOLUME
-- specifies the volume and means a console input as 0..100.
- MP3EQ
-- specify the EQ(0/1/2/3/4/5), 0:Normal, 1:Pop, 2:Rock, 3:Jazz, 4:Classic, 5:Bass.
- MP3DEVICE
-- specify playback device, USB=1, SD-Card=2, default is 2 also after reset or power down/up.
2018-09-15 08:33:53 +01:00
|
|
|
break;
|
2018-09-07 06:59:08 +01:00
|
|
|
}
|
2022-06-22 22:47:32 +01:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-07 06:59:08 +01:00
|
|
|
return serviced;
|
|
|
|
}
|
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
void MP3_EVERY_SECOND(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (PinUsed(GPIO_MP3_DFR562_BUSY)) // optional MP3 player busy pin... // <-------- trl
|
|
|
|
{
|
|
|
|
// Low is busy... we are using this format to allow Berry to receive a busy event
|
|
|
|
MP2BusyFlag = digitalRead(Pin(GPIO_MP3_DFR562_BUSY));
|
|
|
|
Response_P(PSTR("{\"MP3Player\":{\"MP3Busy\":%u}}"), MP2BusyFlag);
|
|
|
|
XdrvRulesProcess(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-07 06:59:08 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* Interface
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2019-01-28 13:08:33 +00:00
|
|
|
bool Xdrv14(uint8_t function)
|
2018-09-07 06:59:08 +01:00
|
|
|
{
|
2019-01-28 13:08:33 +00:00
|
|
|
bool result = false;
|
2018-09-07 06:59:08 +01:00
|
|
|
|
2022-06-22 22:47:32 +01:00
|
|
|
if (PinUsed(GPIO_MP3_DFR562))
|
|
|
|
{
|
|
|
|
switch (function)
|
|
|
|
{
|
2018-11-11 15:52:09 +00:00
|
|
|
case FUNC_PRE_INIT:
|
|
|
|
MP3PlayerInit(); // init and start communication
|
|
|
|
break;
|
2022-06-22 22:47:32 +01:00
|
|
|
|
2018-11-11 15:52:09 +00:00
|
|
|
case FUNC_COMMAND:
|
|
|
|
result = MP3PlayerCmd(); // return result from mp3 player command
|
|
|
|
break;
|
2022-06-22 22:47:32 +01:00
|
|
|
|
|
|
|
case FUNC_EVERY_SECOND:
|
2022-06-24 13:55:19 +01:00
|
|
|
MP3_EVERY_SECOND();
|
|
|
|
break;
|
2018-11-11 15:52:09 +00:00
|
|
|
}
|
2018-09-07 06:59:08 +01:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-09-07 09:54:24 +01:00
|
|
|
#endif // USE_MP3_PLAYER
|