Rotate the display in hardware instead of software

custom
jacqueline 2 years ago
parent b192975cb1
commit 972edd7468
  1. 16
      src/drivers/display.cpp
  2. 2
      src/drivers/display_init.cpp

@ -20,6 +20,7 @@
#include "esp_err.h" #include "esp_err.h"
#include "esp_heap_caps.h" #include "esp_heap_caps.h"
#include "esp_intr_alloc.h" #include "esp_intr_alloc.h"
#include "esp_memory_utils.h"
#include "freertos/portable.h" #include "freertos/portable.h"
#include "freertos/portmacro.h" #include "freertos/portmacro.h"
#include "freertos/projdefs.h" #include "freertos/projdefs.h"
@ -38,9 +39,9 @@
static const char* kTag = "DISPLAY"; static const char* kTag = "DISPLAY";
// TODO(jacqueline): Encode width and height variations in the init data. // TODO(jacqueline): Encode width and height variations in the init data.
static const uint8_t kDisplayWidth = 128 + 2; static const uint8_t kDisplayHeight = 128 + 2;
static const uint8_t kDisplayHeight = 160 + 1; static const uint8_t kDisplayWidth = 160 + 1;
static const uint8_t kTransactionQueueSize = 10; static const uint8_t kTransactionQueueSize = 2;
static const gpio_num_t kDisplayDr = GPIO_NUM_33; static const gpio_num_t kDisplayDr = GPIO_NUM_33;
static const gpio_num_t kDisplayLedEn = GPIO_NUM_32; 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_.draw_buf = &display->buffers_;
display->driver_.hor_res = kDisplayWidth; display->driver_.hor_res = kDisplayWidth;
display->driver_.ver_res = kDisplayHeight; display->driver_.ver_res = kDisplayHeight;
display->driver_.sw_rotate = 1; // display->driver_.sw_rotate = 1;
display->driver_.rotated = LV_DISP_ROT_270; // 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_.antialiasing = 0;
display->driver_.flush_cb = &FlushDataCallback; display->driver_.flush_cb = &FlushDataCallback;
display->driver_.user_data = display.get(); 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)); memset(transaction_, 0, sizeof(spi_transaction_t));
buffer_ = 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)); kDisplayBufferSize * sizeof(lv_color_t), MALLOC_CAP_DMA));
assert(esp_ptr_dma_capable(buffer_));
assert(esp_ptr_dma_capable(transaction_));
} }
Display::~Display() { Display::~Display() {

@ -51,7 +51,7 @@ static const uint8_t kST7735RCommonHeader[]{
0x0E, 0x0E,
ST77XX_INVOFF, 0, // 13: Don't invert display, no args ST77XX_INVOFF, 0, // 13: Don't invert display, no args
ST77XX_MADCTL, 1, // 14: Mem access ctl (directions), 1 arg: 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: ST77XX_COLMOD, 1, // 15: set color mode, 1 arg, no delay:
0x05 0x05
}; };

Loading…
Cancel
Save