first commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
// Stored beside each WAV. A valid .meta file is the queue commit marker.
|
||||
struct BoomEventMeta {
|
||||
uint32_t magic = 0x42434D31; // BCM1
|
||||
uint32_t sampleCount = 0;
|
||||
uint64_t captureStartedMs = 0;
|
||||
uint64_t triggeredMs = 0;
|
||||
uint64_t queuedMs = 0;
|
||||
uint32_t checksum = 0;
|
||||
};
|
||||
|
||||
class BoomQueue {
|
||||
public:
|
||||
bool begin();
|
||||
bool ready() const { return ready_; }
|
||||
int refreshCount();
|
||||
int count() const { return count_; }
|
||||
bool saveWav(const int16_t* samples, size_t sampleCount, const char* triggerType,
|
||||
String* savedFilename = nullptr, uint64_t captureStartedMs = 0,
|
||||
uint64_t triggeredMs = 0);
|
||||
bool readMeta(const String& filename, BoomEventMeta& meta) const;
|
||||
bool remove(const String& filename);
|
||||
bool exists(const String& filename) const;
|
||||
size_t fileSize(const String& filename) const;
|
||||
String absolutePath(const String& filename) const;
|
||||
String listJson(size_t limit = 40);
|
||||
size_t listNames(String* out, size_t maxItems);
|
||||
|
||||
private:
|
||||
bool ready_ = false;
|
||||
int count_ = 0;
|
||||
bool ensureQueueDir();
|
||||
String makeFilename(const char* triggerType);
|
||||
bool writeWavFile(const char* path, const int16_t* samples, size_t sampleCount);
|
||||
bool validWav(const String& filename, uint32_t samples) const;
|
||||
void recoverInterruptedWrites();
|
||||
};
|
||||
|
||||
extern BoomQueue boomQueue;
|
||||
Reference in New Issue
Block a user