Support optional soundbites (adds Skip option in wizard), updates look and feel to a gorgeous sunflower theme, and adds a daily Tribute Time Alarm feature synced automatically with the phone time

This commit is contained in:
drjones
2026-07-04 02:33:32 -07:00
parent 617741f773
commit 2c19aeb6a9
4 changed files with 450 additions and 126 deletions

View File

@@ -23,6 +23,11 @@ static bool longPressTriggered = false;
static uint32_t lastSlideTime = 0;
static const uint32_t SLIDE_INTERVAL = 8000; // 8 s between slides in autoplay
// Tribute Daily Alarm Run-Through State
static bool g_tributeActive = false;
static int g_tributeNextIndex = 0;
static uint32_t lastTributeCheck = 0;
// ── Core function: show a memory ──────────────────────────────────────────────
void showMemory(int index) {
if (g_memoryCount == 0) return;
@@ -40,6 +45,7 @@ void showMemory(int index) {
// ── Button handlers ───────────────────────────────────────────────────────────
void handleSinglePress() {
if (hasError || g_memoryCount == 0) return;
g_tributeActive = false; // Cancel alarm playback if active
if (currentState == STATE_AUTOPLAY) currentState = STATE_IDLE;
showMemory((g_currentIndex + 1) % g_memoryCount);
}
@@ -51,6 +57,7 @@ void handleDoublePress() {
void handleTriplePress() {
if (hasError || g_memoryCount == 0) return;
g_tributeActive = false; // Cancel alarm playback if active
if (currentState == STATE_AUTOPLAY) currentState = STATE_IDLE;
showMemory((g_currentIndex + g_memoryCount - 1) % g_memoryCount);
}
@@ -64,6 +71,7 @@ void handleQuadruplePress() {
void handleLongPress() {
if (hasError) return;
g_tributeActive = false; // Cancel alarm playback if active
if (currentState == STATE_AUTOPLAY) {
currentState = STATE_IDLE;
stopAudio();
@@ -124,6 +132,7 @@ void loop() {
// ── Web display request (triggered by phone) ──────────────────────────────
if (g_webDisplayDirty) {
g_webDisplayDirty = false;
g_tributeActive = false; // Cancel alarm playback if user interacts
int req = g_webDisplayRequest;
g_webDisplayRequest = -1;
if (req >= 0 && req < g_memoryCount) {
@@ -131,6 +140,23 @@ void loop() {
}
}
// ── Tribute Daily Time Alarm Trigger ──────────────────────────────────────
if (g_timeSynchronized && g_tributeAlarmEnabled && g_memoryCount > 0 && !g_tributeActive) {
if (now - lastTributeCheck >= 1000) {
lastTributeCheck = now;
time_t locTime = time(NULL) - g_timezoneOffset;
struct tm* lt = gmtime(&locTime);
if (lt && lt->tm_hour == g_tributeAlarmHour && lt->tm_min == g_tributeAlarmMinute && lt->tm_sec == 0) {
printf("Tribute Alarm triggered! Starting keepsake memories playback.\r\n");
g_tributeActive = true;
g_tributeNextIndex = 0;
currentState = STATE_IDLE;
lastSlideTime = now;
showMemory(0);
}
}
}
// ── Button edge detection ─────────────────────────────────────────────────
if (btn == LOW && lastButtonState == HIGH) {
// Pressed down
@@ -163,8 +189,21 @@ void loop() {
clickCount = 0;
}
// ── Autoplay advance ──────────────────────────────────────────────────────
if (currentState == STATE_AUTOPLAY && g_memoryCount > 0) {
// ── Autoplay and Tribute advance ──────────────────────────────────────────
if (g_tributeActive && g_memoryCount > 0) {
if (!isAudioPlaying() && (now - lastSlideTime > SLIDE_INTERVAL)) {
g_tributeNextIndex++;
if (g_tributeNextIndex < g_memoryCount) {
lastSlideTime = now;
showMemory(g_tributeNextIndex);
} else {
g_tributeActive = false;
stopAudio();
printf("Tribute daily playback loop complete. Returning to Idle.\r\n");
}
}
}
else if (currentState == STATE_AUTOPLAY && g_memoryCount > 0) {
if (!isAudioPlaying() && (now - lastSlideTime > SLIDE_INTERVAL)) {
lastSlideTime = now;
showMemory((g_currentIndex + 1) % g_memoryCount);