Implement browser-based voice notes recording, standby flicking remembrance candle, and favorite memory pinning
This commit is contained in:
@@ -28,6 +28,11 @@ static bool g_tributeActive = false;
|
||||
static int g_tributeNextIndex = 0;
|
||||
static uint32_t lastTributeCheck = 0;
|
||||
|
||||
// Standby Remembrance Candle State
|
||||
static bool g_standbyActive = false;
|
||||
static uint32_t lastInteractionTime = 0;
|
||||
static const uint32_t STANDBY_TIMEOUT = 120000; // 2 minutes standby timeout
|
||||
|
||||
// ── Core function: show a memory ──────────────────────────────────────────────
|
||||
void showMemory(int index) {
|
||||
if (g_memoryCount == 0) return;
|
||||
@@ -36,6 +41,9 @@ void showMemory(int index) {
|
||||
|
||||
printf("Showing memory %d: '%s'\r\n", index, g_memories[index].name);
|
||||
|
||||
g_standbyActive = false;
|
||||
lastInteractionTime = millis();
|
||||
|
||||
stopAudio();
|
||||
Display_Memory_Photo(index);
|
||||
playMemoryAudio(index);
|
||||
@@ -110,12 +118,26 @@ void setup() {
|
||||
initAudioPlayer();
|
||||
setPlayerVolume(g_volume);
|
||||
|
||||
// Show first memory (or error screen)
|
||||
// Show favorite memory or first memory on startup
|
||||
if (g_memoryCount == 0) {
|
||||
printf("No memories found. Add some via the web app.\r\n");
|
||||
// Screen stays dark — user will add via web
|
||||
g_standbyActive = true;
|
||||
Draw_Candle_Body();
|
||||
} else {
|
||||
showMemory(g_currentIndex);
|
||||
int favoriteIndex = -1;
|
||||
if (g_favoriteMemoryId >= 0) {
|
||||
for (int i = 0; i < g_memoryCount; i++) {
|
||||
if (g_memories[i].id == g_favoriteMemoryId) {
|
||||
favoriteIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (favoriteIndex >= 0) {
|
||||
showMemory(favoriteIndex);
|
||||
} else {
|
||||
showMemory(g_currentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Start WiFi + web server
|
||||
@@ -160,6 +182,8 @@ void loop() {
|
||||
// ── Button edge detection ─────────────────────────────────────────────────
|
||||
if (btn == LOW && lastButtonState == HIGH) {
|
||||
// Pressed down
|
||||
lastInteractionTime = now;
|
||||
g_standbyActive = false;
|
||||
buttonPressStartTime = now;
|
||||
isButtonPressed = true;
|
||||
longPressTriggered = false;
|
||||
@@ -210,6 +234,24 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Standby Candle Controller ─────────────────────────────────────────────
|
||||
if (g_memoryCount == 0) {
|
||||
if (!g_standbyActive) {
|
||||
g_standbyActive = true;
|
||||
Draw_Candle_Body();
|
||||
}
|
||||
} else if (!g_standbyActive && !isAudioPlaying() && currentState == STATE_IDLE && !g_tributeActive) {
|
||||
if (now - lastInteractionTime > STANDBY_TIMEOUT) {
|
||||
g_standbyActive = true;
|
||||
Draw_Candle_Body();
|
||||
printf("Standby: entering candle standby mode\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (g_standbyActive) {
|
||||
Draw_Candle_Flicker();
|
||||
}
|
||||
|
||||
lastButtonState = btn;
|
||||
|
||||
// ── Web server ────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user