Configuration menus for microcontrollers.
Developed for Teensy and Arduino, but should run on many more micro controllers, since it is mostly plain C++ code.
- Interactive configuration and execution via serial streams.
- Store and retrieve configuration from EEPROM.
- Read and write YAML configuration file on SD card.
- Transfer configuration to and from host computer.
- Configures key-value pairs, with values being strings, enums, booleans, integer types, or floats.
- Numerical types with units and unit conversion.
- Two levels of access to configurable parameters: user and admin mode.
- Object-oriented and templated interface.
- Stores pointers to arbitarily sized action names (no memory consuming copies).
- Predefined menu for reporting, saving, loading and erasing configuration file on SD card as well as for putting and getting configuration from EEPROM.
- Predefined menu for uploading firmware, based on FlasherX.
- Add the general aspects of the logger configuration GUI to the microconfig package.
- In unit conversion do not only check the prefix but also the unit itself.
- Support transfer of configuration to another micro controller via a serial stream.
This is a brief teaser, for details see the user guide.
Define a menu with a number of submenus and configurable parameters:
#include <SD.h>
#include <MicroConfig.h>
Config config("micro.cfg", &SD); // main menu and configuration file
Menu settings(config, "Settings"); // settings sub menu
StringParameter<32> path(settings, "Path", "recordings/");
char filename[64] = "recording.wav";
StringPointerParameter<64> file_name(settings, "Recording", &filename);
NumberParameter<float> file_time(settings, "FileTime", 30.0, 1.0, 8640.0, "%.0f", "s");
Menu aisettings(config, "Analog input"); // analog input sub menu
NumberParameter<uint32_t> rate(aisettings, "SamplingRate", 48000, 1, 1000000, "%.1f", "Hz", "kHz");
// sub menu for reporting, saving, loading and removing configuration file:
ConfigurationMenu configuration_menu(config, SD);
HelpAction help_act(config, "Help");Load the configuration file and execute the menu like this:
void setup() {
Serial.begin(9600);
while (!Serial && millis() < 2000) {};
SD.begin(BUILTIN_SDCARD); // initialize SD card
config.get(); // get configuration from EEPROM
config.load(); // load configuration file from SD card
if (Serial)
config.execute(); // execute the main menu, default 10s timeout
}Then you get on the serial monitor:
Configuration file "micro.cfg" not found or empty.
Menu:
1) Settings ...
2) Analog input ...
3) Configuration ...
4) Help
Select: The first two sub menus allow you to change the values of the parameters defined above.
Hit '3' followed by return to enter the configuration menu, where you can choose to view the current configuration by hitting '1':
Settings:
Path: recordings/
FileTime: 300s
Analog input:
SamplingRate: 48.0kHzThe configuration file, that you can also save from this menu, looks exactly like this as well. The format is compatible with YAML files and can be easily edited.
The configuration values can be accessed by the .value() member
functions. The value of the file name parameter is directly stored in
the provided variable. The following code
Serial.printf("path: %s\n", path.value());
Serial.printf("file name: %s\n", filename);
Serial.printf("file time: %g\n", file_time.value());
Serial.printf("sampling rate: %u\n", rate.value());prints
path: recordings/
file name: recording.wav
file time: 30
sampling rate: 48000Note that for the file name we do not need to retrieve the value from the parameter. Instead we just use the variable that has been automagically set by the StringPointerParameter.
Nice and easy, isn't it?
- MicroConfig.h: Include all headers of the MicroConfig library.
- MicroConfigBanner: ASCII art banner and MicroConfig version for output streams.
- Action: Base class for executable or configurable menu entries.
- Parameter: Actions with configurable name-value pairs of various types.
- Menu: A menu of actions and parameters.
- Config: Root (top-level) Menu with configuration file.
- MessageAction.h: Action printing some text.
- InfoAction.h: Action printing out key-value pairs.
- HelpAction.h: Action printing a help message.
- ConfigurationMenu.h: Actions and menu for managing configurations.
- FirmwareUpdate: Upload hex file from SD card.
- FirmwareMenu.h: Actions and menu for handling firmware updates.
In examples/ you find sketches demonstrating the use of the MicroConfig libraries.
- menu: Example demonstrating most features of the MicroConfig library.
The content of the pymicroconfig/ folder is a python package. It provides
- modules for detecting and interacting with MicroConfig menus on microcontrollers.
- serialmonitor: serial monitor for the console that automatically detects Teensys connected to USB.
- microconfig: GUI for setting configuration parameters on a microcontroller.
See pymicroconfig/ for more details.
MicroConfig is used in:
-
TeeRec: Libraries for recording analog input data on Teensy microcontrollers.
-
TeeGrid: Electrode arrays based on 8-16channel recording devices for recording electric fish behavior in natural habitats (see Henninger et al. 2018 and Henninger et al. 2020).
-
FishFinder: Smart fishfinders for better EOD recordings of electric fish in the field.