MHVLib  20111011
An efficiency oriented runtime library for AVR microcontrollers
MHV_Debounce Class Reference

#include <MHV_Debounce.h>

Inheritance diagram for MHV_Debounce:
MHV_PinEventListener

List of all members.

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

Detailed Description

Definition at line 70 of file MHV_Debounce.h.


Constructor & Destructor Documentation

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

Parameters:
pinChangeManagerthe pin change manager
rtcthe realtime clock we will use for timing
debounceTimethe minimum amount of time to count as a button press (in milliseconds)
heldTimethe minimum amount of time to consider a button held down
repeatTimethe time after which the held call repeats

Definition at line 40 of file MHV_Debounce.cpp.


Member Function Documentation

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

Parameters:
dirA member of the MHV_PIN_* macro
outA member of the MHV_PIN_* macro
inA member of the MHV_PIN_* macro
bitA member of the MHV_PIN_* macro
pinchangeInterruptA member of the MHV_PIN_* macro
listenera 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

Parameters:
dirA member of the MHV_PIN_* macro
outA member of the MHV_PIN_* macro
inA member of the MHV_PIN_* macro
bitA member of the MHV_PIN_* macro
pinchangeInterruptA 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

Parameters:
pcIntthe pin change interrupt that was triggered
newStatethe new state of the pin

Implements MHV_PinEventListener.

Definition at line 95 of file MHV_Debounce.cpp.


Member Data Documentation

Definition at line 74 of file MHV_Debounce.h.

Definition at line 75 of file MHV_Debounce.h.

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.

Definition at line 76 of file MHV_Debounce.h.

Definition at line 72 of file MHV_Debounce.h.


The documentation for this class was generated from the following files: