#pragma once // Minimal Arduino.h substitute for compiling GxEPD2 under ESP-IDF. GxEPD2's // vendored source calls down into a small, fixed set of Arduino primitives // (digitalWrite/pinMode/digitalRead on plain int16_t pin numbers, plus // delay/micros/yield) - this shim backs them with esphome::GPIOPin via // PinRegistry, so GxEPD2 compiles completely unmodified against it. #include #include "esphome/core/hal.h" #include "esphome/components/gxepd2/pin_registry.h" #ifndef ESP32 #define ESP32 #endif #define HIGH 1 #define LOW 0 #define INPUT 0 #define OUTPUT 1 #define INPUT_PULLUP 2 inline void pinMode(int16_t pin, uint8_t mode) {} inline void digitalWrite(int16_t pin, uint8_t value) { if (auto *p = esphome::gxepd2::PinRegistry::get(pin)) p->digital_write(value != 0); } inline int digitalRead(int16_t pin) { auto *p = esphome::gxepd2::PinRegistry::get(pin); return (p != nullptr && p->digital_read()) ? HIGH : LOW; } inline void delay(uint32_t ms) { esphome::delay(ms); } inline uint32_t micros() { return esphome::micros(); } inline void yield() { esphome::yield(); } #define pgm_read_byte(addr) (*reinterpret_cast(addr)) // Stub: GxEPD2's serial diagnostics are opt-in and this component never // enables them. class GxEPD2SerialShim { public: void begin(uint32_t baud) {} template void print(T) {} template void println(T) {} void println() {} }; inline GxEPD2SerialShim Serial; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)