IoTcat 5 years ago
parent 164e24a22e
commit 71cb284f79
  1. 13
      digital-clock.ino
  2. 10
      digital-screen.h
  3. 7
      switch.h

@ -13,7 +13,6 @@
/*** 引入关键库 ****/
#include "ovo.h"
/*** 定义初始参数 ****/
//小组组号
@ -49,6 +48,7 @@
#include "switch.h"
/*** 运行初始化 ****/
void setup(){
@ -57,6 +57,8 @@ void setup(){
digital_clock_ini();
//开关组件初始化
switch_ini();
//初始化串口,方便debug
Serial.begin(115200);
}
@ -76,13 +78,16 @@ void loop(){
/*** 主要控制逻辑 ****/
//如果reset键被按下,重置时钟
if(reset.isPressed() == true) clock.reset();
if(reset.isPressed() == true) {
clock.reset();
swi.changeStatus();
}
//如果开关打开,则显示时钟,否则不显示时钟
//如果开关打开,则停止计时
if(swi.getStatus() == true) clock.show();
else clock.hide();
Serial.println(swi.getStatus());
/*** 守护进程 ****/
clock.core();
swi.core();

@ -75,8 +75,8 @@ public:
inline void digital_show(int num){
if(num == -1 || _ice == 1){
digital_show_1(15);
digital_show_2(15);
//digital_show_1(15);
//digital_show_2(15);
return;
}
@ -90,7 +90,7 @@ public:
setInterval([&](){
this->digital_show(this->_cnt % (this->_group + 1));
this->_cnt++;
if(this->_ice != 1) this->_cnt++;
}, INTERVAL_TIME);
}
@ -102,6 +102,10 @@ public:
this->_ice = 0;
}
inline void change(){
this->_ice = !(this->_ice);
}
inline void reset(){
this->_cnt = 0;
}

@ -43,6 +43,10 @@ public:
return _status;
}
bool changeStatus(){
this->_status = !(this->_status);
}
bool isPressed(){
return _isPressed;
}
@ -70,9 +74,10 @@ private:
set_isPressed();
// 检测开关键松开动作
if(this->_isPressed != s_fIsPressed && this->_isPressed != _type){
if(this->_isPressed != s_fIsPressed /*&& this->_isPressed != _type*/){
this->_status = !(this->_status);
delay(600);
}
}

Loading…
Cancel
Save