Arduino settings menu: updated

The dl-menu library, a simple one-level menu for 16×2 displays on Arduino, has been heavily updated:

Text menu item

Arduino Settings Menu

There’s a new menu item for saving texts. Every character is chosen separately with up and down keys. The characters are chosen among predefined set, defined in the sketch itself – no hardcoding on my side!

In case you need to store anything unusual, like phone numbers, GPS coordinates, dates and so on, you can use the text field with a narrowed choice of characters and then parse the result to ensure the input was correct.


Since there’s a lot of static text in menus (labels, character choices), it shouldn’t eat up valuable RAM. Now everything is stored to PROGMEM – flash memory and is read directly from it during runtime.

EEPROM and default values

The values are saved to EEPROM when the user quits a menu item. This is to minimize the number of writes.

A fresh EEPROM contains only 0xFF values so it’s easy to find out whether something has previously been written to it. But since Arduino doesn’t wipe EEPROM on upload, many old values can be left behind. Also, nothing forbids anyone to save 0xFF so the values doesn’t really mean anything.

Previously, the menu relied on this value to decide whether to use a default value or the saved one but now this has been changed.

If parsing of a number fails, the default will be zero. In there’s no choice with saved index, the first will be used. If there’s a character saved that’s not allowed within the menu item, the first allowed character will be used.

Instead of sophisticated defaults without a good reason, I added new methods for setting default values when the user of the library decides:

New methods: setValue()

You can use a separate byte in EEPROM to find out whether it has been cleared or used by another sketch. If so, you can set default values to your menu items using those.

See the enclosed example for clarification. All functions you’ll ever need are used there.