Animation demo with MIP8F_SPI_Ver60

Dependencies:   mbed MIP8F_SPI_Ver60 MIP8f_FRDM_LineBuffer_sample MIP8f_FRDM_TransferMode_sample

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TglSW.cpp Source File

TglSW.cpp

00001 #include "TglSW.h"
00002 #include "mbed.h"
00003 
00004 TglSW::TglSW(PinName SWPin) : _SW(SWPin) {}
00005 
00006 void TglSW::Enable(int NoiseCancel)  {  // _PRSCNT -- unit [times] 
00007     _REPEAT   = NoiseCancel;
00008     _PlessCounter.attach(this, &TglSW::_SeekPress, 0.05); // Ticker[s]
00009     _IfPless = 0;
00010 }
00011 
00012 bool  TglSW::State(void){
00013     return _IfPless;
00014 }
00015 
00016 void  TglSW::Clear(void){
00017     _IfPless = 0;
00018     _PressCount = 0;
00019 }
00020 
00021 void TglSW::_SeekPress(void)  {        // instead of InterruptIn  -- for against noise
00022     if(_SW != _preSW)  _PressCount++;
00023     else      _PressCount=0;
00024     if(_PressCount > _REPEAT ){
00025         if(_SW ==0){
00026             _IfPless = !_IfPless;
00027             _PressCount=0;
00028         }
00029         _preSW = _SW;
00030     }
00031 }
00032 
00033