mirror of
https://github.com/meshtastic/firmware.git
synced 2026-09-21 13:55:24 -04:00
Merge eink-driver-layer wait-timeout fix
This commit is contained in:
commit
91dde7e4ea
2 files changed
+20
-4
No files matched your search
@@ -5,6 +5,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "SPILock.h"
|
||||
#include "Throttle.h"
|
||||
|
||||
using namespace NicheGraphics::Drivers;
|
||||
|
||||
@@ -132,12 +133,21 @@ void LCMEN213EFC1::update(uint8_t *imageData, UpdateTypes type)
|
||||
detachFromUpdate();
|
||||
}
|
||||
|
||||
void LCMEN213EFC1::wait()
|
||||
void LCMEN213EFC1::wait(uint32_t timeoutMs)
|
||||
{
|
||||
// Busy when LOW; bounded so a dead panel cannot hang the firmware
|
||||
// Fail-through: skip if an earlier step of this update sequence already failed
|
||||
if (failed)
|
||||
return;
|
||||
|
||||
// Busy when LOW; timeout sets failed so the sequence fails through (cleared by EInk::runOnce)
|
||||
const uint32_t start = millis();
|
||||
while (digitalRead(pin_busy) == LOW && millis() - start < 5000)
|
||||
while (digitalRead(pin_busy) == LOW) {
|
||||
if (!Throttle::isWithinTimespanMs(start, timeoutMs)) {
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
void LCMEN213EFC1::reset()
|
||||
@@ -156,6 +166,9 @@ void LCMEN213EFC1::reset()
|
||||
|
||||
void LCMEN213EFC1::sendCommand(const uint8_t command)
|
||||
{
|
||||
if (failed)
|
||||
return;
|
||||
|
||||
// Take firmware's SPI lock
|
||||
spiLock->lock();
|
||||
|
||||
@@ -177,6 +190,9 @@ void LCMEN213EFC1::sendData(uint8_t data)
|
||||
|
||||
void LCMEN213EFC1::sendData(const uint8_t *data, uint32_t size)
|
||||
{
|
||||
if (failed)
|
||||
return;
|
||||
|
||||
// Take firmware's SPI lock
|
||||
spiLock->lock();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class LCMEN213EFC1 : public EInk
|
||||
void update(uint8_t *imageData, UpdateTypes type) override;
|
||||
|
||||
protected:
|
||||
void wait();
|
||||
void wait(uint32_t timeoutMs = 5000);
|
||||
void reset();
|
||||
void sendCommand(const uint8_t command);
|
||||
void sendData(const uint8_t data);
|
||||
|
||||
Reference in new issue
Block a user