From 1b8966103dcc377ea9021462ae8861ab81b205d3 Mon Sep 17 00:00:00 2001 From: Reed Nightingale Date: Wed, 22 Jan 2020 00:49:59 -0800 Subject: [PATCH] Send audio for 'Exit' menu option correctly --- setup.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.cpp b/setup.cpp index 0ac1f44..7d666df 100644 --- a/setup.cpp +++ b/setup.cpp @@ -565,9 +565,14 @@ void runMenu(const MenuItem_t* const menu_items, const uint16_t num_items) if(globalSettings.morseMenuOn //Only spend cycles copying menu item into RAM if we actually need to && (old_index != index)){ - MenuItem_t mi = {"",nullptr}; - memcpy_P(&mi,&menu_items[index+1],sizeof(mi));//The 0th element in the array is the title, so offset by 1 - strncpy_P(b,mi.ItemName,sizeof(b)); + if(num_items-1 > index){ + MenuItem_t mi = {"",nullptr}; + memcpy_P(&mi,&menu_items[index+1],sizeof(mi));//The 0th element in the array is the title, so offset by 1 + strncpy_P(b,mi.ItemName,sizeof(b)); + } + else{ + strncpy_P(b,MI_EXIT,sizeof(b)); + } morseText(b); enc_read();//Consume any rotations during morse playback }