TcMenu is a framework for generating menu based applications on the Arduino platform. Typically a TcMenu application will be designed using the TcMenu Generator UI also on TcMenu Designer on Windows 10 Store, then generated based on the parameters you specify.
TcMenu embedded library is written in a modular way for the Arduino platform; giving unprecedented levels of control over how the menu is displayed, input acquisition and external control of the menu. The designer UI hides this behind easy to use configuration that supports a wide range of devices.
Menu Designer UI is an embedded form designer that you use to generate a menu. Once the menu is designed the code generator is initiated to build the embedded app, next moving to the IDE to write the code. It is capable of incremental round trip development between form designer and IDE. Any changes you make to the sketch in between are kept as the utility tries not to alter existing code in the sketch.
In this section we look at how to build a menu based application using the generator UI; which is recommended for most people and by far the easiest way to get started.
The TcMenu generator UI is available for most desktop platforms and is released and natively packaged on Windows 8 / 10 and MacOS High Sierra or above. It should work fine on Linux but is not yet packaged for it. You can get the UI and the embedded code from git hub: [https://github.com/davetcc/tcMenu].
Once you’ve got the application running, a screen very similar to below will appear, where you can create and edit TcMenu’s.
Looking at the window above, we go through the major areas:
In the editor area (4) are the properties of the selected menu item. Notice the ID is not editable. The IDs are internally generated and are used to uniquely identify components. Each type of item has slightly different fields, but all fields have:
Ensure root is selected in the tree (1) and press the + button from the toolbar (2) to add a new item. You should see something similar to this dialog:
The above dialog is used to create a new menu item, in area (A1) we choose the type of item and we can optionally change the chosen ID (A2). Normally, just use the ID that’s populated as it is guaranteed unique.
Once an item is created, it is edited by changing the fields in the editor area (4), as you type in here, the prototype is immediately updated to reflect the changes. To remove an item press the - button on the toolbar, the duplicate button makes a copy of the currently selected item, and up / down move the item to the desired position in the current submenu.
There are other functions to generate code, but we’ll get something to generate first.
For this example we will create a menu that has two top level menu items; a counter which counts down from the selected value, and a Boolean switch that turns on or off the countdown. It will also have a submenu with one menu item to control the notification method. So lets draw this out conceptually below
menu root +- countdown, integer values 0 to 1000 seconds +- enabled, boolean YES, NO. +- settings (sub menu) +- alert (one of SOUND, LIGHT, BOTH)
Create a new Arduino project in your sketches area, start a new project in the TcMenu editor and save it into the
new Arduino project directory. It will create an
EMF file with the chosen name in that directory.
Ensure Root is selected in the tree and press the + button from the toolbar (2). We want a numeric item so choose
“Analog Item” as the type. Once you press ok a new menu item should be created and selected in the tree.
In the editor area (4) change:
We are now ready to create the second item. Again press the + button from the toolbar (2) to create a second item, this time choose BooleanMenuItem as the type and press create. In the editor area (4):
Now, we create the submenu by choosing the + button again, this time choose Sub menu as the type and press create. Change the name to Settings and leave all other fields as is.
Ensuring the newly created submenu is selected, press the + button again, this time choose Enumeration item and press create. In the editor area:
At this point we have finished creating the menu, we now move on to generating code.
When generating eeprom values, note that values 0 and 1 are reserved for a “magic key”. This is so that load knows if the eeprom is still intact at startup. If you need to change the magic key it’s defined in the tcMenu headers.
Before generating code, it is advisable to check the ID and eeprom ranges, to ensure there are no overlaps. To do this, from the Code menu choose “Show ID and Rom Layout”; which will pop up the following dialog:
On the left you see the IDs laid out in numeric order, and on the right the rom layout. If there are any overlaps in the rom, I.E. a value that overlaps with another, it is highlighted in red. Any overlaps should be changed before generating code.
Finally, we get to generating the code for Arduino. Choose Code/Generate Code from the menu. You should see a dialog similar to the following:
Once this dialog appears you’ll notice it’s split into roughly two areas, the platform and hardware choices, and the properties that need to be defined for those choices.
Once all the above choices are set, you need to define the parameters that will be used by these plugins. In order to do this, you need to fill in the properties table (lower part of dialog) with your values. Notice each row in the list has a description along with the variable name, so you know what it’s for. These values will be saved into your project file (don’t forget to press save after leaving the generator)!
Press the generate button, a new window should popup, that logs the code generation run. Once complete the menu files and the sketch should be generated. Further, you should see output in the text area similar but not identical to:
08:18:17 - Starting Arduino generate: /Users/dave/Documents/Arduino/timerExample 08:18:17 - INO Previously existed, backup existing file 08:18:17 - Writing out header file: /Users/dave/Documents/Arduino/timerExample/timerExample.h 08:18:18 - Finished processing header file. 08:18:18 - Writing out source CPP file: /Users/dave/Documents/Arduino/timerExample/timerExample.cpp 08:18:18 - Finished processing source file. 08:18:18 - Making adjustments to /Users/dave/Documents/Arduino/timerExample/timerExample.ino 08:18:18 - found include in INO 08:18:18 - found setup in INO 08:18:18 - found runLoop in INO 08:18:18 - found callback for onContrastChange 08:18:18 - found callback for on12VStandby 08:18:18 - found callback for onVolumeChange 08:18:18 - found callback for onChannelChange 08:18:18 - No changes to the INO file, not writing out 08:18:18 - Process has completed, make sure the code in your IDE is up-to-date. 08:18:18 - You may need to close the project and then re-open it to pick up changes..
At this point, as long as all the properties were defined above, and the circuit is built, you should have a functioning menu to build in your favorite IDE!
Hope you enjoy using TcMenu!