mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 19:56:30 +00:00
Added I2SRtttl command (#18423)
This commit is contained in:
parent
3d0354b6fb
commit
2a8b859e37
@ -223,6 +223,10 @@ void sayTime(int hour, int minutes);
|
|||||||
void Cmd_MicRec(void);
|
void Cmd_MicRec(void);
|
||||||
void Cmd_wav2mp3(void);
|
void Cmd_wav2mp3(void);
|
||||||
void Cmd_Time(void);
|
void Cmd_Time(void);
|
||||||
|
#ifdef USE_I2S_RTTTL
|
||||||
|
void Rtttl(char *buffer);
|
||||||
|
void Cmd_I2SRtttl(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
void copy_micpars(uint32_t port) {
|
void copy_micpars(uint32_t port) {
|
||||||
audio_i2s.mic_mclk = audio_i2s.mclk;
|
audio_i2s.mic_mclk = audio_i2s.mclk;
|
||||||
@ -606,6 +610,9 @@ const char kI2SAudio_Commands[] PROGMEM = "I2S|"
|
|||||||
#ifdef USE_I2S_SAY_TIME
|
#ifdef USE_I2S_SAY_TIME
|
||||||
"|Time"
|
"|Time"
|
||||||
#endif // USE_I2S_SAY_TIME
|
#endif // USE_I2S_SAY_TIME
|
||||||
|
#ifdef USE_I2S_RTTTL
|
||||||
|
"|Rtttl"
|
||||||
|
#endif
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
"|Play"
|
"|Play"
|
||||||
#ifdef USE_I2S_WEBRADIO
|
#ifdef USE_I2S_WEBRADIO
|
||||||
@ -629,6 +636,9 @@ void (* const I2SAudio_Command[])(void) PROGMEM = {
|
|||||||
#ifdef USE_I2S_SAY_TIME
|
#ifdef USE_I2S_SAY_TIME
|
||||||
,&Cmd_Time
|
,&Cmd_Time
|
||||||
#endif // USE_I2S_SAY_TIME
|
#endif // USE_I2S_SAY_TIME
|
||||||
|
#ifdef USE_I2S_RTTTL
|
||||||
|
,&Cmd_I2SRtttl
|
||||||
|
#endif
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
,&Cmd_Play
|
,&Cmd_Play
|
||||||
#ifdef USE_I2S_WEBRADIO
|
#ifdef USE_I2S_WEBRADIO
|
||||||
@ -671,6 +681,15 @@ void Cmd_Say(void) {
|
|||||||
ResponseCmndChar(XdrvMailbox.data);
|
ResponseCmndChar(XdrvMailbox.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_I2S_RTTTL
|
||||||
|
void Cmd_I2SRtttl(void) {
|
||||||
|
if (XdrvMailbox.data_len > 0) {
|
||||||
|
Rtttl(XdrvMailbox.data);
|
||||||
|
}
|
||||||
|
ResponseCmndChar(XdrvMailbox.data);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Interface
|
* Interface
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
54
tasmota/tasmota_xdrv_driver/xdrv_42_6_i2s_rtttl.ino
Normal file
54
tasmota/tasmota_xdrv_driver/xdrv_42_6_i2s_rtttl.ino
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
audio is2 RTTTL
|
||||||
|
|
||||||
|
Copyright (C) 2023 Fernando Pena López
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#if (defined(USE_I2S_AUDIO) || defined(USE_TTGO_WATCH) || defined(USE_M5STACK_CORE2) || defined(ESP32S3_BOX))
|
||||||
|
#ifdef USE_I2S_RTTTL
|
||||||
|
#include "AudioFileSourcePROGMEM.h"
|
||||||
|
#include "AudioGeneratorRTTTL.h"
|
||||||
|
|
||||||
|
void Rtttl(char *buffer);
|
||||||
|
|
||||||
|
void Rtttl(char *buffer) {
|
||||||
|
|
||||||
|
if (!audio_i2s.out) return;
|
||||||
|
|
||||||
|
AudioGeneratorRTTTL *rtttl;
|
||||||
|
AudioFileSourcePROGMEM *file = NULL;
|
||||||
|
|
||||||
|
file = new AudioFileSourcePROGMEM(buffer, strlen(buffer));
|
||||||
|
rtttl = new AudioGeneratorRTTTL();
|
||||||
|
|
||||||
|
AUDIO_PWR_ON
|
||||||
|
rtttl->begin(file, audio_i2s.out);
|
||||||
|
|
||||||
|
while(rtttl->isRunning()) {
|
||||||
|
if (!rtttl->loop()) {
|
||||||
|
rtttl->stop();
|
||||||
|
} else {
|
||||||
|
delay(1); // Keep the dog happy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
audio_i2s.out->stop();
|
||||||
|
AUDIO_PWR_OFF
|
||||||
|
delete rtttl;
|
||||||
|
delete file;
|
||||||
|
}
|
||||||
|
#endif // USE_I2S_RTTTL
|
||||||
|
#endif // is2audio
|
Loading…
x
Reference in New Issue
Block a user