hannabox/src/globals.h

107 lines
2.1 KiB
C++

#ifndef GLOBALS_H_
#define GLOBALS_H_
void stop();
void start();
bool playFile(const char* filename, uint32_t resumeFilePos = 0);
void loop2(void* parameter);
void id_song_action(AsyncWebServerRequest *request);
void progress_action(AsyncWebServerRequest *request);
void volume_action(AsyncWebServerRequest *request);
boolean buttonPressed(const uint8_t pin);
/**
* Helper routine to dump a byte array as hex values to Serial.
*/
void dump_byte_array(byte *buffer, byte bufferSize)
{
for (byte i = 0; i < bufferSize; i++)
{
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], HEX);
}
}
String getRFIDString(byte uidByte[10])
{
String uidString = String(uidByte[0]) + " " + String(uidByte[1]) + " " +
String(uidByte[2]) + " " + String(uidByte[3]);
return uidString;
}
void writeFile(fs::FS &fs, const char * path, const char * message){
Serial.printf("Writing file: %s\n", path);
File file = fs.open(path, FILE_WRITE);
if(!file){
Serial.println("Failed to open file for writing");
return;
}
if(file.print(message)){
Serial.println("File written");
} else {
Serial.println("Write failed");
}
file.close();
}
unsigned long lastStart = 0;
unsigned long lastInteraction = 0;
boolean sleepSoundPlayed = false;
boolean startupSoundPlayed = false;
boolean continuousMode = false;
uint8_t buttontoignore = 0;
uint32_t lastVoltage = 0;
uint loopCounter = 0;
String lastUid = "";
uint16_t currentSongId = 0;
uint32_t currentSongSeconds = 0;
boolean continuePlaying = false;
boolean prepareSleepMode = false;
const String sleep_sound = "sleep.mp3";
const String startup_sound = "start.mp3";
const String mapping_file = "/mapping.txt";
const String progress_file = "progress.txt";
std::map<String, String> rfid_map;
/*
const long sleepMessageDelay = 28000;
// wait until deep sleep:
const long sleepDelay = 30000;
*/
const long sleepMessageDelay = 1798000;
//const long sleepMessageDelay = 22000;
// wait until deep sleep:1800000
const long sleepDelay = 1800000;
//const long sleepDelay = 25000;
#endif