improvements

This commit is contained in:
Stefan Ostermann 2023-10-09 21:24:57 +02:00
parent 21119603cb
commit 6684be01eb
7 changed files with 62 additions and 2 deletions

View File

@ -101,6 +101,15 @@ Wake up / Next -> 04 and GND
Previous -> 16 and GND
```
## System sounds
Place these sounds in the folder `system` on the SD card:
* sleep.mp3
* start.mp3
sleep.mp3 will be played just before the timed shutdown, start.mp3 will be played if the box started and initialized successfully.
## TODOs
* Card Reader with SPI. Configure hspi, second SPI channel? Or does SD Card + RFID run at the same channel?

BIN
sounds/sleep.mp3 Normal file

Binary file not shown.

BIN
sounds/start.mp3 Normal file

Binary file not shown.

View File

@ -64,7 +64,8 @@ void DirectoryNode::buildDirectoryTree(const char *currentPath)
{
break;
}
if (entry.isDirectory())
if (entry.isDirectory() && strcmp(entry.name(),sys_dir.c_str()))
{
DirectoryNode *newNode = new DirectoryNode(entry.name());
subdirectories.push_back(newNode);

View File

@ -4,6 +4,8 @@
#include <SD.h>
#include <vector>
const String sys_dir = "system";
class DirectoryNode {
private:
String name;

View File

@ -56,10 +56,29 @@ unsigned long lastStart = 0;
unsigned long lastInteraction = 0;
boolean sleepSoundPlayed = false;
boolean startupSoundPlayed = false;
boolean continuousMode = false;
uint8_t buttontoignore = 0;
const int startDelay = 250;
const String sleep_sound = "sleep.mp3";
const String startup_sound = "start.mp3";
/*
const long sleepMessageDelay = 28000;
// wait until deep sleep:
const long sleepDelay = 30000;
*/
const long sleepMessageDelay = 1798000;
// wait until deep sleep:
const long sleepDelay = 1800000;

View File

@ -38,6 +38,12 @@
#include "css.h"
#include "DirectoryNode.h"
#define SOUND_STARTUP "start.mp3"
#define SOUND_SLEEP "sleep.mp3"
File root;
File mp3File;
@ -104,6 +110,11 @@ void playSongByName(String song)
deactivateSD();
}
void playSongByPath(String path)
{
playFile(path.c_str());
}
void playSongByRFID(String id)
{
String song = rfid_map[id];
@ -128,6 +139,7 @@ bool playFile(const char *filename, uint32_t resumeFilePos)
void playNextMp3()
{
stop();
continuousMode = true;
if (currentNode == NULL)
{
currentNode = rootNode.findFirstDirectoryWithMP3s();
@ -248,7 +260,8 @@ void next()
void audio_eof_mp3(const char *info)
{
Serial.println("audio file ended.");
playNextMp3();
if (continuousMode)
playNextMp3();
}
/* not working, FIXME remove me! */
@ -472,8 +485,24 @@ void loop()
start();
}
if (!startupSoundPlayed) {
startupSoundPlayed = true;
String tempPath = "/"+sys_dir+"/"+startup_sound;
playSongByPath(tempPath.c_str());
}
// send device to sleep:
long now = millis();
if (!sleepSoundPlayed && now - lastInteraction > sleepMessageDelay) {
sleepSoundPlayed = true;
String tempPath = "/"+sys_dir+"/"+sleep_sound;
playSongByPath(tempPath.c_str());
}
if (now - lastInteraction > sleepDelay) {
Serial.println("entering deep sleep...");
deactivateRFID();