Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MIP8f_FRDM_sample by
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
Generated on Wed Jul 13 2022 02:52:47 by
1.7.2
