Skip to content

Releases: Stutchbury/InputEvents

Bring EncoderAdapters into core library

25 Nov 11:25

Choose a tag to compare

Release Notes for v1.6.0 (Core EncoderAdapters)

New Classes

This release brings the EncoderAdapter into the core InputEvents library, removing the external library dependency.

You will need to delete or comment out the following lib_deps = line from platformio.ini (a semicolon comments out the line):
;stutchbury/EncoderAdapter@^0.5.0

PJRC's Encoder library is still recommended, so ensure the following line is still present if you are planning to use encoders connected via regular GPIO buttons and using interrupts (recommended):

paulstoffregen/Encoder@^1.4.4

Use the PjrcEncoderAdapter for the PJRC's Encoder library.

Please note: As at Nov 2025, there is still an issue with v1.4.4 of the Encoder library as it does not include changes to the source repository. If you are having issues with PJRC's encode, please download the zip from the repo and install locally (change the lib_deps line above to /your/path/to/lib/Encoder).

If you want to use a GPIO Expander to connect EventEncoder and EventEncoderButton inputs there are now two expander encoder adapters for this. Neither use interrupts so are not likely to be lossless - use only if you have to!

Use the ExpanderEncoderAdapter and ExpanderPinAdapter for reasonably fast GPIO expanders such as the MCP23017. This adapter uses the de facto standard 'table based' encoder method of incrementing hte position.

For slower GPIO expanders such as the PCF8575, there is the SlowExpanderEncoderAdapter - this only readys a single state change per indent rather than the usual four, so may prove more consistent for slow moving inputs.

The examples AdafruitGPIOExpanderAdapter.ino and RobTillartPCF8575Expander.ino show how this is coded - it's still fairly simple but obviously there is the additional layer of the GPIO expander!.

API and Class Name Changes

The encoder adapter classes are now in a sub directory/module, so the #include will need to be prefixed. eg:

#include <EncoderAdapter/PjrcEncoderAdapter.h>

The EncoderAdapter abstract class from the old library has been renamed to IEncoderAdapter as part of a move towards 'standard' naming conventions. This is normally only used internally, so should not affect existing code.

The ExpanderPinAdapter constructor now requires a reference, not a pointer, to the GpioExpanderAdapter (just remove the & prefix in your constructor call(s)).

Full Changelog: v1.5.2...v1.6.0

I2C GPIO Expander Adapters

27 Oct 10:52

Choose a tag to compare

This release adds I2C GPIO Expander Adapters for the MCP23017, PCF8575 and PCF8574 expander ICs making the boards and libraries much easier to integrate into your projects.

The supported underlying libraries are:

The I2C address can be optionally set via the begin() for the Adafruit adapters and via the constructor for Rob Tollaart's so multiple boards or combinations of ICs are supported.

As with the SPI adapter, the adapter's update() must be called from loop() before calling EventButton or EventSwitch update() methods. This is to mitigate the 'slow' read/update over I2C.

The adapter implementations have been tested with the readily available PCF8575 and PCF8574 modules and Adafruit's MCP23017 module. Many thanks to @HubertJH for testing the prior to this release.

Please see docs for updated information. There are also two new examples showing how to use the adapters.

Full Changelog: v1.5.0...v1.5.2

GPIO Expanders for InputEvents

15 Sep 12:46

Choose a tag to compare

GPIO Expanders for InputEvents v1.5.0

GPIO Expanders can now be used with InputEvents. Many thanks to @leon-gh for the initial pull request, Discord chats and all the testing. The initial release supports the popular HC165E expander - it is fairly trivial to create adapters for other expanders so pull requests are very welcome.

What's Changed

Full Changelog: v1.4.0...v1.5.0

v1.4.0 PinAdapters for virtual pins, pin mixing and more.

25 Jun 14:56

Choose a tag to compare

Release Notes for v1.4.0

This release introduces PinAdapters to enable the use of GPIO Expanders, better testing and anything that doesn't directly connect to regular GPIO pins.

