Hello and welcome to our community! Is this your first visit?
Register

Onboard Menu Sytem via OSD or LCD

This page is a chapter in 'Introduction to additional features'

On board menu system

Description

On board menu allows various tasks to be done using a menu visible on OSD or alternatively on a LCD using the transmitter. Current implementation allows the menu to be used only while the motors are not armed and the pitch/roll stick is used for navigation through the menu.

Development

The menu code was initially made for the v2.4 flight software but has now been merged into the upcoming v3. For history check this forum posting.

Setup and configuration

The menu is enabled by defining OSD_SYSTEM_MENU in the AeroQuad.ino it also relies on OSD so that needs to be enabled too.

Currently there is no configurable items inside the menu (but check OSDMenu.h if you like).

Usage of a Serial LCD display

Note:
If a Serial LCD is used, OSD can not be used at the same time!
This feature is only available in flight software version 3.2 or higher.

The on board menu system can be also used in conjunction with a Serial LCD display which can be found in the AeroQuad store.

You just need to apply power to the LCD (5V) and connect the LCD's "RX" pin to the "TX3" pin of the AeroQuad flight control board (default serial port). If you want to change the Serial Port used, you may change that in "UserConfiguration.h" by modifying the following line:

Code:
// *******************************************************************************************************************************
// Support menu on serial enabled LCD display (16x2 characters). You can change serial port if needed
// Note: cannot be enabled at the same time with OSD
// *************************************************************.******************************************************************
#define SERIAL_LCD Serial3
After that the LCD can be operated like described below to use the features of the on board menu.

Operation

While motors are unarmed the menu is entered by moving the (pitch/roll) stick to right, this 'gesture' is also used to confirm selections.

Selected item is changed/modified by moving stick up/down, at extremes 'autorepeat' is enabled for faster operation.

Moving stick to the left will exit to upper level or exit the menu.

If motors are armed while in the menu the menu action is automatically canceled and menu exits.

Menu Actions

Current menu structure:
Code:
+ Config
| + Camera stabilizer
| + Center Pitch
| + Center Roll
| + Center Yaw
| + Reset battery stats
| + OSD
| +Reset flightime
+ Setup
| + Edit PIDs
| + [PIDNAME].[P|I|D] = xxxxx.xx
| + Save to EEPROM
| + Reinit EEPROM
+ Debug
| + Sensors
| + Accel Data
| + Gyro Data
| + Mag Data
| + Ranger Data
+ Camera PTZ mode
+ Exit and hide OSD

Development information

Adding menu entries

To add an entry to the menu two things need to be done
  1. add the entry into menuData array
  2. create a handler function that will execute the task (and link it by function pointer to the menuData).
    Note that in many cases the 'generic handlers' could be used.
The entries in menuData[] have four values
  • the level on the menu tree, this defines a tree like structure to organize the entries
  • name of the entry (shown on OSD)
  • handler function (or MENU_NOFUNC for a submenu)
  • mode (passed to the handler function, this allows sharing the handler easily)

handler function

The handler function is used to execute the action for selected menu item. It must follow prototype of
Code:
void menuHandlerFunc( byte mode, byte action )
  • mode value will be set according to the active (selected) menu entry and is used to allow sharing of the same function for multiple tasks.
  • action tells the handler what action should it take
Possible action values are:
The handler function is entered from the menu. This is the only value needed for trivial handlers that do not want to process user events, in that case they should set menuInFunc=0 upon return. If handler intrenal data is used it must be initialized when this event is seen.
Stick actions passed to the handler.
Stick left action, handler may do what it wants but generally it should allow getting back to the main menu via this (set menuInFunc=0).
Timed callback fired i.e. handler had set menuInFunc=(>2) at same point to request callback.

Important global variables

Currently selected menu item, normally handler functions don't need to access this.
This determines the current operating mode:
0 -- navigating in the menu tree
1 -- handler function active, handler function is called on stick actions
2 -- call handler with MENU_CALLBACK on next update
>2 -- waiting for callback (decremented on each update)

Handler function must modify this value in two cases
  • when the handler function wants to pass control back to the 'menu tree' it must set menuInFunc=0
  • if the handler function did something and wants to be called again after some time it will set menuInFunc to value of 3 or greater. (2 is not recommended as that can prevent other OSD output)

Handler function internal data

To allow creation of complex handler functions some data is prereserved for 'internal state'. This data is shared between all handler functions and thus any handler must initialize it prior to use.
Code:
byte  menuFuncData[10]; // 10 bytes of data that can be used by any handler function
float menuFuncDatafloat; // one floating point value for float editting
Check the code for examples on how to use the handlers.

Tags:

This page has been seen 8,117 times.

    • Created by on
      Last updated by on