Using custom init_internal_ for 7C

This commit is contained in:
NeilSCGH 2024-11-17 20:55:27 +01:00
parent 57d7204a09
commit c61c390e2e
3 changed files with 13 additions and 5 deletions

View file

@ -25,7 +25,7 @@ class DisplayBuffer : public Display {
protected: protected:
virtual void draw_absolute_pixel_internal(int x, int y, Color color) = 0; virtual void draw_absolute_pixel_internal(int x, int y, Color color) = 0;
virtual void init_internal_(uint32_t buffer_length); void init_internal_(uint32_t buffer_length);
uint8_t *buffer_{nullptr}; uint8_t *buffer_{nullptr};
}; };

View file

@ -113,10 +113,10 @@ static const uint8_t PARTIAL_UPD_2IN9_LUT[PARTIAL_UPD_2IN9_LUT_SIZE] =
void WaveshareEPaperBase::setup() { void WaveshareEPaperBase::setup() {
this->init_internal_(this->get_buffer_length_()); this->init_internal_(this->get_buffer_length_());
this->setup_pins_();//was in setup this->setup_pins_();
this->spi_setup(); this->spi_setup();
this->reset_(); this->reset_();
this->initialize();//was in setup this->initialize();
} }
void WaveshareEPaperBase::setup_pins_() { void WaveshareEPaperBase::setup_pins_() {
this->dc_pin_->setup(); // OUTPUT this->dc_pin_->setup(); // OUTPUT
@ -177,7 +177,14 @@ void WaveshareEPaper::fill(Color color) {
for (uint32_t i = 0; i < this->get_buffer_length_(); i++) for (uint32_t i = 0; i < this->get_buffer_length_(); i++)
this->buffer_[i] = fill; this->buffer_[i] = fill;
} }
void WaveshareEPaper7C::init_internal_(uint32_t buffer_length) { void WaveshareEPaper7C::setup() {
this->init_internal_7c_(this->get_buffer_length_());
this->setup_pins_();
this->spi_setup();
this->reset_();
this->initialize();
}
void WaveshareEPaper7C::init_internal_7c_(uint32_t buffer_length) {
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE); ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
uint32_t small_buffer_length = buffer_length / NUM_BUFFERS; uint32_t small_buffer_length = buffer_length / NUM_BUFFERS;

View file

@ -93,7 +93,8 @@ class WaveshareEPaper7C : public WaveshareEPaperBase {
protected: protected:
void draw_absolute_pixel_internal(int x, int y, Color color) override; void draw_absolute_pixel_internal(int x, int y, Color color) override;
uint32_t get_buffer_length_() override; uint32_t get_buffer_length_() override;
void init_internal_(uint32_t buffer_length); void setup() override;
void init_internal_7c_(uint32_t buffer_length);
static const int NUM_BUFFERS = 10; static const int NUM_BUFFERS = 10;
uint8_t *buffers_[NUM_BUFFERS]; uint8_t *buffers_[NUM_BUFFERS];