Skip to content

LVGL driver for ST7796S display #3422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hw/drivers/display/lvgl/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pkg.deps.LVGL_ST7735S:
- "@apache-mynewt-core/hw/drivers/display/lvgl/tft/st7735s"
pkg.deps.LVGL_ST7789:
- "@apache-mynewt-core/hw/drivers/display/lvgl/tft/st7789"
pkg.deps.LVGL_ST7796S:
- "@apache-mynewt-core/hw/drivers/display/lvgl/tft/st7796S"

pkg.deps.LVGL_CST816S:
- "@apache-mynewt-core/hw/drivers/display/lvgl/indev/cst816s"
Expand Down
3 changes: 3 additions & 0 deletions hw/drivers/display/lvgl/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ syscfg.defs:
LVGL_ST7789:
description: Enable ST7789 display driver.
value:
LVGL_ST7796S:
description: Enable ST7796S display driver.
value:
LVGL_XPT2046:
description: Enable XPT2046 touchscreen driver.
value:
Expand Down
3 changes: 0 additions & 3 deletions hw/drivers/display/lvgl/tft/ili9341/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:

pkg.cflags:

pkg.deps:
- "@apache-mynewt-core/hw/bus/drivers/spi_common"
13 changes: 8 additions & 5 deletions hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@

static const uint8_t madctl[] = {
MADCTL_MX,
MADCTL_MX | MADCTL_MY | MADCTL_MV,
MADCTL_MY,
MADCTL_MV,
MADCTL_MY,
MADCTL_MX | MADCTL_MY | MADCTL_MV,
};

void
Expand Down Expand Up @@ -231,17 +231,20 @@ void
ili9341_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
uint8_t cmd[5];
lv_disp_t *disp = lv_disp_get_default();
lv_coord_t hor_res = lv_disp_get_hor_res(disp);
lv_coord_t ver_res = lv_disp_get_ver_res(disp);

if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ILI9341_HOR_RES || area->y1 >= ILI9341_VER_RES) {
if (area->x2 < 0 || area->y2 < 0 || area->x1 >= hor_res || area->y1 >= ver_res) {
lv_disp_flush_ready(drv);
return;
}

/* Truncate the area to the screen */
int32_t act_x1 = area->x1 < 0 ? 0 : area->x1;
int32_t act_y1 = area->y1 < 0 ? 0 : area->y1;
int32_t act_x2 = area->x2 >= ILI9341_HOR_RES ? ILI9341_HOR_RES - 1 : area->x2;
int32_t act_y2 = area->y2 >= ILI9341_VER_RES ? ILI9341_VER_RES - 1 : area->y2;
int32_t act_x2 = area->x2 >= hor_res ? hor_res - 1 : area->x2;
int32_t act_y2 = area->y2 >= ver_res ? ver_res - 1 : area->y2;

/* Column address */
cmd[0] = ILI9341_CASET;
Expand Down
9 changes: 6 additions & 3 deletions hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,20 @@ void
ili9486_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
uint8_t cmd[5];
lv_disp_t *disp = lv_disp_get_default();
lv_coord_t hor_res = lv_disp_get_hor_res(disp);
lv_coord_t ver_res = lv_disp_get_ver_res(disp);

if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ILI9486_HOR_RES || area->y1 >= ILI9486_VER_RES) {
if (area->x2 < 0 || area->y2 < 0 || area->x1 >= hor_res || area->y1 >= ver_res) {
lv_disp_flush_ready(drv);
return;
}

/* Truncate the area to the screen */
int32_t act_x1 = area->x1 < 0 ? 0 : area->x1;
int32_t act_y1 = area->y1 < 0 ? 0 : area->y1;
int32_t act_x2 = area->x2 >= ILI9486_HOR_RES ? ILI9486_HOR_RES - 1 : area->x2;
int32_t act_y2 = area->y2 >= ILI9486_VER_RES ? ILI9486_VER_RES - 1 : area->y2;
int32_t act_x2 = area->x2 >= hor_res ? hor_res - 1 : area->x2;
int32_t act_y2 = area->y2 >= ver_res ? ver_res - 1 : area->y2;

/* Column address */
cmd[0] = ILI9486_CASET;
Expand Down
9 changes: 6 additions & 3 deletions hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,20 @@ void
st7735s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
uint8_t cmd[5];
lv_disp_t *disp = lv_disp_get_default();
lv_coord_t hor_res = lv_disp_get_hor_res(disp);
lv_coord_t ver_res = lv_disp_get_ver_res(disp);

if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ST7735S_HOR_RES || area->y1 >= ST7735S_VER_RES) {
if (area->x2 < 0 || area->y2 < 0 || area->x1 >= hor_res || area->y1 >= ver_res) {
lv_disp_flush_ready(drv);
return;
}

/* Truncate the area to the screen */
int32_t act_x1 = area->x1 < 0 ? 0 : area->x1;
int32_t act_y1 = area->y1 < 0 ? 0 : area->y1;
int32_t act_x2 = area->x2 >= ST7735S_HOR_RES ? ST7735S_HOR_RES - 1 : area->x2;
int32_t act_y2 = area->y2 >= ST7735S_VER_RES ? ST7735S_VER_RES - 1 : area->y2;
int32_t act_x2 = area->x2 >= hor_res ? hor_res - 1 : area->x2;
int32_t act_y2 = area->y2 >= ver_res ? ver_res - 1 : area->y2;

/* Column address */
cmd[0] = ST7735S_CASET;
Expand Down
12 changes: 10 additions & 2 deletions hw/drivers/display/lvgl/tft/st7789/src/st7789.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,20 @@ void
st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
{
uint8_t cmd[5];
lv_disp_t *disp = lv_disp_get_default();
lv_coord_t hor_res = lv_disp_get_hor_res(disp);
lv_coord_t ver_res = lv_disp_get_ver_res(disp);

if (area->x2 < 0 || area->y2 < 0 || area->x1 >= hor_res || area->y1 >= ver_res) {
lv_disp_flush_ready(drv);
return;
}

/* Truncate the area to the screen */
int32_t offsetx1 = area->x1 < 0 ? 0 : area->x1;
int32_t offsety1 = area->y1 < 0 ? 0 : area->y1;
int32_t offsetx2 = area->x2 >= ST7789_HOR_RES ? ST7789_HOR_RES - 1 : area->x2;
int32_t offsety2 = area->y2 >= ST7789_VER_RES ? ST7789_VER_RES - 1 : area->y2;
int32_t offsetx2 = area->x2 >= hor_res ? hor_res - 1 : area->x2;
int32_t offsety2 = area->y2 >= ver_res ? ver_res - 1 : area->y2;

#if (CONFIG_LV_TFT_DISPLAY_OFFSETS)
offsetx1 += CONFIG_LV_TFT_DISPLAY_X_OFFSET;
Expand Down
23 changes: 23 additions & 0 deletions hw/drivers/display/lvgl/tft/st7796S/pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

pkg.name: hw/drivers/display/lvgl/tft/st7796S
pkg.description: LVGL display driver for ST7796S
pkg.author: "Apache Mynewt <[email protected]>"
pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:
Loading
Loading