If you are just using regular GPIO pins, nothing needs to change in the initialisation of your InputEvents inputs - the constructors continue to accept regular GPIO pins and a PinAdapter+DebounceAdapter will be created for you by default. Some duplicate/superfluous minor methods have been removed (see below).

Pins can now also be 'mixed', so if you have a physical button, it can now also be virtually pressed and released - for example, via a touch screen tap. See this example showing a button press/release performed with a timer in the loop()

Existing Classes

New Methods

EventButton::setPressedState
EventEncoderButton::setPressedState

Sets the value that represents 'pressed' for your button.
By default, the pin mode is INPUT_PULLUP, so buttons are deemed 'pressed' if their pin state is LOW (ie pulled down.)
If you change this to HIGH, you must also change the pinMode in the PinAdapter constructor.

EventSwitch::setOnState

Sets the value that represents 'on' for your switch.
By default, the pin mode is INPUT_PULLUP, so switches are deemed 'on' if their pin state is LOW (ie pulled down.)
If you change this to HIGH, you must also change the pinMode in the PinAdapter constructor.

EventButton::setDebouncer
EventEncoderButton::setDebouncer
EventSwitch::setDebouncer

Set your own DebounceAdapter. The built-in debouncer will be used by default (unless you pass useDefaultDebounce=false) to the button or switch construcotr) but you can set use you own debouncer if required.

Note: When planning to use setDebouncer() you must ensure useDefaultDebouncer is set to false in the button or switch constructor. Previously set or created DebouncerAdapters are not deleted.

New Constructors

EventButton
EventEncoderButton
EventSwitch

All the above classes will now accept a regular GPIO pin (the GpioAdapter will be created for you), a PinAdapter or a PinAdapter + DebounceAdapter in their constructors.

Two of the constructors also have an optional useDefaultDebouncer flag. When set to true (the default) the built-in debouncer will be created for you. If it is set to false, the PinAdapter (created for you or passed) will be used directly unless you setDebouncer() to your chosen DebounceAdapter.

Removed Methods

EventButton::buttonState
EventEncoderButton::buttonState

This previously to read the pin state via the Bounce2 library. Buttons and switches are now agnostic of their underlying pin state, so please use isPressed() instead.

EventSwitch::reverseOnOff
EventSwitch::isOnOffReversed

This is replaced by EventSwitch::setOnState() as detailed above.

New Classes

PinAdapter

The interface for all pin adapters.

GpioPinAdapter

The standard pin adapter for regular GPIO pins. This will be created for you if you just pass a regular GPIO pin to button or switch constructors.

DebounceAdapter

The base/interface for debounce adapters. Derived from PinAdapter.

FoltmanDebounceAdapter

The built in debounce adapter. This will be created for you unless you set useDefaultConstructor to false in the button or switch constructors, or set/pass your own DebounceAdapter

PinMixerAdapter

Accepts two PinAdapters and mixes their read() states.

VirtualPinAdapter

A PinAdapter that provides press(), release(), and setState() methods to control state programatically. Can be used with PinMixerAdapter to make touch screen inputs virtually press and release a physical button.

Bounce2PinAdapter

This is not a DebounceAdapter but a regular PinAdapter that uses the Bounce2 library (which only reads GPIO pins directly), so cannot be passed to setDebouncer(). Used primarily for test/development.

New Example

There is a ButtonPinMixer.ino example sketch that demonstrated how to use PinAdapters and the PinMixerAdapter

Documentation and Support

As always, there is comprehensive documentation provides here and full Doxygen generated API Docs.

Feedback and bug reports are welcome or chat on Discord if you have any questions.

Acknowledements

Once again, thank you to @kfoltman for his seemingly unending patience and expertise.

Full Changelog: v1.3.0...v1.4.0

EventEncoderButton position limits

19 Feb 09:59

Choose a tag to compare

Encoder Button Position Limits

