Introducing TextDisplayMenu: Easy, Powerful LCD Menus with Netduino.Foundation.

Posted on June 5, 2018 by bryan costanich 1 Comment

When building connected things, the need to provide info to the user and allow interaction and input quickly surfaces. However, building display screens, menus, and providing a way to edit parameters, configure settings, etc, quickly becomes an enormous task.

Enter Netduino.Foundation’s TextDisplayMenu:

TextDisplayMenu is an incredibly powerful, yet super easy to use, hierarchical, editable, plug-and-play menu library that allows you to easily add an LCD powered graphical interface to your hardware project. It can be driven with a rotary encoder (think: volume knob on your stereo), or three buttons, with very little code:

// use encoder with push button

_encoder = new RotaryEncoderWithButton(

N.Pins.GPIO_PIN_D7, N.Pins.GPIO_PIN_D6, N.Pins.GPIO_PIN_D5,

Netduino.Foundation.CircuitTerminationType.CommonGround);



// Setup the display

_display = new Lcd2004(N.Pins.GPIO_PIN_D13, N.Pins.GPIO_PIN_D12,

N.Pins.GPIO_PIN_D11, N.Pins.GPIO_PIN_D10, N.Pins.GPIO_PIN_D9,

N.Pins.GPIO_PIN_D8);

// Create menu with encoder, and load items from JSON

_menu = new Menu(_display, _encoder, Resources.GetBytes(Resources.BinaryResources.menu), true);

// Wire up event handlers

_menu.Selected += HandleMenuSelected;

_menu.ValueChanged += HandleMenuValueChanged;

_menu.Exited += HandleMenuExited;



// Show the menu

_menu.Enable();



What’s more, the menu itself can be defined in JSON, so creating complex menus can be created declaratively and the only code you need to write is to handle selection and edit events:

{

“menu”: [

{ “text”: “My Temp: {value}”, “id”: “displayTemp”, “value”: 77 },

{ “text”: “My Age: {value}”, “id”: “displayAge”, “value”: 12 },

{ “text”: “My Time”, “id”: “time”, “type”: “TimeDetailed” },

{ “text”: “Edit Temp”, “id”: “temp”, “type”: “Temperature”, “value”: 77 },

{ “text”: “Edit Age”, “id”: “age”, “type”: “Age”, “value”: 12 },

{

“text”: “Parent”,

“sub”: [

{ “text”: “Child 1” },

{ “text”: “Child 2” },

{ “text”: “Child 3” }

]

},

{ “text”: “My Command”, “command”: “DoSomething”},

{ “text”: “Quit” },

{ “text”: “Item 7” }

]

}

There are a number of built in editable menu item types such as time , temp , and boolean , that allow for varied user input depending on what type of data input you need. Additionally, creating custom menu types, including selection lists, is super easy.

Additionally, both our Appliance Control enclosure, and Nice Weather enclosures are designed with TextDisplayMenu in mind, and accommodate a 4 line LCD and rotary enclosure:

This is just a glimpse of the TextDisplayMenu library, but it illustrates the power of Netduino.Foundation. With it, you spend less time on low-level hardware code and can put that saved effort on building cool things!

For more information, check out the docs and view a full sample.

We’re currently the TextDisplayMenu library to support more LCD displays and also add more input types for editable items. If you find yourself writing a code that may be helpful to others, please send us a pull request.

Happy hacking!!