As of today, reading the ModulinoButtons states is done like this:
if (buttons.get(a, b, c)) {
}
As discussed also with Tom Igoe, we should provide an alternative API for ModulinoButtons that doesn't involve pass-by-reference methods and follows the more idiomatic mental model of "arguments are input, return value is output". This could be the alternative API:
void loop() {
buttons.update();
if (buttons.isPressed(0)) {
}
}
This also applies to the ModulinoMovement (IMU) API which as of today uses pass-by-reference arguments to read acceleration.
I believe that using .update() has also the advantage of following the begin()/update() paradigm of many Arduino libraries and in general offers a consistent standard and a versatil infrastructure for the API of all Modulinos that retrieve multiple properties at once from the modul. In case we want to throttle the I2C requests, we can do it under the hood in the update() implementation.
As of today, reading the ModulinoButtons states is done like this:
As discussed also with Tom Igoe, we should provide an alternative API for ModulinoButtons that doesn't involve pass-by-reference methods and follows the more idiomatic mental model of "arguments are input, return value is output". This could be the alternative API:
This also applies to the ModulinoMovement (IMU) API which as of today uses pass-by-reference arguments to read acceleration.
I believe that using
.update()
has also the advantage of following thebegin()/update()
paradigm of many Arduino libraries and in general offers a consistent standard and a versatil infrastructure for the API of all Modulinos that retrieve multiple properties at once from the modul. In case we want to throttle the I2C requests, we can do it under the hood in theupdate()
implementation.