This release adds the ability to set limits on the position() or pressedPosition() of the EventEncoderButton.

If either a minimum or maximum position is set (ie non-zero) then limits will be applied.

You can choose between 'hard' limits (the default) or to 'wrap' from max back to min and min back to max.

Please see API docs for more information.

There are no changes to other input types.

Full Changelog: v1.2.1...v1.3.0

v1.2.1 Adapt to any encoder library (+Doyygen APIdocs)

11 Feb 13:27

Choose a tag to compare

What's Changed

Use Any Encoder Library

The primary change for this release is the use of an EncoderAdapter for EventEncoder and EventEncoderButton. While this adds an extra couple of lines when creating those inputs, it allows the use of any underlying encoder library via the EncoderAdapter.

This change means InputEvents no longer has a hard dependency on PJRC's (very good) Encoder, so can use other encoder libraries that work with different MCUs such as the Raspberry Pico2040.

Please see the EventEncoder and EventEncoderButton examples for the sketch changes required.

Come and chat on Discord if you have any questions.

Doxygen API Docs

The full Doxygen generated API documentation are now available.

Full Changelog: v1.2.0...v1.2.1

Begin the begin()

19 Jan 00:06

Choose a tag to compare

API Changes

The major API change in this release (v1.1.0) is the introduction of the begin() method on all input classes.
This follows the Arduino library convention and ensures better compatibility with boards that initialise their pins rather late.

The begin() method must be called for each input from within the setup() function before any other configuration.


For EventAnalog and EventJoystick the ADC resolution can be optionally passed to the constructor. The default is 10bit but most ESP32s use 12bit.


Also for EventAnalog and EventJoystick the following methods have been added:

enableAutoCalibration() (true by default) - this replaces the rather badly named allowRead() method.

setMinValue() and setMaxValue() allow the manual setting of the upper and lower limit od the ADC that can be achieved by a potentiometer or joystick. These are normally auto-calibrated as the input is used.

setAdcResolution() has been removed. Use the constructor ADC bits argument instead. setMaxValue() can be used if running a pin with a lower than expected voltage (eg my test rig feeds 3V3 into a 5v Uno pin).


The following methods are now available for all inputs:

unsetCallback() If using a class method as a callback, this must be called before destroying the class instance.

isCallbackSet() Returns true if setCallback() has been called and false if unsetCallback() has been called. Returning true does not guarantee the callback's function or method still exists.

resetIdleTimer() When called the IDLE event will be fired after setIdleTimeout() milliseconds (default 10 seconds).

New Events

DOUBLE_CLICKED and MULTI_CLICKED events for EventButton and EventEncoderButton. This means CLICKED will only fire for single clicks. As before clickCount() will return the number of clicks for MULTI_CLICKED.

Thanks to Andy @valentineautos for the feedback on these.

Fixes

Fixed idle timer so it is reset only if an event is actually fired (ie not the event has not been blocked).


Full Changelog: v1.0.2...v1.1.0

v1.0.2 for more reliable ESP32 Encoders

16 Dec 14:45

Choose a tag to compare

All the ESP32 modules I own now work reliably with PJRCs Encoder library.

Thanks to @danja https://www.reddit.com/r/esp32/comments/yalvd6/comment/itcq3re/
@tko PaulStoffregen/Encoder#90 (comment)
@ZephyrCloudNine PaulStoffregen/Encoder#90 (comment)
for unknowingly pointing me in the right direction.

Full Changelog: v1.0.1...v1.0.2

v1.0.1

14 Dec 16:28

Choose a tag to compare

Set initial state in EventSwitch constructor
Add setAdcResolution for EventAnalog
Update docs and examples

Full Changelog: v1.0.0...v1.0.1

InputEvents Made Easy

12 Dec 11:33

Choose a tag to compare

This new library brings together all my other input event libraries. A slightly different approach means only a single callback function is required per input (and a callback function can be shared across the same type of inputs).

Enjoy!