Home

Awesome

MicroMenu

Copyright (c) 2014 karl@pitrich.com

Simple and concise Embedded Menu System for Arduino.

Please check out the comprehensive example applications.

Note: This has been developed and tested with Arduino 1.5.x only.

Demo Videos

TODO

Feature Set

Simple API

Any hardware

Great display flexibility

Single callback per menu item, multiple actions

Handles all events, eg.

Installation

Clone this repository or download the current version as an archive, copy or link it to your Arduino libraries folder, e.g. ~/Documents/Arduino/libraries on a Mac, then restart the Arduino IDE.

Usage and Concept

The code base resides in it's own namespace Menu. So you need to either prefix all methods with Menu:: or add using namespace Menu; somewhere in your code. I prefer to be explicit by opting for the prefix.

1) Define menu an structure

Begin with a dummy exit menu item. With it, you can utilize all events and functions, e.g. the parent event will be invoked, allowing you to save all data when you leave the menu or even prevent to leave. Also, you can simply clear the display when the user leaves the menu. The arguments to the macro MenuItem are: Name, Label, Next, Previous, Parent, Child, Callback. If you have no child or sibling or parent, substitute with Menu::NullItem, this is a typesafe replacement for NULL

MenuItem(miExit, "", Menu::NullItem, Menu::NullItem, Menu::NullItem, miSettings, menuExit);
    MenuItem(miSettings, "Settings", miTest1, Menu::NullItem, miExit, miCalibrateLo, menuDummy);
      MenuItem(miCalibrateLo,  "Calibrate Lo", miCalibrateHi,  Menu::NullItem,       miSettings, Menu::NullItem, menuDummy);
      MenuItem(miCalibrateHi,  "Calibrate Hi", miChannel0, miCalibrateLo,  miSettings, Menu::NullItem, menuDummy);

2) Implement a callback to render a single menu item

This example is for a 4-line text LCD, usable with the LiquidCrystal library shipped with Arduino.

void renderMenuItem(const Menu::Item_t *mi, uint8_t pos) {
    lcd.setCursor(0, pos);
    lcd.print(engine->label(mi));
}

3) Handle menu events

 bool myMenuItemCallback(Menu::Action_t act) {
  switch (act) {
    case actionParent: 
      saveAll();
      return true; // return false to prevent navigation to parent
      break;
    case actionTrigger:
      adcSaveCalibrationData();
      break;
  }
}

Example Hardware Configuration

TODO: Image LCD and TFT Boards

Licensing

The MIT License (MIT)

Copyright (c) 2014 karl@pitrich.com
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.