Skip to content

fix led-pin in updater #5217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions cores/esp8266/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void UpdaterClass::_reset() {
_command = U_FLASH;

if(_ledPin != -1) {
digitalWrite(_ledPin, _ledStateRestore);
digitalWrite(_ledPin, !_ledOn); // off
}
}

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

_ledPin = ledPin;
_ledOn = ledOn;
if(_ledPin != -1) {
_ledStateRestore = digitalRead(_ledPin);
}
_ledOn = !!ledOn; // 0(LOW) or 1(HIGH)

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

while(remaining()) {
if(_ledPin != -1) {
digitalWrite(LED_BUILTIN, _ledOn); // Switch LED on
digitalWrite(_ledPin, _ledOn); // Switch LED on
}
size_t bytesToRead = _bufferSize - _bufferLen;
if(bytesToRead > remaining()) {
Expand All @@ -394,7 +391,7 @@ size_t UpdaterClass::writeStream(Stream &data) {
}
}
if(_ledPin != -1) {
digitalWrite(LED_BUILTIN, _ledOn == HIGH ? LOW : HIGH); // Switch LED off
digitalWrite(_ledPin, !_ledOn); // Switch LED off
}
_bufferLen += toRead;
if((_bufferLen == remaining() || _bufferLen == _bufferSize) && !_writeBuffer())
Expand Down
1 change: 0 additions & 1 deletion cores/esp8266/Updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ class UpdaterClass {

int _ledPin;
uint8_t _ledOn;
int _ledStateRestore;
};

extern UpdaterClass Update;
Expand Down