Skip to content

Commit ce7bf4e

Browse files
committed
Allow melodies to be temporarily disabled
1 parent 673d4db commit ce7bf4e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

command_interface.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "nrf_ble_gatt.h"
1010
#include "user_cfg.h"
1111

12+
extern uint16_t melody_snooze_seconds;
1213
extern uint16_t lfs_file_count;
1314
extern void display_file_count(void);
1415
extern uint8_t lfs_free_space_check(void);
@@ -240,7 +241,7 @@ void command_interface_process_byte(char incoming)
240241
}
241242
else if(strncmp(command_input_buffer, "version", 7) == 0)
242243
{
243-
sprintf((char *)command_response_buffer, "version,0.8.2,beta");
244+
sprintf((char *)command_response_buffer, "version,0.9.0,beta");
244245
m_ble_tx_logbuffer(command_response_buffer, strlen((const char *)command_response_buffer));
245246
}
246247
else if(strncmp(command_input_buffer, "getcfg", 6) == 0)
@@ -361,6 +362,13 @@ void command_interface_process_byte(char incoming)
361362
NRF_LOG_FLUSH();
362363
}
363364
}
365+
else if(strncmp(command_input_buffer, "snooze,", 7) == 0)
366+
{
367+
// Set melody snooze duration
368+
NRF_LOG_INFO("snooze command received: %s seconds", command_input_buffer+7);
369+
NRF_LOG_FLUSH();
370+
melody_snooze_seconds = atoi(command_input_buffer+7);
371+
}
364372

365373
memset(command_input_buffer, 0, sizeof(command_input_buffer));
366374
command_input_index = 0;

main.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ bool is_melody_playing_pause = false;
180180
uint32_t melody_next_note = 0;
181181
int *melody;
182182
int melody_last_alert_index = MELODY_NONE;
183+
uint16_t melody_snooze_seconds = 0;
183184

184185

185186
uint32_t app_timer_ms(uint32_t ticks)
@@ -203,7 +204,7 @@ uint32_t millis(void)
203204

204205
void melody_play(int index, bool interrupt_melody)
205206
{
206-
if (is_melody_playing && !interrupt_melody)
207+
if (is_melody_playing && !interrupt_melody || melody_snooze_seconds > 0)
207208
{
208209
return;
209210
}
@@ -1635,6 +1636,12 @@ static void logging_timer_handler(void *p_context) {
16351636

16361637
strftime(datetimestring, 64, "%Y-%m-%dT%H:%M:%S", tmTime);
16371638

1639+
// Decrement melody snooze counter if active
1640+
if (melody_snooze_seconds > 0)
1641+
{
1642+
--melody_snooze_seconds;
1643+
}
1644+
16381645
// Write GPS status to display
16391646
Adafruit_GFX_setCursor(64,8);
16401647
snprintf(gps_status, sizeof(gps_status), "GPS %02d S%01d%01d", hgps.seconds, hgps.is_valid, hgps.fix);
@@ -2135,7 +2142,7 @@ void log_file_start()
21352142
void update_status_packet(char * buffer)
21362143
{
21372144
// Update the buffer with the a status response packet
2138-
sprintf(buffer, "status,OK,%d,%d,%d,%d,%d,%d,%d,%d", log_file_active, fault_count, recent_fault_index, lfs_percent_free, lfs_file_count, hgps.fix, hgps.sats_in_view, melody_last_alert_index);
2145+
sprintf(buffer, "status,OK,%d,%d,%d,%d,%d,%d,%d,%d,%d", log_file_active, fault_count, recent_fault_index, lfs_percent_free, lfs_file_count, hgps.fix, hgps.sats_in_view, melody_last_alert_index, melody_snooze_seconds);
21392146
}
21402147

21412148
uint16_t create_fault_packet(char * buffer)

0 commit comments

Comments
 (0)