Mouse's Arduino Buttons & Such (Mabs)
A collection of classes and functions for nice handling of basic inputs for Arduino boards. The classes are kept as simple as possible while having enough functionality to be useful. ''Timeslice-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 Mabs inputs must not intefere with timing of other parts of your project which might use interrupts themselves (e.g. NeoPixel control.
- RawButton - abstract digital switch with optional logic inversion (pullup).
- DebouncedButton - timeslice-based debounced push button class.
- DualButton - works like a DebouncedButton which has two inputs (from separate DebouncedButtons). The purpose of this class is to enable easy addition of a second control (e.g. from radio remote control) to a system with an existing DebouncedButton, without having to change firmware logic.
- DiscretePot - use a potential divider attached to an analog input to return a discrete value within a specified range - includes debouncing.
- ToggleButton - each press flips state from on to off
Here are some terms I use, and the meanings I have given them in the context of the Mabs library:
- on: instantaneous logical value.
- pushed: button is on now, and this is the first time pushed has been tested since the button became on.
- tapped: button has been pushed and released.
- held: is on and has been for more than some period of time (over and above debouncing).
- repeat: is held, but will only return true periodically - the delay between true returns is different (typically longer) for the first repeat, and then shorter for subsequent repeats. This follows common repeat characteristics of computer keyboards.
Documentation can be found on the Orthogonal Systems website at http://orthogonal-systems.co.uk/doc/mabs/
- Install Doxygen
- Run ''doxygen'' from the root of this project - html is generated in doc/html
Author & License
All code written by Mouse firstname.lastname@example.org, and licensed under the GNU GPL v3. See the LICENSE file for details.
Ideas for future development
Enhancements to DebouncedButton
- DebouncedButton::wasPressed() should return number of presses if more than one since last test
- When pushed, stays on for some period of time and thn switches off
- Pushing when on restarts the on timer
- state=0 --> state=1 ... --> state=n-1 --> state=0
- This makes ToggleButton just an n-state where n=2