9 ESP_LOGCONFIG(TAG,
"Setting up QSPI_DBI");
37 if (this->
x_low_ % 2 == 1) {
43 if (this->
y_low_ % 2 == 1) {
57 this->
width_ - w - this->x_low_);
59 this->x_low_ = this->
width_;
72 uint32_t pos = (y * this->
width_) + x;
76 if (this->
buffer_[pos] != static_cast<uint8_t>(new_color >> 8)) {
77 this->
buffer_[pos] =
static_cast<uint8_t
>(new_color >> 8);
81 new_color = new_color & 0xFF;
83 if (this->
buffer_[pos] != new_color) {
124 ESP_LOGCONFIG(TAG,
"QSPI_DBI setup complete");
128 ESP_LOGVV(TAG,
"Set addr %d/%d, %d/%d", x1, y1, x2, y2);
135 put16_be(buf + 2, y2);
138 put16_be(buf + 2, x2);
146 if (w <= 0 || h <= 0)
150 return Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, x_pad);
152 auto stride = x_offset + w + x_pad;
153 for (
int y = 0;
y !=
h;
y++) {
154 memcpy(this->
buffer_ + ((
y + y_start) * this->
width_ + x_start) * 2,
155 ptr + ((
y + y_offset) * stride + x_offset) * 2, w * 2);
173 if (x_offset == 0 && x_pad == 0 && y_offset == 0) {
177 auto stride = x_offset + w + x_pad;
178 uint16_t
cmd = 0x2C00;
179 for (
int y = 0;
y !=
h;
y++) {
180 this->
write_cmd_addr_data(8, 0x32, 24, cmd, ptr + ((
y + y_offset) * stride + x_offset) * 2, w * 2, 4);
187 ESP_LOGV(TAG,
"Command %02X, length %d, bytes %s", cmd, len,
format_hex_pretty(bytes, len).c_str());
195 while (index != vec.size()) {
196 if (vec.size() - index < 2) {
197 ESP_LOGE(TAG,
"Malformed init sequence");
200 uint8_t
cmd = vec[index++];
201 uint8_t
x = vec[index++];
202 if (x == DELAY_FLAG) {
203 ESP_LOGV(TAG,
"Delay %dms", cmd);
206 uint8_t num_args = x & 0x7F;
207 if (vec.size() - index < num_args) {
208 ESP_LOGE(TAG,
"Malformed init sequence");
211 const auto *ptr = vec.data() + index;
219 ESP_LOGCONFIG(
"",
"QSPI_DBI Display");
220 ESP_LOGCONFIG(
"",
"Model: %s", this->
model_);
221 ESP_LOGCONFIG(TAG,
" Height: %u", this->
height_);
222 ESP_LOGCONFIG(TAG,
" Width: %u", this->
width_);
223 LOG_PIN(
" CS Pin: ", this->
cs_);
225 ESP_LOGCONFIG(TAG,
" SPI Data rate: %dMHz", (
unsigned) (this->
data_rate_ / 1000000));
virtual void digital_write(bool value)=0
int get_width_internal() override
std::string format_hex_pretty(const uint8_t *data, size_t length)
Format the byte array data of length len in pretty-printed, human-readable hex.
static uint16_t color_to_565(Color color, ColorOrder color_order=ColorOrder::COLOR_ORDER_RGB)
void set_addr_window_(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
void spi_setup() override
std::vector< std::vector< uint8_t > > init_sequences_
void write_init_sequence_()
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
display::ColorOrder color_mode_
The most significant bit is transmitted/received first.
void write_sequence_(const std::vector< uint8_t > &vec)
void write_command_(uint8_t cmd, const uint8_t *bytes, size_t len)
the RM67162 in quad SPI mode seems to work like this (not in the datasheet, this is deduced from the ...
void write_cmd_addr_data(size_t cmd_bits, uint32_t cmd, size_t addr_bits, uint32_t address, const uint8_t *data, size_t length, uint8_t bus_width=1)
void dump_config() override
void write_to_display_(int x_start, int y_start, int w, int h, const uint8_t *ptr, int x_offset, int y_offset, int x_pad)
int get_height_internal() override
void draw_absolute_pixel_internal(int x, int y, Color color) override
void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override
void reset_params_(bool ready=false)
Implementation of SPI Controller mode.
std::vector< uint8_t > bytes
void IRAM_ATTR HOT delay(uint32_t ms)