File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,15 @@ void LED_PCF8574::begin() {
2323}
2424
2525void LED_PCF8574::loop () {
26+ if (blink) {
27+ unsigned long currentMillis = millis ();
28+
29+ if (currentMillis - _previousMillis >= interval) {
30+ _previousMillis = currentMillis;
31+
32+ toggle ();
33+ }
34+ }
2635}
2736
2837void LED_PCF8574::update () {
@@ -31,11 +40,13 @@ void LED_PCF8574::update() {
3140
3241void LED_PCF8574::enable () {
3342 state = HIGH;
43+ blink = false ;
3444 update ();
3545}
3646
3747void LED_PCF8574::disable () {
3848 state = LOW;
49+ blink = false ;
3950 update ();
4051}
4152
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ class LED_PCF8574
1919 int led_state = LOW
2020 );
2121 int state;
22+ bool blink = false ;
23+ unsigned long interval = 500 ;
24+
2225 void begin ();
2326 void loop ();
2427 void enable ();
@@ -29,6 +32,7 @@ class LED_PCF8574
2932 void update ();
3033
3134 int _pin;
35+ unsigned long _previousMillis = 0 ;
3236 MultiPlexer_PCF8574* _expander;
3337};
3438
You can’t perform that action at this time.
0 commit comments