add duration to custompage
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
github: [makuna]
|
||||
custom: ["https://paypal.me/MakunaGithub"]
|
||||
@@ -1,105 +0,0 @@
|
||||
// this example will play a track and then every 60 seconds
|
||||
// it will play an advertisement
|
||||
//
|
||||
// it expects the sd card to contain the following mp3 files
|
||||
// but doesn't care whats in them
|
||||
//
|
||||
// sd:/01/001.mp3 - the song to play, the longer the better
|
||||
// sd:/advert/0001.mp3 - the advertisement to interrupt the song, keep it short
|
||||
|
||||
#include <SoftwareSerial.h>
|
||||
#include <DFMiniMp3.h>
|
||||
|
||||
// implement a notification class,
|
||||
// its member methods will get called
|
||||
//
|
||||
class Mp3Notify
|
||||
{
|
||||
public:
|
||||
static void PrintlnSourceAction(DfMp3_PlaySources source, const char* action)
|
||||
{
|
||||
if (source & DfMp3_PlaySources_Sd)
|
||||
{
|
||||
Serial.print("SD Card, ");
|
||||
}
|
||||
if (source & DfMp3_PlaySources_Usb)
|
||||
{
|
||||
Serial.print("USB Disk, ");
|
||||
}
|
||||
if (source & DfMp3_PlaySources_Flash)
|
||||
{
|
||||
Serial.print("Flash, ");
|
||||
}
|
||||
Serial.println(action);
|
||||
}
|
||||
static void OnError(uint16_t errorCode)
|
||||
{
|
||||
// see DfMp3_Error for code meaning
|
||||
Serial.println();
|
||||
Serial.print("Com Error ");
|
||||
Serial.println(errorCode);
|
||||
}
|
||||
static void OnPlayFinished(DfMp3_PlaySources source, uint16_t track)
|
||||
{
|
||||
Serial.print("Play finished for #");
|
||||
Serial.println(track);
|
||||
}
|
||||
static void OnPlaySourceOnline(DfMp3_PlaySources source)
|
||||
{
|
||||
PrintlnSourceAction(source, "online");
|
||||
}
|
||||
static void OnPlaySourceInserted(DfMp3_PlaySources source)
|
||||
{
|
||||
PrintlnSourceAction(source, "inserted");
|
||||
}
|
||||
static void OnPlaySourceRemoved(DfMp3_PlaySources source)
|
||||
{
|
||||
PrintlnSourceAction(source, "removed");
|
||||
}
|
||||
};
|
||||
|
||||
// instance a DFMiniMp3 object,
|
||||
// defined with the above notification class and the hardware serial class
|
||||
//
|
||||
DFMiniMp3<HardwareSerial, Mp3Notify> mp3(Serial1);
|
||||
|
||||
// Some arduino boards only have one hardware serial port, so a software serial port is needed instead.
|
||||
// comment out the above definition and uncomment these lines
|
||||
//SoftwareSerial secondarySerial(10, 11); // RX, TX
|
||||
//DFMiniMp3<SoftwareSerial, Mp3Notify> mp3(secondarySerial);
|
||||
|
||||
uint32_t lastAdvert; // track time for last advertisement
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.println("initializing...");
|
||||
|
||||
mp3.begin();
|
||||
uint16_t volume = mp3.getVolume();
|
||||
Serial.print("volume was ");
|
||||
Serial.println(volume);
|
||||
mp3.setVolume(24);
|
||||
volume = mp3.getVolume();
|
||||
Serial.print(" and changed to ");
|
||||
Serial.println(volume);
|
||||
|
||||
Serial.println("track 1 from folder 1");
|
||||
mp3.playFolderTrack(1, 1); // sd:/01/001.mp3
|
||||
|
||||
lastAdvert = millis();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint32_t now = millis();
|
||||
if ((now - lastAdvert) > 60000)
|
||||
{
|
||||
// interrupt the song and play the advertisement, it will
|
||||
// return to the song when its done playing automatically
|
||||
mp3.playAdvertisement(1); // sd:/advert/0001.mp3
|
||||
lastAdvert = now;
|
||||
}
|
||||
mp3.loop();
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
// this example will play a track and then
|
||||
// every five seconds play another track
|
||||
//
|
||||
// it expects the sd card to contain these three mp3 files
|
||||
// but doesn't care whats in them
|
||||
//
|
||||
// sd:/mp3/0001.mp3
|
||||
// sd:/mp3/0002.mp3
|
||||
// sd:/mp3/0003.mp3
|
||||
|
||||
#include <SoftwareSerial.h>
|
||||
#include <DFMiniMp3.h>
|
||||
|
||||
// implement a notification class,
|
||||
// its member methods will get called
|
||||
//
|
||||
class Mp3Notify
|
||||
{
|
||||
public:
|
||||
static void PrintlnSourceAction(DfMp3_PlaySources source, const char* action)
|
||||
{
|
||||
if (source & DfMp3_PlaySources_Sd)
|
||||
{
|
||||
Serial.print("SD Card, ");
|
||||
}
|
||||
if (source & DfMp3_PlaySources_Usb)
|
||||
{
|
||||
Serial.print("USB Disk, ");
|
||||
}
|
||||
if (source & DfMp3_PlaySources_Flash)
|
||||
{
|
||||
Serial.print("Flash, ");
|
||||
}
|
||||
Serial.println(action);
|
||||
}
|
||||
static void OnError(uint16_t errorCode)
|
||||
{
|
||||
// see DfMp3_Error for code meaning
|
||||
Serial.println();
|
||||
Serial.print("Com Error ");
|
||||
Serial.println(errorCode);
|
||||
}
|
||||
static void OnPlayFinished(DfMp3_PlaySources source, uint16_t track)
|
||||
{
|
||||
Serial.print("Play finished for #");
|
||||
Serial.println(track);
|
||||
}
|
||||
static void OnPlaySourceOnline(DfMp3_PlaySources source)
|
||||
{
|
||||
PrintlnSourceAction(source, "online");
|
||||
}
|
||||
static void OnPlaySourceInserted(DfMp3_PlaySources source)
|
||||
{
|
||||
PrintlnSourceAction(source, "inserted");
|
||||
}
|
||||
static void OnPlaySourceRemoved(DfMp3_PlaySources source)
|
||||
{
|
||||
PrintlnSourceAction(source, "removed");
|
||||
}
|
||||
};
|
||||
|
||||
// instance a DFMiniMp3 object,
|
||||
// defined with the above notification class and the hardware serial class
|
||||
//
|
||||
DFMiniMp3<HardwareSerial, Mp3Notify> mp3(Serial1);
|
||||
|
||||
// Some arduino boards only have one hardware serial port, so a software serial port is needed instead.
|
||||
// comment out the above definition and uncomment these lines
|
||||
//SoftwareSerial secondarySerial(10, 11); // RX, TX
|
||||
//DFMiniMp3<SoftwareSerial, Mp3Notify> mp3(secondarySerial);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.println("initializing...");
|
||||
|
||||
mp3.begin();
|
||||
|
||||
uint16_t volume = mp3.getVolume();
|
||||
Serial.print("volume ");
|
||||
Serial.println(volume);
|
||||
mp3.setVolume(24);
|
||||
|
||||
uint16_t count = mp3.getTotalTrackCount(DfMp3_PlaySource_Sd);
|
||||
Serial.print("files ");
|
||||
Serial.println(count);
|
||||
|
||||
Serial.println("starting...");
|
||||
}
|
||||
|
||||
void waitMilliseconds(uint16_t msWait)
|
||||
{
|
||||
uint32_t start = millis();
|
||||
|
||||
while ((millis() - start) < msWait)
|
||||
{
|
||||
// calling mp3.loop() periodically allows for notifications
|
||||
// to be handled without interrupts
|
||||
mp3.loop();
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println("track 1");
|
||||
mp3.playMp3FolderTrack(1); // sd:/mp3/0001.mp3
|
||||
|
||||
waitMilliseconds(5000);
|
||||
|
||||
Serial.println("track 2");
|
||||
mp3.playMp3FolderTrack(2); // sd:/mp3/0002.mp3
|
||||
|
||||
waitMilliseconds(5000);
|
||||
|
||||
Serial.println("track 3");
|
||||
mp3.playMp3FolderTrack(3); // sd:/mp3/0002.mp3
|
||||
|
||||
waitMilliseconds(5000);
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
// this example will play a random track from all on the sd
|
||||
//
|
||||
// it expects the sd card to contain some mp3 files
|
||||
|
||||
#include <SoftwareSerial.h>
|
||||
#include <DFMiniMp3.h>
|
||||
|
||||
// implement a notification class,
|
||||
// its member methods will get called
|
||||
//
|
||||
class Mp3Notify
|
||||
{
|
||||
public:
|
||||
static void PrintlnSourceAction(DfMp3_PlaySources source, const char* action)
|
||||
{
|
||||
if (source & DfMp3_PlaySources_Sd)
|
||||
{
|
||||
Serial.print("SD Card, ");
|
||||
}
|
||||
if (source & DfMp3_PlaySources_Usb)
|
||||
{
|
||||
Serial.print("USB Disk, ");
|
||||
}
|
||||
if (source & DfMp3_PlaySources_Flash)
|
||||
{
|
||||
Serial.print("Flash, ");
|
||||
}
|
||||
Serial.println(action);
|
||||
}
|
||||
static void OnError(uint16_t errorCode)
|
||||
{
|
||||
// see DfMp3_Error for code meaning
|
||||
Serial.println();
|
||||
Serial.print("Com Error ");
|
||||
Serial.println(errorCode);
|
||||
}
|
||||
static void OnPlayFinished(DfMp3_PlaySources source, uint16_t track)
|
||||
{
|
||||
Serial.print("Play finished for #");
|
||||
Serial.println(track);
|
||||
}
|
||||
static void OnPlaySourceOnline(DfMp3_PlaySources source)
|
||||
{
|
||||
PrintlnSourceAction(source, "online");
|
||||
}
|
||||
static void OnPlaySourceInserted(DfMp3_PlaySources source)
|
||||
{
|
||||
PrintlnSourceAction(source, "inserted");
|
||||
}
|
||||
static void OnPlaySourceRemoved(DfMp3_PlaySources source)
|
||||
{
|
||||
PrintlnSourceAction(source, "removed");
|
||||
}
|
||||
};
|
||||
|
||||
// instance a DFMiniMp3 object,
|
||||
// defined with the above notification class and the hardware serial class
|
||||
//
|
||||
DFMiniMp3<HardwareSerial, Mp3Notify> mp3(Serial1);
|
||||
|
||||
// Some arduino boards only have one hardware serial port, so a software serial port is needed instead.
|
||||
// comment out the above definition and uncomment these lines
|
||||
//SoftwareSerial secondarySerial(10, 11); // RX, TX
|
||||
//DFMiniMp3<SoftwareSerial, Mp3Notify> mp3(secondarySerial);
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.println("initializing...");
|
||||
|
||||
mp3.begin();
|
||||
mp3.reset();
|
||||
|
||||
// show some properties and set the volume
|
||||
uint16_t volume = mp3.getVolume();
|
||||
Serial.print("volume ");
|
||||
Serial.println(volume);
|
||||
mp3.setVolume(24);
|
||||
|
||||
uint16_t count = mp3.getTotalTrackCount(DfMp3_PlaySource_Sd);
|
||||
Serial.print("files ");
|
||||
Serial.println(count);
|
||||
|
||||
uint16_t mode = mp3.getPlaybackMode();
|
||||
Serial.print("playback mode ");
|
||||
Serial.println(mode);
|
||||
|
||||
Serial.println("starting...");
|
||||
|
||||
mp3.playRandomTrackFromAll(); // random of all folders on sd
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// calling mp3.loop() periodically allows for notifications
|
||||
// to be handled without interrupts
|
||||
mp3.loop();
|
||||
}
|
||||
@@ -102,7 +102,6 @@ private:
|
||||
uint8_t updateInterval = 33;
|
||||
|
||||
uint8_t getnextAppNumber();
|
||||
void drawIndicator();
|
||||
void drawApp();
|
||||
void drawOverlays();
|
||||
void tick();
|
||||
@@ -110,7 +109,6 @@ private:
|
||||
|
||||
public:
|
||||
MatrixDisplayUi(FastLED_NeoMatrix *matrix);
|
||||
|
||||
uint8_t AppCount = 0;
|
||||
/**
|
||||
* Initialise the display
|
||||
|
||||
@@ -24,16 +24,17 @@ void FSWebServer::addHandler(const Uri &uri, HTTPMethod method, WebServerClass::
|
||||
webserver->on(uri, method, fn);
|
||||
}
|
||||
|
||||
|
||||
void FSWebServer::onNotFound(WebServerClass::THandlerFunction fn)
|
||||
{
|
||||
webserver->onNotFound(fn);
|
||||
}
|
||||
|
||||
void FSWebServer::addHandler(const Uri &uri, WebServerClass::THandlerFunction handler)
|
||||
{
|
||||
webserver->on(uri, HTTP_ANY, handler);
|
||||
}
|
||||
|
||||
void FSWebServer::onNotFound(WebServerClass::THandlerFunction handler)
|
||||
{
|
||||
webserver->onNotFound(handler);
|
||||
}
|
||||
|
||||
// List all files saved in the selected filesystem
|
||||
bool FSWebServer::checkDir(char *dirname, uint8_t levels)
|
||||
{
|
||||
@@ -85,7 +86,7 @@ bool FSWebServer::begin(const char *path)
|
||||
webserver->on("/edit", HTTP_PUT, std::bind(&FSWebServer::handleFileCreate, this));
|
||||
webserver->on("/edit", HTTP_DELETE, std::bind(&FSWebServer::handleFileDelete, this));
|
||||
#endif
|
||||
//webserver->onNotFound(std::bind(&FSWebServer::handleRequest, this));
|
||||
webserver->onNotFound(std::bind(&FSWebServer::handleRequest, this));
|
||||
webserver->on("/favicon.ico", HTTP_GET, std::bind(&FSWebServer::replyOK, this));
|
||||
webserver->on("/", HTTP_GET, std::bind(&FSWebServer::handleIndex, this));
|
||||
#ifdef INCLUDE_SETUP_HTM
|
||||
@@ -158,6 +159,7 @@ IPAddress FSWebServer::startWiFi(uint32_t timeout, const char *apSSID, const cha
|
||||
#elif defined(ESP32)
|
||||
wifi_config_t conf;
|
||||
esp_wifi_get_config(WIFI_IF_STA, &conf);
|
||||
|
||||
_ssid = reinterpret_cast<const char *>(conf.sta.ssid);
|
||||
_pass = reinterpret_cast<const char *>(conf.sta.password);
|
||||
#endif
|
||||
@@ -167,6 +169,7 @@ IPAddress FSWebServer::startWiFi(uint32_t timeout, const char *apSSID, const cha
|
||||
WiFi.begin(_ssid, _pass);
|
||||
Serial.print(F("Connecting to "));
|
||||
Serial.println(_ssid);
|
||||
|
||||
uint32_t startTime = millis();
|
||||
while (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
@@ -174,6 +177,8 @@ IPAddress FSWebServer::startWiFi(uint32_t timeout, const char *apSSID, const cha
|
||||
Serial.print(".");
|
||||
if (WiFi.status() == WL_CONNECTED)
|
||||
{
|
||||
WiFi.setAutoReconnect(true);
|
||||
WiFi.persistent(true);
|
||||
ip = WiFi.localIP();
|
||||
return ip;
|
||||
}
|
||||
@@ -921,4 +926,4 @@ void FSWebServer::handleStatus()
|
||||
webserver->send(200, "application/json", json);
|
||||
}
|
||||
|
||||
#endif // INCLUDE_EDIT_HTM
|
||||
#endif // INCLUDE_EDIT_HTM
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <memory>
|
||||
#include <typeinfo>
|
||||
#include <base64.h>
|
||||
//#include <FS.h>
|
||||
// #include <FS.h>
|
||||
#include <LittleFS.h>
|
||||
|
||||
#define INCLUDE_EDIT_HTM
|
||||
@@ -82,11 +82,11 @@ public:
|
||||
bool begin(const char *path = nullptr);
|
||||
|
||||
void run();
|
||||
|
||||
void onNotFound(WebServerClass::THandlerFunction fn);
|
||||
|
||||
void addHandler(const Uri &uri, HTTPMethod method, WebServerClass::THandlerFunction fn);
|
||||
|
||||
void addHandler(const Uri &uri, WebServerClass::THandlerFunction handler);
|
||||
void onNotFound(WebServerClass::THandlerFunction handler);
|
||||
|
||||
void setCaptiveWebage(const char *url);
|
||||
|
||||
@@ -256,13 +256,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool saveOptionValue(const char *label, T val)
|
||||
{
|
||||
// Öffne die Datei im Lesemodus, um den Inhalt des Dokuments beizubehalten
|
||||
File file = m_filesystem->open("/config.json", "r");
|
||||
DynamicJsonDocument doc(file.size()* 1.33);
|
||||
DynamicJsonDocument doc(file.size() * 1.33);
|
||||
|
||||
if (file)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user