MHVLib
20111011
An efficiency oriented runtime library for AVR microcontrollers
|
#include <MHV_Debounce.h>
Public Member Functions | |
MHV_Debounce (MHV_PinChangeManager *pinChangeManager, MHV_RTC *rtc, uint16_t debounceTime, uint16_t heldTime, uint16_t repeatTime) | |
void | assignKey (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t pin, int8_t pinchangeInterrupt, MHV_DebounceListener *listener) |
void | deassignKey (volatile uint8_t *dir, volatile uint8_t *out, volatile uint8_t *in, uint8_t pin, int8_t pinchangeInterrupt) |
void | checkHeld () |
Protected Member Functions | |
void | pinChanged (uint8_t pcInt, bool newState) |
void | initPin (uint8_t pinchangeInterrupt) |
Protected Attributes | |
MHV_RTC * | _rtc |
MHV_DEBOUNCE_PIN | _pins [MHV_PC_INT_COUNT] |
MHV_TIMESTAMP | _debounceTime |
MHV_TIMESTAMP | _heldTime |
MHV_TIMESTAMP | _repeatTime |
MHV_PinChangeManager * | _pinChangeManager |
Definition at line 70 of file MHV_Debounce.h.
MHV_Debounce::MHV_Debounce | ( | MHV_PinChangeManager * | pinChangeManager, |
MHV_RTC * | rtc, | ||
uint16_t | debounceTime, | ||
uint16_t | heldTime, | ||
uint16_t | repeatTime | ||
) |
Debouncing helper for buttons connected directly to PCINT capable pins The user must pull the pin up, either externally (and initing the pin by calling mhv_setInput), or internally by calling mhv_setInputPullup
pinChangeManager | the pin change manager |
rtc | the realtime clock we will use for timing |
debounceTime | the minimum amount of time to count as a button press (in milliseconds) |
heldTime | the minimum amount of time to consider a button held down |
repeatTime | the time after which the held call repeats |
Definition at line 40 of file MHV_Debounce.cpp.
void MHV_Debounce::assignKey | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pinchangeInterrupt, | ||
MHV_DebounceListener * | listener | ||
) |
Assign a pin to debounce
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pinchangeInterrupt | A member of the MHV_PIN_* macro |
listener | a class to call when the button is pressed or held down |
Definition at line 126 of file MHV_Debounce.cpp.
void MHV_Debounce::checkHeld | ( | ) |
Called periodically to check if pins have been held Ideally, this should be called from the main loop, rather than the interrupt context
Definition at line 68 of file MHV_Debounce.cpp.
void MHV_Debounce::deassignKey | ( | volatile uint8_t * | dir, |
volatile uint8_t * | out, | ||
volatile uint8_t * | in, | ||
uint8_t | bit, | ||
int8_t | pinchangeInterrupt | ||
) |
Deassign a pin
dir | A member of the MHV_PIN_* macro |
out | A member of the MHV_PIN_* macro |
in | A member of the MHV_PIN_* macro |
bit | A member of the MHV_PIN_* macro |
pinchangeInterrupt | A member of the MHV_PIN_* macro |
Definition at line 150 of file MHV_Debounce.cpp.
void MHV_Debounce::initPin | ( | uint8_t | pinchangeInterrupt | ) | [protected] |
Definition at line 60 of file MHV_Debounce.cpp.
void MHV_Debounce::pinChanged | ( | uint8_t | pcInt, |
bool | newState | ||
) | [protected, virtual] |
Trigger for pin change interrupts - scans through 8 pins starting at the offset
pcInt | the pin change interrupt that was triggered |
newState | the new state of the pin |
Implements MHV_PinEventListener.
Definition at line 95 of file MHV_Debounce.cpp.
MHV_TIMESTAMP MHV_Debounce::_debounceTime [protected] |
Definition at line 74 of file MHV_Debounce.h.
MHV_TIMESTAMP MHV_Debounce::_heldTime [protected] |
Definition at line 75 of file MHV_Debounce.h.
MHV_PinChangeManager* MHV_Debounce::_pinChangeManager [protected] |
Definition at line 77 of file MHV_Debounce.h.
MHV_DEBOUNCE_PIN MHV_Debounce::_pins[MHV_PC_INT_COUNT] [protected] |
Definition at line 73 of file MHV_Debounce.h.
MHV_TIMESTAMP MHV_Debounce::_repeatTime [protected] |
Definition at line 76 of file MHV_Debounce.h.
MHV_RTC* MHV_Debounce::_rtc [protected] |
Definition at line 72 of file MHV_Debounce.h.