summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-09-22 17:06:37 +1000
committerjacqueline <me@jacqueline.id.au>2023-09-22 21:19:19 +1000
commit972edd746865c3852538be822aa07ab4b5762401 (patch)
treefcda5f5cd35ed576b26182f57a298da556c7eb00 /src/drivers
parentb192975cb1eeb4e6b7c7bf53cdf42701c55f034a (diff)
downloadtangara-fw-972edd746865c3852538be822aa07ab4b5762401.tar.gz
Rotate the display in hardware instead of software
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/display.cpp16
-rw-r--r--src/drivers/display_init.cpp2
2 files changed, 12 insertions, 6 deletions
diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp
index d83ef7eb..7c3b5ce5 100644
--- a/src/drivers/display.cpp
+++ b/src/drivers/display.cpp
@@ -20,6 +20,7 @@
#include "esp_err.h"
#include "esp_heap_caps.h"
#include "esp_intr_alloc.h"
+#include "esp_memory_utils.h"
#include "freertos/portable.h"
#include "freertos/portmacro.h"
#include "freertos/projdefs.h"
@@ -38,9 +39,9 @@
static const char* kTag = "DISPLAY";
// TODO(jacqueline): Encode width and height variations in the init data.
-static const uint8_t kDisplayWidth = 128 + 2;
-static const uint8_t kDisplayHeight = 160 + 1;
-static const uint8_t kTransactionQueueSize = 10;
+static const uint8_t kDisplayHeight = 128 + 2;
+static const uint8_t kDisplayWidth = 160 + 1;
+static const uint8_t kTransactionQueueSize = 2;
static const gpio_num_t kDisplayDr = GPIO_NUM_33;
static const gpio_num_t kDisplayLedEn = GPIO_NUM_32;
@@ -151,8 +152,10 @@ auto Display::Create(IGpios& expander,
display->driver_.draw_buf = &display->buffers_;
display->driver_.hor_res = kDisplayWidth;
display->driver_.ver_res = kDisplayHeight;
- display->driver_.sw_rotate = 1;
- display->driver_.rotated = LV_DISP_ROT_270;
+ // display->driver_.sw_rotate = 1;
+ // display->driver_.rotated = LV_DISP_ROT_270;
+ display->driver_.sw_rotate = 0;
+ display->driver_.rotated = LV_DISP_ROT_NONE;
display->driver_.antialiasing = 0;
display->driver_.flush_cb = &FlushDataCallback;
display->driver_.user_data = display.get();
@@ -170,6 +173,9 @@ Display::Display(IGpios& gpio, spi_device_handle_t handle)
memset(transaction_, 0, sizeof(spi_transaction_t));
buffer_ = reinterpret_cast<lv_color_t*>(heap_caps_malloc(
kDisplayBufferSize * sizeof(lv_color_t), MALLOC_CAP_DMA));
+
+ assert(esp_ptr_dma_capable(buffer_));
+ assert(esp_ptr_dma_capable(transaction_));
}
Display::~Display() {
diff --git a/src/drivers/display_init.cpp b/src/drivers/display_init.cpp
index c7eb5789..f1e94d9a 100644
--- a/src/drivers/display_init.cpp
+++ b/src/drivers/display_init.cpp
@@ -51,7 +51,7 @@ static const uint8_t kST7735RCommonHeader[]{
0x0E,
ST77XX_INVOFF, 0, // 13: Don't invert display, no args
ST77XX_MADCTL, 1, // 14: Mem access ctl (directions), 1 arg:
- 0xC0, // row/col addr, bottom-top refresh
+ 0xA8, // row/col addr, bottom-top refresh
ST77XX_COLMOD, 1, // 15: set color mode, 1 arg, no delay:
0x05
};