Mutila: Mouse's Utilities for Arduino
Oft-used utilities: debouncing buttons, averaging samples, and so on.
|
Re-usable utility components for Arduino projects. All the stuff we all end up re-implementing every project - buttons, averaging samplers, voltage and current measurements calculations and so on. The classes and functions in this library are intended to be flexible, efficient and stable, as well as following a style which is broadly similar to the core Arduino libraries.
All code written by Matthew Gates (Mouse), and licensed under the GNU GPL version 3. See the LICENSE file for details.
A collection of classes and functions for nice handling of basic inputs (buttons and such). The classes are kept as simple as possible while having enough functionality to be useful. ''Time slice-based'' classes should have their ''update()'' method called as frequently as possible, which will return rapidly. These classes are an alternative to interrupt driven IO for projects where interrupts can't be used - e.g. where Mutila inputs must not interfere with timing of other parts of your project which might use interrupts themselves (e.g. motor control).
Terms used for Mutila input classes:
Samplers read from analog input pins and allow some operations to be performed on the data - typically calculating some sort of average value for the pin to help de-noise signals from sensors.
Sampling voltage and current values may be performed using the following classes, which are good examples of how to derive custom samplers from BufferedSampler and EMASampler:
DFPlayer Mini is a neat and affordable audio module which can play MP3 files from an SD card with a serial interface for control. It can also drive a small speaker. Mutila provides the class DFPlayerMini for controlling such a device. DFPReader is a class which can be used to read out numbers and durations, using the samples in the audio/ directory.
HC-SR04 ultrasonic range finding modules are inexpensive and popular modules used in Arduino projects. While using them is simple (it only takes a few lines of code to fetch and calculate the range), Mutila provides the following classes for clean usage of these modules, and enhanced functionality:
Mutila's Heartbeat class can be used to blink and LED with variable patterns to give some diagnostic information about the state of the program without needed a more sophisticated display.
A Mode is a kind of sub-program which has distinct startup, shutdown and update routines. For example, your program might have a special setup mode which suspends normal operations while settings are altered. The ModeManager class can be used to switch between such mutually exclusive modes while keeping your main loop clean and simple.
Modes may be arranged in a hierarchical manner using the ParentMode class. This can be useful when building hierarchical menu systems which a couple of buttons.
PersistentSetting provides an EEPROM-backed store for settings which you want to survive Arduino resets. Supports a simple wear-levelling scheme.
Doxygen-generated documentation can be found here: https://matthewg42.github.io/Mutila/
It would be really nice to have some mechanism to write the current project version, and library versions into flash automatically. By version I guess I mean git short hash of library version from library.properties.
At time of writing, Mutila is a one-Mouse project. versions up until v1.1.0 were not made into releases, and most work was done directly in master. However, enough projects now use Mutila that is makes sense to start being a bit more structured, so here's how it's going to work from now (until I need to change it again).