1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-24 19:42:27 +03:00

Fix led-pin in updater, also no need to backup LED state (#5217)

This commit is contained in:
david gauchard
2018-10-08 16:02:27 +02:00
committed by Earle F. Philhower, III
parent 464bdccf41
commit 9fb4a05d67
2 changed files with 4 additions and 8 deletions

View File

@ -37,7 +37,7 @@ void UpdaterClass::_reset() {
_command = U_FLASH; _command = U_FLASH;
if(_ledPin != -1) { if(_ledPin != -1) {
digitalWrite(_ledPin, _ledStateRestore); digitalWrite(_ledPin, !_ledOn); // off
} }
} }
@ -50,10 +50,7 @@ bool UpdaterClass::begin(size_t size, int command, int ledPin, uint8_t ledOn) {
} }
_ledPin = ledPin; _ledPin = ledPin;
_ledOn = ledOn; _ledOn = !!ledOn; // 0(LOW) or 1(HIGH)
if(_ledPin != -1) {
_ledStateRestore = digitalRead(_ledPin);
}
/* Check boot mode; if boot mode is 1 (UART download mode), /* 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. we will not be able to reset into normal mode once update is done.
@ -376,7 +373,7 @@ size_t UpdaterClass::writeStream(Stream &data) {
while(remaining()) { while(remaining()) {
if(_ledPin != -1) { if(_ledPin != -1) {
digitalWrite(LED_BUILTIN, _ledOn); // Switch LED on digitalWrite(_ledPin, _ledOn); // Switch LED on
} }
size_t bytesToRead = _bufferSize - _bufferLen; size_t bytesToRead = _bufferSize - _bufferLen;
if(bytesToRead > remaining()) { if(bytesToRead > remaining()) {
@ -394,7 +391,7 @@ size_t UpdaterClass::writeStream(Stream &data) {
} }
} }
if(_ledPin != -1) { if(_ledPin != -1) {
digitalWrite(LED_BUILTIN, _ledOn == HIGH ? LOW : HIGH); // Switch LED off digitalWrite(_ledPin, !_ledOn); // Switch LED off
} }
_bufferLen += toRead; _bufferLen += toRead;
if((_bufferLen == remaining() || _bufferLen == _bufferSize) && !_writeBuffer()) if((_bufferLen == remaining() || _bufferLen == _bufferSize) && !_writeBuffer())

View File

@ -165,7 +165,6 @@ class UpdaterClass {
int _ledPin; int _ledPin;
uint8_t _ledOn; uint8_t _ledOn;
int _ledStateRestore;
}; };
extern UpdaterClass Update; extern UpdaterClass Update;