27 this->
mark_failed(LOG_STR(
"Buffer allocation failed"));
35 static constexpr uint32_t RESET_HIGH_MS = 50;
36 static constexpr uint32_t RESET_LOW_MS = 20;
37 static constexpr uint32_t RESET_SETTLE_MS = 50;
38 static constexpr uint32_t SOFT_RESET_MS = 5;
59 if (this->init_sequence_length_ - this->
init_index_ < 2) {
60 this->
mark_failed(LOG_STR(
"Malformed init sequence"));
70 if (this->init_sequence_length_ - this->
init_index_ < count) {
71 this->
mark_failed(LOG_STR(
"Malformed init sequence"));
78 for (uint8_t i = 0; i <
count; i++)
110 window.stride =
static_cast<uint16_t
>(this->
height_ / 4);
111 window.outer_start =
static_cast<uint16_t
>(this->
x_low_ >> 1);
112 window.outer_end =
static_cast<uint16_t
>(this->
x_high_ >> 1);
115 window.block_start =
static_cast<uint16_t
>((inv_min >> 2) / 3 * 3);
117 static_cast<uint16_t
>(std::min(((inv_max >> 2) / 3) * 3 + 2,
static_cast<int>(window.stride) - 1));
120 const int last_band = window.stride / 3 - 1;
121 window.caset_start =
static_cast<uint8_t
>(this->
column_start_ + last_band - window.block_end / 3);
122 window.caset_end =
static_cast<uint8_t
>(this->
column_start_ + last_band - window.block_start / 3);
125 window.stride =
static_cast<uint16_t
>(this->
width_ / 4);
126 window.outer_start =
static_cast<uint16_t
>(this->
y_low_ >> 1);
127 window.outer_end =
static_cast<uint16_t
>(this->
y_high_ >> 1);
128 const int block_min = this->
x_low_ >> 2;
129 const int block_max = this->
x_high_ >> 2;
130 window.block_start =
static_cast<uint16_t
>(block_min / 3 * 3);
131 window.block_end =
static_cast<uint16_t
>(std::min((block_max / 3) * 3 + 2,
static_cast<int>(window.stride) - 1));
132 window.caset_start =
static_cast<uint8_t
>(this->
column_start_ + window.block_start / 3);
133 window.caset_end =
static_cast<uint8_t
>(this->
column_start_ + window.block_end / 3);
169 if (window.
data_length() > this->buffer_length_ / 2) {
183 const int inv_y = this->
height_ - 1 -
y;
184 index =
static_cast<size_t>(
x >> 1) * (this->
height_ / 4) + (inv_y >> 2);
185 mask =
static_cast<uint8_t
>(1 << (7 - (((inv_y & 3) << 1) | (
x & 1))));
187 index =
static_cast<size_t>(
y >> 1) * (this->
width_ / 4) + (x >> 2);
188 mask =
static_cast<uint8_t
>(1 << (7 - (((
x & 3) << 1) | (
y & 1))));
191 uint8_t &value = this->
buffer_[index];
192 const uint8_t previous = value;
194 if (value == previous)
207 const uint8_t value = color.
is_on() ? 0xFF : 0x00;
211 if (this->
buffer_[index] == value)
214 if (first == this->buffer_length_)
218 if (first == this->buffer_length_)
224 const int stride = this->
height_ / 4;
225 this->
extend_dirty_(
static_cast<int>(first / stride) * 2, 0,
static_cast<int>(last / stride) * 2 + 1,
228 const int stride = this->
width_ / 4;
230 static_cast<int>(last / stride) * 2 + 1);
246 LOG_DISPLAY(
"",
"ST7305",
this);
247 ESP_LOGCONFIG(TAG,
" Model: %s", this->
model_);
248 ESP_LOGCONFIG(TAG,
" Orientation: %s",
250 : LOG_STR_LITERAL(
"portrait"));
253 LOG_PIN(
" DC Pin: ", this->
dc_pin_);
255 LOG_UPDATE_INTERVAL(
this);
void mark_failed()
Mark this component as failed.
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
virtual void digital_write(bool value)=0
void init_internal_(uint32_t buffer_length)
virtual void fill(Color color)
Fill the entire screen with the given color.
Rect get_clipping() const
Get the current the clipping rectangle.
void spi_setup() override
void write_byte(uint8_t data)
void draw_absolute_pixel_internal(int x, int y, Color color) override
void write_window_(const Window &window)
static constexpr uint32_t STARTUP_TIMEOUT_ID
Scheduler id for the non-blocking reset and init sequence.
void extend_dirty_(int x0, int y0, int x1, int y1)
void send_data_(const uint8_t *data, size_t length)
void send_init_sequence_()
const uint8_t * init_sequence_
void send_command_(uint8_t command)
void dump_config() override
Window compute_window_() const
size_t init_sequence_length_
void fill(Color color) override
ESPHOME_LOG_TAG(TAG, "st7305")
ESPHOME_ALWAYS_INLINE constexpr void assign_bits(T &value, std::type_identity_t< T > mask, bool on)
Set the bits of mask in value when on is true, clear them otherwise.
uint8_t progmem_read_byte(const uint8_t *addr)
bool is_on() ESPHOME_ALWAYS_INLINE
An addressable write window.
size_t data_length() const