File tree Expand file tree Collapse file tree 3 files changed +17
-24
lines changed Expand file tree Collapse file tree 3 files changed +17
-24
lines changed Original file line number Diff line number Diff line change @@ -860,7 +860,6 @@ void Wippersnapper::runNetFSM() {
860
860
WS._mqtt ->setKeepAliveInterval (WS_KEEPALIVE_INTERVAL);
861
861
mqttRC = WS._mqtt ->connect (WS._username , WS._key );
862
862
if (mqttRC == WS_MQTT_CONNECTED) {
863
- statusLEDDeinit ();
864
863
fsmNetwork = FSM_NET_CHECK_MQTT;
865
864
break ;
866
865
}
@@ -933,12 +932,7 @@ void Wippersnapper::pingBroker() {
933
932
}
934
933
// blink status LED every STATUS_LED_KAT_BLINK_TIME millis
935
934
if (millis () > (_prvKATBlink + STATUS_LED_KAT_BLINK_TIME)) {
936
- if (WS.lockStatusLED ) {
937
- WS_DEBUG_PRINTLN (" Status-LED in-use by WipperSnapper" );
938
- } else {
939
- statusLEDBlink (WS_LED_STATUS_KAT);
940
- statusLEDDeinit ();
941
- }
935
+ statusLEDBlink (WS_LED_STATUS_KAT);
942
936
_prvKATBlink = millis ();
943
937
}
944
938
}
@@ -1049,7 +1043,6 @@ void Wippersnapper::connect() {
1049
1043
1050
1044
WS_DEBUG_PRINTLN (" Registered board with Wippersnapper." );
1051
1045
statusLEDBlink (WS_LED_STATUS_CONNECTED);
1052
- statusLEDDeinit ();
1053
1046
1054
1047
WS._mqtt ->processPackets (1000 );
1055
1048
}
Original file line number Diff line number Diff line change @@ -64,12 +64,10 @@ bool Wippersnapper::statusLEDInit() {
64
64
#endif
65
65
66
66
#ifdef USE_STATUS_LED
67
- if (!WS.lockStatusLED ) {
68
- pinMode (STATUS_LED_PIN, OUTPUT); // Initialize LED
69
- digitalWrite (STATUS_LED_PIN, 0 ); // Turn OFF LED
70
- WS.lockStatusLED = true ; // set global pin "lock" flag
71
- is_success = true ;
72
- }
67
+ pinMode (STATUS_LED_PIN, OUTPUT); // Initialize LED
68
+ digitalWrite (STATUS_LED_PIN, 0 ); // Turn OFF LED
69
+ WS.lockStatusLED = true ; // set global pin "lock" flag
70
+ is_success = true ;
73
71
#endif
74
72
return is_success;
75
73
}
@@ -96,7 +94,7 @@ void Wippersnapper::statusLEDDeinit() {
96
94
digitalWrite (STATUS_LED_PIN, 0 ); // turn off
97
95
pinMode (STATUS_LED_PIN,
98
96
INPUT); // "release" for use by setting to input (hi-z)
99
- WS.lockStatusLED = false ; // release global pin lock flag
97
+ WS.lockStatusLED = false ; // un-set global pin " lock" flag
100
98
#endif
101
99
}
102
100
@@ -146,6 +144,11 @@ void Wippersnapper::setStatusLEDColor(uint32_t color) {
146
144
*/
147
145
/* ***************************************************************************/
148
146
void Wippersnapper::statusLEDBlink (ws_led_status_t statusState) {
147
+ #ifdef USE_STATUS_LED
148
+ if (!WS.lockStatusLED )
149
+ return ;
150
+ #endif
151
+
149
152
int blinkNum = 0 ;
150
153
uint32_t ledBlinkColor;
151
154
switch (statusState) {
Original file line number Diff line number Diff line change @@ -61,11 +61,9 @@ void Wippersnapper_DigitalGPIO::initDigitalPin(
61
61
wippersnapper_pin_v1_ConfigurePinRequest_Direction_DIRECTION_OUTPUT) {
62
62
63
63
#ifdef STATUS_LED_PIN
64
- // lock status LED pin for use as a digitalIO component
65
- if (pinName == STATUS_LED_PIN) {
66
- WS_DEBUG_PRINTLN (" * Using status LED as a digital output" );
67
- WS.lockStatusLED = true ;
68
- }
64
+ // deinit status led, use it as a dio component instead
65
+ if (pinName == STATUS_LED_PIN)
66
+ WS.statusLEDDeinit ();
69
67
#endif
70
68
WS_DEBUG_PRINT (" Configured digital output pin on D" );
71
69
WS_DEBUG_PRINTLN (pinName);
@@ -131,11 +129,10 @@ void Wippersnapper_DigitalGPIO::deinitDigitalPin(
131
129
itoa (pinName, cstr, 10 );
132
130
pinMode (pinName, INPUT); // hi-z
133
131
132
+ // if prv. in-use by DIO, release pin back to application
134
133
#ifdef STATUS_LED_PIN
135
- // release status LED pin back for signaling
136
- if (pinName == STATUS_LED_PIN) {
137
- WS.lockStatusLED = false ;
138
- }
134
+ if (pinName == STATUS_LED_PIN)
135
+ WS.statusLEDInit ();
139
136
#endif
140
137
}
141
138
You can’t perform that action at this time.
0 commit comments