Issues Adding OLED Menu

Hey Guys -

I can’t figure a couple of things out for my project which includes an OLED screen + rotary encoder /w push button (the only input on project). Currently, when powered on, it displays a title plus 3 lines showing the current values from sensors.

The part I’m having trouble with is that from this screen, I’m wanting to be able to click the rotary encoder and have the following displayed:

  • Mute: (Set variable to enable / disable speaker)
  • LEDPattern: (Set variable to one of three patterns)
  • Sensitivity: (Adjust an integer variable up & down (set to 15 by default in script))
  • Done (Return back to initial screen)

Clicking rotary encoder on each allows you to rotate to select option then click again to set it.

My initial thought was to…

  • Move everything from the “// Loop OLED” block in its own function (named “MainDisplay”)
  • Replace code moved from “// Loop OLED” with “MainDisplay();”
  • Create a menu structure for the 4 options within a function (with selecting “Done” running the MainDisplay function)
  • Add something to loop where if the encoder was pressed, the configMenu would appear

I started with the above to test, but found that even after doing the first two steps above, verifying it threw an error that “f” was not declared in the scope. When reverted, it worked fine again. Tried passing “f” to function, but couldn’t get it working.

Below are my questions with code attached (thought it would be too long to paste)…


  • Is the method I’m considering for the menu + encoder valid or what would be suggested?
  • Assuming I should create the MainDisplay function, how do I pass the DHT22 variables f & h to it?
  • I can’t get the config menu to appear - what do I need to add to trigger it at any time?
  • I haven’t been able to test yet since can’t trigger it, but do the config options listed seem to be set up correctly? (config menu function starts on line 221.)

Any assistance or suggestions are well appreciated - Thanks!!

PublicCode.ino (8.83 KB)