improvements
This commit is contained in:
parent
21119603cb
commit
6684be01eb
|
|
@ -101,6 +101,15 @@ Wake up / Next -> 04 and GND
|
||||||
Previous -> 16 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
|
## TODOs
|
||||||
* Card Reader with SPI. Configure hspi, second SPI channel? Or does SD Card + RFID run at the same channel?
|
* Card Reader with SPI. Configure hspi, second SPI channel? Or does SD Card + RFID run at the same channel?
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -64,7 +64,8 @@ void DirectoryNode::buildDirectoryTree(const char *currentPath)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (entry.isDirectory())
|
|
||||||
|
if (entry.isDirectory() && strcmp(entry.name(),sys_dir.c_str()))
|
||||||
{
|
{
|
||||||
DirectoryNode *newNode = new DirectoryNode(entry.name());
|
DirectoryNode *newNode = new DirectoryNode(entry.name());
|
||||||
subdirectories.push_back(newNode);
|
subdirectories.push_back(newNode);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#include <SD.h>
|
#include <SD.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
const String sys_dir = "system";
|
||||||
|
|
||||||
class DirectoryNode {
|
class DirectoryNode {
|
||||||
private:
|
private:
|
||||||
String name;
|
String name;
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,29 @@ unsigned long lastStart = 0;
|
||||||
|
|
||||||
unsigned long lastInteraction = 0;
|
unsigned long lastInteraction = 0;
|
||||||
|
|
||||||
|
boolean sleepSoundPlayed = false;
|
||||||
|
|
||||||
|
boolean startupSoundPlayed = false;
|
||||||
|
|
||||||
|
boolean continuousMode = false;
|
||||||
|
|
||||||
uint8_t buttontoignore = 0;
|
uint8_t buttontoignore = 0;
|
||||||
|
|
||||||
const int startDelay = 250;
|
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:
|
// wait until deep sleep:
|
||||||
const long sleepDelay = 1800000;
|
const long sleepDelay = 1800000;
|
||||||
|
|
||||||
|
|
|
||||||
31
src/main.cpp
31
src/main.cpp
|
|
@ -38,6 +38,12 @@
|
||||||
#include "css.h"
|
#include "css.h"
|
||||||
#include "DirectoryNode.h"
|
#include "DirectoryNode.h"
|
||||||
|
|
||||||
|
#define SOUND_STARTUP "start.mp3"
|
||||||
|
#define SOUND_SLEEP "sleep.mp3"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File root;
|
File root;
|
||||||
File mp3File;
|
File mp3File;
|
||||||
|
|
||||||
|
|
@ -104,6 +110,11 @@ void playSongByName(String song)
|
||||||
deactivateSD();
|
deactivateSD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void playSongByPath(String path)
|
||||||
|
{
|
||||||
|
playFile(path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void playSongByRFID(String id)
|
void playSongByRFID(String id)
|
||||||
{
|
{
|
||||||
String song = rfid_map[id];
|
String song = rfid_map[id];
|
||||||
|
|
@ -128,6 +139,7 @@ bool playFile(const char *filename, uint32_t resumeFilePos)
|
||||||
void playNextMp3()
|
void playNextMp3()
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
|
continuousMode = true;
|
||||||
if (currentNode == NULL)
|
if (currentNode == NULL)
|
||||||
{
|
{
|
||||||
currentNode = rootNode.findFirstDirectoryWithMP3s();
|
currentNode = rootNode.findFirstDirectoryWithMP3s();
|
||||||
|
|
@ -248,7 +260,8 @@ void next()
|
||||||
void audio_eof_mp3(const char *info)
|
void audio_eof_mp3(const char *info)
|
||||||
{
|
{
|
||||||
Serial.println("audio file ended.");
|
Serial.println("audio file ended.");
|
||||||
playNextMp3();
|
if (continuousMode)
|
||||||
|
playNextMp3();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not working, FIXME remove me! */
|
/* not working, FIXME remove me! */
|
||||||
|
|
@ -472,8 +485,24 @@ void loop()
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!startupSoundPlayed) {
|
||||||
|
startupSoundPlayed = true;
|
||||||
|
String tempPath = "/"+sys_dir+"/"+startup_sound;
|
||||||
|
playSongByPath(tempPath.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// send device to sleep:
|
// send device to sleep:
|
||||||
long now = millis();
|
long now = millis();
|
||||||
|
|
||||||
|
if (!sleepSoundPlayed && now - lastInteraction > sleepMessageDelay) {
|
||||||
|
sleepSoundPlayed = true;
|
||||||
|
String tempPath = "/"+sys_dir+"/"+sleep_sound;
|
||||||
|
playSongByPath(tempPath.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (now - lastInteraction > sleepDelay) {
|
if (now - lastInteraction > sleepDelay) {
|
||||||
Serial.println("entering deep sleep...");
|
Serial.println("entering deep sleep...");
|
||||||
deactivateRFID();
|
deactivateRFID();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue