Skip to content

Commit 9fb4a05

Browse files
d-a-vearlephilhower
authored andcommitted
Fix led-pin in updater, also no need to backup LED state (#5217)
1 parent 464bdcc commit 9fb4a05

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Diff for: cores/esp8266/Updater.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void UpdaterClass::_reset() {
3737
_command = U_FLASH;
3838

3939
if(_ledPin != -1) {
40-
digitalWrite(_ledPin, _ledStateRestore);
40+
digitalWrite(_ledPin, !_ledOn); // off
4141
}
4242
}
4343

@@ -50,10 +50,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
5050
}
5151

5252
_ledPin = ledPin;
53-
_ledOn = ledOn;
54-
if(_ledPin != -1) {
55-
_ledStateRestore = digitalRead(_ledPin);
56-
}
53+
_ledOn = !!ledOn; // 0(LOW) or 1(HIGH)
5754

5855
/* Check boot mode; if boot mode is 1 (UART download mode),
5956
we will not be able to reset into normal mode once update is done.
@@ -376,7 +373,7 @@ size_t UpdaterClass::writeStream(Stream &data) {
376373

377374
while(remaining()) {
378375
if(_ledPin != -1) {
379-
digitalWrite(LED_BUILTIN, _ledOn); // Switch LED on
376+
digitalWrite(_ledPin, _ledOn); // Switch LED on
380377
}
381378
size_t bytesToRead = _bufferSize - _bufferLen;
382379
if(bytesToRead > remaining()) {
@@ -394,7 +391,7 @@ size_t UpdaterClass::writeStream(Stream &data) {
394391
}
395392
}
396393
if(_ledPin != -1) {
397-
digitalWrite(LED_BUILTIN, _ledOn == HIGH ? LOW : HIGH); // Switch LED off
394+
digitalWrite(_ledPin, !_ledOn); // Switch LED off
398395
}
399396
_bufferLen += toRead;
400397
if((_bufferLen == remaining() || _bufferLen == _bufferSize) && !_writeBuffer())

Diff for: cores/esp8266/Updater.h

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ class UpdaterClass {
165165

166166
int _ledPin;
167167
uint8_t _ledOn;
168-
int _ledStateRestore;
169168
};
170169

171170
extern UpdaterClass Update;

0 commit comments

Comments
 (0)