Serial Wombat Arduino Library

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
SerialWombatButtonCounter Class Reference

A class that runs on top of SerialWombaAbstractButton to increment or decrement a variable based on a button. More...

`#include <SerialWombatDebouncedInput.h>`

## Public Member Functions
| SerialWombatButtonCounter (SerialWombatAbstractButton &serialWombatDebouncedInput)
| Constructor for SerialWombatButtonCounter.
void | begin (long *variableToIncrement, long slowIncrement=1, unsigned long slow_mS_betweenIncrements=250, uint16_t slowToMediumTransition_mS=1000, long mediumIncrement=1, unsigned long medium_mS_betweenIncrements=100, uint16_t mediumToFastTransition_mS=1000, long fastIncrement=1, unsigned long fast_mS_betweenIncrements=50)
bool | update ()
| Called periodically to query the SerialWombatDebouncedInput and update the variable.

## Public Attributes
long | highLimit = LONG_MAX
| The variable will not increment above this limit.
long | lowLimit = LONG_MIN
| The variable will not decrement below this limit.

## Detailed Description

A class that runs on top of SerialWombaAbstractButton to increment or decrement a variable based on a button.

This class runs on top of a SerialWombaAbstractButton input. It is passed a variable reference in its begin call. The update() method is then called periodically. This method will look at how many times the debounced input has transitioned since the last call, and also if the input is currently pressed and for how long.

A high limit and low limit can be set which keeps the variable from exceeing those bounds.

Times can be specified for button hold that allows the variable to be incremented at varying rates for short, medium, and long holds.

See the example sw4b_ard_Debounce2 distributed with the Serial Wombat Arduino Library and in the video

https://youtu.be/_EKlrEVaEhg

for an example.

Definition at line 205 of file SerialWombatDebouncedInput.h.

## Constructor & Destructor Documentation

## ◆ SerialWombatButtonCounter()

SerialWombatButtonCounter::SerialWombatButtonCounter | ( | SerialWombatAbstractButton & | serialWombatDebouncedInput | ) |
| inline

Constructor for SerialWombatButtonCounter.

Parameters

  serialWombatDebouncedInput | A pointer to an already initialized SerialWombatDebouncedInput, SerialWombatMatrixButton or digitally configured SerialWombat18CapTouch

Definition at line 213 of file SerialWombatDebouncedInput.h.

## Member Function Documentation

## ◆ begin()

void SerialWombatButtonCounter::begin | ( | long * | variableToIncrement,
|  | long | slowIncrement = 1,
|  | unsigned long | slow_mS_betweenIncrements = 250,
|  | uint16_t | slowToMediumTransition_mS = 1000,
|  | long | mediumIncrement = 1,
|  | unsigned long | medium_mS_betweenIncrements = 100,
|  | uint16_t | mediumToFastTransition_mS = 1000,
|  | long | fastIncrement = 1,
|  | unsigned long | fast_mS_betweenIncrements = 50 )
| inline

Initializes the SerialWombatButtonCounter

Parameters

  variableToIncrement | A pointer to a signed long integer
  slowIncrement | the amount that the variable should increment (or decrement if negative) per increment
  slow_mS_betweenIncrements | how often an increment should happen in slow mode
  slowToMediumTransition_mS | how long to stay in slow mode before switching to medium mode
  mediumIncrement | the amount that the variable should increment (or decrement if negative) per increment
  medium_mS_betweenIncrements | how often an increment should happen in medium mode
  mediumToFastTransition_mS | how long after the initail button press start until switching to Fast mode
  fastIncrement | the amount that the variable should increment (or decrement if negative) per increment
  fast_mS_betweenIncrements | how often an increment should happen in fast mode

Definition at line 231 of file SerialWombatDebouncedInput.h.

## ◆ update()

bool SerialWombatButtonCounter::update | ( |  | ) |
| inline

Called periodically to query the SerialWombatDebouncedInput and update the variable.

Definition at line 257 of file SerialWombatDebouncedInput.h.

## Member Data Documentation

## ◆ highLimit

long SerialWombatButtonCounter::highLimit = LONG_MAX

The variable will not increment above this limit.

Definition at line 320 of file SerialWombatDebouncedInput.h.

## ◆ lowLimit

long SerialWombatButtonCounter::lowLimit = LONG_MIN

The variable will not decrement below this limit.

Definition at line 322 of file SerialWombatDebouncedInput.h.