SerialUI: A Serial User Interface for embedded devices, namely Arduinos.
SerialUI is useful when you want to provide a user interface through the serial channel (menus, sub-menus and command execution). It provides built-in support for navigation through the menu hierarchy and online help.
With SerialUI, you can create a hierarchy of menus and sub-menus of arbitrary depth (limited only by ROM/RAM space).
Each menu contains a list of menu items. There are two types of SerialUI menu items:
- Sub menus: lead you to another level of menu items
- Commands: actually perform some type of action.
Using SerialUI, you can create any serial user interface. Here’s an example menu system you could set up:
So, here we’d have a three-option top level menu (information, enable, settings) with two of those options leading to sub-menus.
Every “leaf” (option that doesn’t lead to a sub-menu) is a command that uses a callback specified when setting up the menu item.
Exactly what happens when a user issues a command is determined by callback implementations (functions).
A few commands are built-in and don’t need to be defined:
Help, which displays all the available menu keys and help messages, where defined.
Up, which moves up to a parent menu from a sub-menu
Exit the SerialUI interface (available in top level menu).
GUI and Demo
But wait, there’s more! Yes, use SerialUI now (as of version 1.4) and you get a free graphical user interface, thanks to druid4arduino. You don’t need to use druid but should you want to provide a GUI then there’s no additional work involved.
This little druid demo includes some use of SerialUI, at the beginning:
Here’s a sample of the interaction through the serial connection (created using the code in examples/SuperBlinker):
+++ Welcome to the SuperBlinker +++ Enter '?' to list available options. > ? *** Help for: SuperBlinker Main Menu * information Retrieve data and current settings + enable Enable/disable device + settings Perform setup and config * quit Exit SerialUI * ? List available menu items > settings SuperBlinker Settings SuperBlinker Settings> ? *** Help for: SuperBlinker Settings * red Set color [0-255] * green * blue * deviceid Set dev ID [string] * show * .. Move up to parent menu * ? List available menu items SuperBlinker Settings> red ... 10 OK SuperBlinker Settings> green ... 20 OK SuperBlinker Settings> blue ... 42 OK SuperBlinker Settings> deviceid ... Yay Device! OK SuperBlinker Settings> show (Called 'show_info' from menu: SuperBlinker Settings) ID: Yay Device! Color--> R:10 G:20 B:42 Device is OFF SuperBlinker Settings> .. SuperBlinker Main Menu > quit
As of version 1.3, the on-line help features flags (the + and *) before each menu item key, to indicate whether the item is a command or a sub-menu and provides better error reporting. It also displays the sub-menu name, in the prompt, where appropriate.
More SerialUI information: