diff --git a/src/graphics/GxEPD2Multi.h b/src/graphics/GxEPD2Multi.h index f3807c9de..78ae06058 100644 --- a/src/graphics/GxEPD2Multi.h +++ b/src/graphics/GxEPD2Multi.h @@ -115,6 +115,10 @@ template class GxEPD2_Multi // Select driver by passing whichDriver as 0 or 1 GxEPD2_Multi(uint8_t whichDriver, int16_t cs, int16_t dc, int16_t rst, int16_t busy, SPIClass &spi) { + // Only the selected driver is allocated; the other stays null + driver0 = nullptr; + driver1 = nullptr; + assert(whichDriver == 0 || whichDriver == 1); which = whichDriver; LOG_DEBUG("GxEPD2_Multi driver: %d", which); @@ -128,6 +132,11 @@ template class GxEPD2_Multi } } + // The driver we allocate above is owned by this object, and a single display can only be driven + // by one of them: copying would alias that pointer. There is exactly one instance per device. + GxEPD2_Multi(const GxEPD2_Multi &) = delete; + GxEPD2_Multi &operator=(const GxEPD2_Multi &) = delete; + private: uint8_t which; GxEPD2_BW *driver0;