arduinoMenu crash in nav.poll - help needed


Well-known member
I am trying to get a CHOOSE submenu working in a platformio prioject for teensy 4.1.
This is what the menu definition looks like. Full code is attache to this post.
int instrument_index =-1;//some variable used by your code (not necessarily an int)
CHOOSE(instrument_index, instrument_menu,"Choose instrument",doNothing,noEvent,wrapStyle
MENU(mainMenu, "Settings menu", doNothing, noEvent, wrapStyle
    ,OP("Sub1", dummy, enterEvent)
The very first call to the nav.poll() in the loop function crashes the teensy.
I have used the arduinoMenu library in a number of other projects on teensy with problems. This the first time I have tried to the CHOOSE submenu macro.

Here is the platformio.ini file.

; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

platform = teensy
board = teensy41
framework = arduino
lib_deps =
    neu-rah/ArduinoMenu library@^4.21.4

Any suggestions on how to fix this, I have run out of ideas.


  • main.cpp
    3.4 KB · Views: 5

Have you tried making use of the crash report capability is your setup() function (note that the while (!Serial); line will wait forever if nothing is connected to the serial console, so comment that line out and/or remove it after you have finished with the crash debugging) ??

   while (!Serial);

   if (CrashReport)

Which type of crash does it report & what's the apparent cause at the specific line that the crash report indicates ??

Mark J Culross
Thanks for your response.

I have found what the problem was.

The line just before the CHOOSE macro
int instrument_index = -1;//some variable used by your code (not necessarily an int)
That I copied from an example in the ArduinoMenu library, causes the crash. Initialising the variable to 1 works fine.