These days, there’s a huge variety of screens on the market for use with microcontrollers. OLEDs and graphic LCDs abound, while e-ink devices tempt the user with their clean look and low energy consumption. However, for many purposes, the humble HD44780 character LCD does the job just fine. If you’re using such a device, you might want to implement a simple menu system, and in that case, [MyHomeThings] has you covered.
The menu code is simple to modify and implement. It allows the user to define a certain number of menu items, along with button labels and functions to be executed with button presses. By default, it’s set up to work with left and right function buttons, with up and down buttons to toggle through the menu’s various entries. This suits the commonly available Arduino shields which combine a 16×2 character LCD with a set of four tactile buttons in a cross formation. However, modifying the code to use an alternate button scheme would be simple for those eager to tweak things to their liking.
For the absolute beginner to programming, it’s a great way to put together a simple interface for your microcontroller projects. It’s the sort of thing you might use if you’d built a do-everything Arduino handheld device, as we’ve seen built before. If you find text menus too archaic for your purposes, though, be sure to sound off with your favourite solutions in the comments.
Looks neat and like a very light weight alternative to “ArduinoMenu” (github) which I bookmarked to test next time I have a menu to navigate in a project.
*clank* … That was me dropping it in the toolbox. Condemned a set of cordless phones that have 16×3 displays in them that look useful. COG though, not HD44780, so that might take some noodling around. I was thinking of using one in a variable PSU, got some of those cheap buck convertor modules, and another in an ESR meter. With pro-mini clones. Anyway, at least one of those might like a nifty menu.
Something funky is going on with their website. Chrome cpu usage shoots to 100% and locks up on mobile.
@GrizzlyAdams said: “Something funky is going on with their website. Chrome cpu usage shoots to 100% and locks up on mobile.”
I pointed my Android Firefox mobile browser at the web site. Immediately the “Shield” in Firefox went purple and blocked ws.eu.amazon-adsystem.com (my privacy settings were set to high). After accepting the ubiquitous Cookie euro-nag, the rest of the page loaded without drama; no CPU spike. I would not be surprised if an ad via Amazon caused your Chrome to crash. It happens sometimes. I normally do not crank privacy up so high, especially on sites I know where the content creator deserves some ad revenue. Give Firefox mobile a try, there have been a lot of improvements lately.
Chrome on my Android was rendered completely stuck until I emptied the cache of the app and closed the tab via flight mode…
I wonder how hard it would be to build an embedded equivalent to libdialog where you just have to drop in a back-end for whatever text display system you have and ask for UI elements from the front end of the library.
my lib would cloud be a start for this: https://github.com/0xPIT/menu, I’ve used it for Text and Pixel-based UIs
I’ve created something like this quite some time ago:
https://github.com/0xPIT/menu
It’s maybe even simpler, requires more thinking though, to integrate it properly.
Could use someone to make it work also on other architectures, e.g. ESP32
Looks very similar to the code I’m using on my current project, although the author of the menu I’m using made his menu strings constants to save on ram.
I wrote my own library to handle menu a long time ago and I have rewritten it a few times. It works from data structure instead of build it procedurally and calls the functions for the printing, inc/dec, next/prev entries etc. Thge data structure tells it the X,Y location, min/max values, increment, type of data, pointer to data etc.
It might be a bit of code, but it pays off if you need multiple menus and/or sub menus or change it quickly.
we use gui slicer with tft_spi library for 240*240 lcd screen. works nice, looks good, and on esp32 doesn’t eat much resources
Don’t open the link. It locks up android phone. The site is bad juju
“Something funky is going on with their website. Chrome cpu usage shoots to 100% and locks up on mobile.”
“Don’t open the link. It locks up android phone. The site is bad juju”
Huh. Nothing out of the ordinary with macOS. Maybe the author just has a shoulder chip for Google.
Hmm, I have a menu with just one button, and it can enter WiFi passwords.
https://yoursunny.com/t/2018/ESP32-WiFi-credentials-one-button/
I did something similar, but I needed to do the menu with as few buttons as possible, for entering the WiFi password on a clock that synchronises with NTP.
For me, pressing left/right buttons lots of times to get from A to z or back again wasn’t an option, so I used an encoder. That also includes a button (for backspace) and only one other button is needed (short press “add current character”, long press to accept password).
Have you posted your clock project before? I’m working on an analog clock conversion that I’d like to sync with NTP but I haven’t addressed Wi-Fi credentialing yet.
To add to the list of “done it”s — I wrote a pretty functional menu system for a little DSP project, alas it doesn’t have that Arduino blog cred: https://github.com/T3sl4co1l/Reverb
The trick I guess, is to include function pointers so, if anything needs to /do/ anything, just plop in a pointer and away you go. Probably not real efficient for code space, in terms of a state machine, but it’s easy enough to write in C this way.