Software based digital input debouncer
Diff: TimerSubscriber.h
- Revision:
- 2:dabe90a0bdc1
- Parent:
- 1:b59d305c4365
--- a/TimerSubscriber.h Mon Jun 02 14:09:31 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -#pragma once -#include "mbed.h" - -/*------------------------------------------------------------- - -(c) W.D. 2014 - --------------------------------------------------------------*/ - -/* ------ sample usage------ -*/ -class TimerDependent -{ -public: - TimerDependent(); - virtual ~TimerDependent(); - - virtual void TimerEvent (void) = NULL; -}; - -class TimerSubscriber -{ -public: - TimerSubscriber(const unsigned int inTableSize=10, const unsigned int inTickerPeriod=10000); - ~TimerSubscriber(); - unsigned int counter_rd(void) {return TickerCounter;}; - unsigned int TickerPeriod_rd(void) {return TickerPeriod;}; - bool Subscribe(class TimerDependent *adres, const unsigned int inDivider=1); - bool UnSubscribe(const class TimerDependent *adres); -private: - static struct TimerEntry - { - class TimerDependent *CallBack; - unsigned int Divider; - unsigned int Counter; - } *TimerTable; - static void OnTimer(void); - static unsigned int TableSize; - unsigned int TickerPeriod; - static unsigned int TickerCounter; -};