11using namespace display;
28static constexpr uint8_t NONE = 0;
29static constexpr uint8_t MIRROR_X = 1;
30static constexpr uint8_t MIRROR_Y = 2;
31static constexpr uint8_t SWAP_XY = 4;
33static constexpr uint32_t MAX_TRANSFER_TIME = 10;
34static constexpr size_t MAX_TRANSFER_SIZE = 128;
36static constexpr uint32_t FAST_BUSY_POLL_MS = 50;
37static constexpr uint8_t DELAY_FLAG = 0xFF;
40 public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
41 spi::DATA_RATE_2MHZ> {
43 EPaperBase(
const char *name, uint16_t width, uint16_t height,
const uint8_t *init_sequence =
nullptr,
45 uint8_t bits_per_pixel = 1, uint8_t planes = 1)
78 this->
cmd_data(command, data.begin(), data.size());
84 void setup()
override;
131 virtual bool reset();
244#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
247#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG
Helper class to request loop() to be called as fast as possible.
int int int const uint8_t ColorOrder ColorBitness bitness
int int int const uint8_t ColorOrder ColorBitness bool int int y_offset
virtual void fill(Color color)
Fill the entire screen with the given color.
int int int const uint8_t ColorOrder ColorBitness bool int int int x_pad
int int int const uint8_t * ptr
virtual void set_rotation(DisplayRotation rotation)
Internal method to set the display rotation with.
int int int const uint8_t ColorOrder ColorBitness bool big_endian
Rect get_clipping() const
Get the current the clipping rectangle.
int int int const uint8_t ColorOrder ColorBitness bool int x_offset
uint32_t update_start_time_
virtual void power_off()=0
Power the display off.
void command(uint8_t value)
void set_rotation(DisplayRotation rotation) override
virtual void abort_transfer()
const uint8_t * init_sequence_
void set_enable_pins(std::vector< GPIOPin * > enable_pins)
void set_transform(uint8_t transform)
void fill(Color color) override
void process_state_()
Process the state machine.
virtual void deep_sleep()=0
Place the display into deep sleep.
bool is_using_partial_update_() const
DisplayType display_type_
void on_safe_shutdown() override
int get_height_internal() override
void draw_pixel_at(int x, int y, Color color) override
Default implementation for monochrome displays where 8 pixels are packed to a byte.
bool init_sent_frame_(size_t length)
virtual bool after_refresh()
Called after the refresh, before power off, repeatedly until it returns true.
int get_height() override
bool pixel_axes_swapped() const override
uint32_t waiting_for_idle_start_
bool rotate_coordinates_(int &x, int &y)
Check and rotate coordinates based on the transform flags.
void record_sent_(size_t index, const uint8_t *data, size_t length)
void loop() override
Called during the loop task.
virtual void refresh_screen(bool partial)=0
Refresh the screen after data transfer.
uint8_t full_update_every_
virtual bool initialise(bool partial)
void set_dc_pin(GPIOPin *dc_pin)
void send_init_sequence_(const uint8_t *sequence, size_t length)
void dump_config() override
void update_effective_transform_()
uint32_t buffer_hash_() const
void set_reset_pin(GPIOPin *reset)
virtual bool transfer_data()=0
Methods that must be implemented by concrete classes to control the display.
bool buffer_is_mono_() const
split_buffer::SplitBuffer buffer_
void cmd_data(uint8_t command, const uint8_t *ptr, size_t length)
void cmd_data(uint8_t command, std::initializer_list< uint8_t > data)
virtual bool needs_previous_frame() const
void draw_rgb565_block_(uint8_t *buffer, int x_start, int y_start, int w, int h, const uint8_t *ptr, bool big_endian, int x_offset, int y_offset, int x_pad)
void request_full_update()
bool full_update_requested_
uint16_t busy_timeout_seconds_
split_buffer::SplitBuffer sent_
void set_state_(EPaperState state, uint16_t delay=0)
const char * epaper_state_to_string_()
uint8_t effective_transform_
virtual void power_on()=0
Power the display on.
HighFrequencyLoopRequester high_frequency_loop_
void set_reset_duration(uint32_t reset_duration)
void draw_pixels_internal(int x_start, int y_start, int w, int h, const uint8_t *ptr, ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override
void set_full_update_every(uint8_t full_update_every)
EPaperBase(const char *name, uint16_t width, uint16_t height, const uint8_t *init_sequence=nullptr, size_t init_sequence_length=0, DisplayType display_type=DISPLAY_TYPE_BINARY, uint8_t bits_per_pixel=1, uint8_t planes=1)
DisplayType get_display_type() override
void wait_for_idle_(bool should_wait)
bool hardware_reset_()
The reset pin part of reset(), for a driver that must skip what its parent adds to it.
size_t current_data_index_
uint32_t waiting_for_idle_last_print_
size_t init_sequence_length_
float get_setup_priority() const override
bool init_buffer_(size_t buffer_length)
void set_busy_pin(GPIOPin *busy)
int get_width_internal() override
std::vector< GPIOPin * > enable_pins_
The SPIDevice is what components using the SPI will create.
A SplitBuffer allocates a large memory buffer potentially as multiple smaller buffers to facilitate a...
void fill(uint8_t value) const
Fill the entire buffer with a single byte value.
void write(size_t index, const uint8_t *data, size_t length)
constexpr Color COLOR_ON(255, 255, 255, 255)
Turn the pixel ON.
constexpr uint8_t color_to_mono(Color color)
Map an RGB color to a single monochrome bit: 1 = white, 0 = black.
void HOT delay(uint32_t ms)