summaryrefslogtreecommitdiff
path: root/src/drivers/display.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-09-12 14:30:28 +1000
committerjacqueline <me@jacqueline.id.au>2023-09-12 14:30:28 +1000
commitad74a459216832499a41f5805fd820006c409017 (patch)
treef0b594fd394a4e819a863a877c59b243d3253d15 /src/drivers/display.cpp
parent86296c187f799eb94fe504e2491d7d991640fadc (diff)
downloadtangara-fw-ad74a459216832499a41f5805fd820006c409017.tar.gz
Use only one buffer for lvgl's display driver
We weren't actually making use of the double buffering, and it's a pain to implement properly.
Diffstat (limited to 'src/drivers/display.cpp')
-rw-r--r--src/drivers/display.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp
index a0ace021..d83ef7eb 100644
--- a/src/drivers/display.cpp
+++ b/src/drivers/display.cpp
@@ -50,8 +50,6 @@ static const gpio_num_t kDisplayCs = GPIO_NUM_22;
* The size of each of our two display buffers. This is fundamentally a balance
* between performance and memory usage. LVGL docs recommend a buffer 1/10th the
* size of the screen is the best tradeoff
- * We use two buffers so that one can be flushed to the screen at the same time
- * as the other is being drawn.
*/
static const int kDisplayBufferSize = kDisplayWidth * kDisplayHeight / 10;
@@ -147,8 +145,8 @@ auto Display::Create(IGpios& expander,
// The hardware is now configured correctly. Next, initialise the LVGL display
// driver.
ESP_LOGI(kTag, "Init buffers");
- lv_disp_draw_buf_init(&display->buffers_, display->buffer1_,
- display->buffer2_, kDisplayBufferSize);
+ lv_disp_draw_buf_init(&display->buffers_, display->buffer_, NULL,
+ kDisplayBufferSize);
lv_disp_drv_init(&display->driver_);
display->driver_.draw_buf = &display->buffers_;
display->driver_.hor_res = kDisplayWidth;
@@ -170,17 +168,14 @@ Display::Display(IGpios& gpio, spi_device_handle_t handle)
transaction_ = reinterpret_cast<spi_transaction_t*>(
heap_caps_malloc(sizeof(spi_transaction_t), MALLOC_CAP_DMA));
memset(transaction_, 0, sizeof(spi_transaction_t));
- buffer1_ = reinterpret_cast<lv_color_t*>(heap_caps_malloc(
- kDisplayBufferSize * sizeof(lv_color_t), MALLOC_CAP_DMA));
- buffer2_ = reinterpret_cast<lv_color_t*>(heap_caps_malloc(
+ buffer_ = reinterpret_cast<lv_color_t*>(heap_caps_malloc(
kDisplayBufferSize * sizeof(lv_color_t), MALLOC_CAP_DMA));
}
Display::~Display() {
ledc_fade_func_uninstall();
free(transaction_);
- free(buffer1_);
- free(buffer2_);
+ free(buffer_);
}
auto Display::SetDisplayOn(bool enabled) -> void {