|
|
|
@ -5,8 +5,8 @@ |
|
|
|
|
* @category digital-clock |
|
|
|
|
* @package switch.h |
|
|
|
|
* @copyright Copyright (c) 2019 IoTcat (https://iotcat.me)
|
|
|
|
|
* @license GNU General Public License 2.0 |
|
|
|
|
* @version 0.0.1 |
|
|
|
|
* @license GNU General Public License 3.0 |
|
|
|
|
* @version 0.0.2 |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -23,6 +23,9 @@ |
|
|
|
|
#define SWI_RESET 4 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#ifndef SWI_DELAY_TIME 1200 |
|
|
|
|
#define SWI_DELAY_TIME 1200 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
class Switch{ |
|
|
|
|
|
|
|
|
@ -77,13 +80,24 @@ private: |
|
|
|
|
static bool s_fIsPressed = false; |
|
|
|
|
set_isPressed(); |
|
|
|
|
|
|
|
|
|
#ifdef FORCED_SWITCH |
|
|
|
|
static unsigned int t_t = millis(); |
|
|
|
|
// 检测开关键按下动作
|
|
|
|
|
if(this->_isPressed != s_fIsPressed){ |
|
|
|
|
|
|
|
|
|
if(t_t < millis() - SWI_DELAY_TIME ){ |
|
|
|
|
this->_status = !(this->_status); |
|
|
|
|
t_t = millis(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
// 检测开关键松开动作
|
|
|
|
|
if(this->_isPressed != s_fIsPressed /*&& this->_isPressed != _type*/){ |
|
|
|
|
|
|
|
|
|
this->_status = !(this->_status); |
|
|
|
|
delay(600); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|