|
@@ -7,8 +7,11 @@
|
|
|
// PinRegistry, so GxEPD2 compiles completely unmodified against it.
|
|
// PinRegistry, so GxEPD2 compiles completely unmodified against it.
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
#include <cstdint>
|
|
|
|
|
+#include <sstream>
|
|
|
|
|
+#include <string>
|
|
|
|
|
|
|
|
#include "esphome/core/hal.h"
|
|
#include "esphome/core/hal.h"
|
|
|
|
|
+#include "esphome/core/log.h"
|
|
|
#include "esphome/components/gxepd2/pin_registry.h"
|
|
#include "esphome/components/gxepd2/pin_registry.h"
|
|
|
|
|
|
|
|
#ifndef ESP32
|
|
#ifndef ESP32
|
|
@@ -39,13 +42,31 @@ inline void yield() { esphome::yield(); }
|
|
|
|
|
|
|
|
#define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t *>(addr))
|
|
#define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t *>(addr))
|
|
|
|
|
|
|
|
-// Stub: GxEPD2's serial diagnostics are opt-in and this component never
|
|
|
|
|
-// enables them.
|
|
|
|
|
|
|
+// GxEPD2's per-transfer timing diagnostics are opt-in (this component never
|
|
|
|
|
+// enables them, by passing serial_diag_bitrate=0 to init()) and stay
|
|
|
|
|
+// discarded here. But a handful of unconditional warnings - notably
|
|
|
|
|
+// GxEPD2_EPD::_waitWhileBusy()'s "Busy Timeout!" - also go through Serial,
|
|
|
|
|
+// and those matter: they're the only signal that the busy pin never
|
|
|
|
|
+// released. Buffer print() calls and flush to the logger on println(), so
|
|
|
|
|
+// that warning actually surfaces instead of vanishing silently.
|
|
|
class GxEPD2SerialShim {
|
|
class GxEPD2SerialShim {
|
|
|
public:
|
|
public:
|
|
|
void begin(uint32_t baud) {}
|
|
void begin(uint32_t baud) {}
|
|
|
- template<typename T> void print(T) {}
|
|
|
|
|
- template<typename T> void println(T) {}
|
|
|
|
|
- void println() {}
|
|
|
|
|
|
|
+ template<typename T> void print(T value) { this->buffer_ << value; }
|
|
|
|
|
+ template<typename T> void println(T value) {
|
|
|
|
|
+ this->buffer_ << value;
|
|
|
|
|
+ this->flush_();
|
|
|
|
|
+ }
|
|
|
|
|
+ void println() { this->flush_(); }
|
|
|
|
|
+
|
|
|
|
|
+ private:
|
|
|
|
|
+ void flush_() {
|
|
|
|
|
+ std::string line = this->buffer_.str();
|
|
|
|
|
+ if (!line.empty())
|
|
|
|
|
+ ESP_LOGW("gxepd2", "%s", line.c_str());
|
|
|
|
|
+ this->buffer_.str("");
|
|
|
|
|
+ this->buffer_.clear();
|
|
|
|
|
+ }
|
|
|
|
|
+ std::ostringstream buffer_;
|
|
|
};
|
|
};
|
|
|
inline GxEPD2SerialShim Serial; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
|
inline GxEPD2SerialShim Serial; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|