-
Notifications
You must be signed in to change notification settings - Fork 886
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
477 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ build_src_filter = | |
|
||
lib_deps= | ||
${arduino_base.lib_deps} | ||
jgromes/RadioLib@^6.2.0 | ||
|
||
lib_ignore = | ||
BluetoothOTA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#pragma once | ||
#include "PowerFSM.h" | ||
#include "concurrency/OSThread.h" | ||
#include "configuration.h" | ||
#include "main.h" | ||
#include "sleep.h" | ||
|
||
#ifdef HAS_I2S | ||
#include <AudioFileSourcePROGMEM.h> | ||
#include <AudioGeneratorRTTTL.h> | ||
#include <AudioOutputI2S.h> | ||
#include <ESP8266SAM.h> | ||
|
||
#define AUDIO_THREAD_INTERVAL_MS 100 | ||
|
||
class AudioThread : public concurrency::OSThread | ||
{ | ||
public: | ||
AudioThread() : OSThread("AudioThread") { initOutput(); } | ||
|
||
void beginRttl(const void *data, uint32_t len) | ||
{ | ||
setCPUFast(true); | ||
rtttlFile = new AudioFileSourcePROGMEM(data, len); | ||
i2sRtttl = new AudioGeneratorRTTTL(); | ||
i2sRtttl->begin(rtttlFile, audioOut); | ||
} | ||
|
||
bool isPlaying() | ||
{ | ||
if (i2sRtttl != nullptr) { | ||
return i2sRtttl->isRunning() && i2sRtttl->loop(); | ||
} | ||
return false; | ||
} | ||
|
||
void stop() | ||
{ | ||
if (i2sRtttl != nullptr) { | ||
i2sRtttl->stop(); | ||
delete i2sRtttl; | ||
i2sRtttl = nullptr; | ||
} | ||
if (rtttlFile != nullptr) { | ||
delete rtttlFile; | ||
rtttlFile = nullptr; | ||
} | ||
|
||
setCPUFast(false); | ||
} | ||
|
||
protected: | ||
int32_t runOnce() override | ||
{ | ||
canSleep = true; // Assume we should not keep the board awake | ||
|
||
// if (i2sRtttl != nullptr && i2sRtttl->isRunning()) { | ||
// i2sRtttl->loop(); | ||
// } | ||
return AUDIO_THREAD_INTERVAL_MS; | ||
} | ||
|
||
private: | ||
void initOutput() | ||
{ | ||
audioOut = new AudioOutputI2S(1, AudioOutputI2S::EXTERNAL_I2S); | ||
audioOut->SetPinout(DAC_I2S_BCK, DAC_I2S_WS, DAC_I2S_DOUT); | ||
audioOut->SetGain(0.2); | ||
}; | ||
|
||
AudioGeneratorRTTTL *i2sRtttl = nullptr; | ||
AudioOutputI2S *audioOut; | ||
|
||
AudioFileSourcePROGMEM *rtttlFile; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.