我用的中景园st7789 240x240的屏幕,canvas总是截掉80个像素的图片,我画一个图形放在0,0只显示一部分,然后canvas坐标慢慢往下(默认坐标系下y增加)就显示得越来越多。我并没有用任何变换。
void init_display(QueueHandle_t *msg_queue) {
queue = msg_queue;
esp_err_t ret = ESP_OK;
spi_config_t bus_conf = { .miso_io_num = SPI2_MISO,
.mosi_io_num = SPI2_MOSI, .sclk_io_num = SPI2_SCK,
.max_transfer_sz = 2 * 240 * 240 + 10, };
spi_bus_handle_t s_spi2_bus_handle = spi_bus_create(SPI2_HOST, &bus_conf);
scr_interface_spi_config_t spi_lcd_cfg = { .spi_bus = s_spi2_bus_handle,
.pin_num_cs = LCD_SPI_CS_PIN, .pin_num_dc = LCD_SPI_DC_PIN,
.clk_freq = LCD_SPI_CLOCK_FREQ, .swap_data = true, };
scr_interface_driver_t *iface_drv;
scr_interface_create(SCREEN_IFACE_SPI, &spi_lcd_cfg, &iface_drv);
ret = scr_find_driver(SCREEN_CONTROLLER_ST7789, &g_lcd);
if (ESP_OK != ret) {
ESP_LOGE(TAG, "screen find failed");
return;
}
scr_controller_config_t lcd_cfg =
{ .interface_drv = iface_drv, .pin_num_rst = LCD_SPI_RESET_PIN,
.pin_num_bckl = LCD_SPI_BL_PIN, .rst_active_level = 0,
.bckl_active_level = 1, .offset_hor = 0, .offset_ver = 0,
.width = 240, .height = 240, .rotate = SCR_DIR_LRTB, };
ret = g_lcd.init(&lcd_cfg);
if (ESP_OK != ret) {
ESP_LOGE(TAG, "screen initialize failed");
return;
}
g_lcd.get_info(&g_lcd_info);
ESP_LOGI(TAG, "Screen name:%s | width:%d | height:%d", g_lcd_info.name,
g_lcd_info.width, g_lcd_info.height);
lvgl_init(&g_lcd, NULL);
lv_style_t bg_style;
lv_style_init(&bg_style);
lv_style_set_bg_color(&bg_style, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_add_style(lv_scr_act(), LV_OBJ_PART_MAIN, &bg_style);
create_canvas();
// main_page();
}
void create_canvas() {
canvas = lv_canvas_create(lv_scr_act(), NULL);
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT,
LV_IMG_CF_TRUE_COLOR);
lv_obj_align(canvas, NULL, LV_ALIGN_IN_TOP_LEFT,0, 40);
lv_canvas_fill_bg(canvas, LV_COLOR_BLACK, LV_OPA_COVER);
lv_draw_rect_dsc_t rect_dsc;
lv_draw_rect_dsc_init(&rect_dsc);
rect_dsc.radius = 40;
rect_dsc.bg_opa = LV_OPA_TRANSP;
rect_dsc.border_width = 2;
rect_dsc.border_opa = LV_OPA_90;
rect_dsc.border_color = LV_COLOR_MAKE(0x00, 0xFF, 0x00);
lv_canvas_draw_rect(canvas, 0, 0, CANVAS_WIDTH, CANVAS_HEIGHT, &rect_dsc);
}
第一次用lvgl 小白一个
请问这会是我代码的问题吗?lvgl canvas 图形被截断
Moderator: ESP_Bob
-
- Posts: 13
- Joined: Tue Oct 05, 2021 2:53 am
Return to “ESP IoT Solution 中文讨论版”
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 14 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.