-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sample: gui: Added basic sample for lvgl library
Added a basic sample showing how to use the LittlevGL library in an application. Signed-off-by: Jan Van Winkel <[email protected]>
- Loading branch information
1 parent
cbfcae7
commit 81301bf
Showing
13 changed files
with
261 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.. _gui-samples: | ||
|
||
GUI Samples | ||
########### | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:glob: | ||
|
||
**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.8.2) | ||
macro(set_conf_file) | ||
if(EXISTS ${APPLICATION_SOURCE_DIR}/prj_${BOARD}.conf) | ||
set(CONF_FILE "${APPLICATION_SOURCE_DIR}/prj_${BOARD}.conf") | ||
elseif(EXISTS ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf) | ||
set(CONF_FILE | ||
"prj.conf ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf") | ||
else() | ||
set(CONF_FILE "prj.conf") | ||
endif() | ||
endmacro() | ||
|
||
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) | ||
project(lvgl) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE ${app_sources}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
.. _lvgl-sample: | ||
|
||
LittlevGL Basic Sample | ||
###################### | ||
|
||
Overview | ||
******** | ||
|
||
This sample application displays "Hello World" in the center of the screen | ||
and a counter at the bottom which increments every second. | ||
|
||
Requirements | ||
************ | ||
|
||
- `nRF52840 Preview development kit`_ | ||
- `Adafruit 2.2 inch TFT Display`_ | ||
|
||
or a simulated display environment in a native Posix application: | ||
|
||
- :ref:`native_posix` | ||
- `SDL2`_ | ||
|
||
Wiring | ||
****** | ||
|
||
The nrf52840 Preview development kit should be connected as follows to the | ||
Adafruit TFT display. | ||
|
||
+-------------+----------------+ | ||
| | nrf52840 | | Adafruit TFT | | ||
| | Pin | | Pin | | ||
+=============+================+ | ||
| P0.27 | SCK | | ||
+-------------+----------------+ | ||
| P0.31 | D/C | | ||
+-------------+----------------+ | ||
| P0.30 | RST | | ||
+-------------+----------------+ | ||
| P0.26 | MOSI | | ||
+-------------+----------------+ | ||
| P0.29 | MISO | | ||
+-------------+----------------+ | ||
| P0.4 | NSS | | ||
+-------------+----------------+ | ||
|
||
Building and Running | ||
******************** | ||
|
||
Build this sample using the following commands: | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/gui/lvgl | ||
:board: nrf52840_pca10056 | ||
:goals: build | ||
:compact: | ||
|
||
See :ref:`nrf52840_pca10056` on how to flash the build. | ||
|
||
or | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/gui/lvgl | ||
:board: native_posix | ||
:goals: build | ||
:compact: | ||
|
||
References | ||
********** | ||
|
||
.. target-notes:: | ||
|
||
.. _LittlevGL Web Page: https://littlevgl.com/ | ||
.. _Adafruit 2.2 inch TFT Display: https://www.adafruit.com/product/1480 | ||
.. _nRF52840 Preview development kit: http://www.nordicsemi.com/eng/Products/nRF52840-Preview-DK | ||
.. _SDL2: https://www.libsdl.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CONFIG_SDL_DISPLAY=y | ||
CONFIG_SDL_DISPLAY_DEV_NAME="DISPLAY" | ||
CONFIG_SDL_DISPLAY_X_RES=320 | ||
CONFIG_SDL_DISPLAY_Y_RES=240 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CONFIG_SPI=y | ||
CONFIG_SPI_1=y | ||
CONFIG_SPI_NRFX=y | ||
|
||
CONFIG_ILI9340=y | ||
|
||
CONFIG_LVGL_BITS_PER_PIXEL=24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CONFIG_SPI=y | ||
CONFIG_SSD1673=y | ||
|
||
CONFIG_LVGL_COLOR_DEPTH_1=y | ||
CONFIG_LVGL_BITS_PER_PIXEL=1 | ||
CONFIG_LVGL_HOR_RES=250 | ||
CONFIG_LVGL_VER_RES=120 | ||
CONFIG_LVGL_DPI=130 | ||
CONFIG_LVGL_VDB_SIZE=16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2018 Jan Van Winkel <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#if defined(CONFIG_SPI_NRFX) && defined(CONFIG_ILI9340) | ||
|
||
#define DT_ILI9340_SPI_DEV_NAME \ | ||
DT_NORDIC_NRF_SPI_40004000_ILITEK_ILI9340_0_BUS_NAME | ||
|
||
#define DT_ILI9340_SPI_SLAVE_NUMBER \ | ||
DT_NORDIC_NRF_SPI_40004000_ILITEK_ILI9340_0_BASE_ADDRESS | ||
|
||
#define DT_ILI9340_CMD_DATA_GPIO_PORT_NAME \ | ||
DT_NORDIC_NRF_SPI_40004000_ILITEK_ILI9340_0_CMD_DATA_GPIOS_CONTROLLER | ||
|
||
#define DT_ILI9340_CMD_DATA_PIN \ | ||
DT_NORDIC_NRF_SPI_40004000_ILITEK_ILI9340_0_CMD_DATA_GPIOS_PIN | ||
|
||
#define DT_ILI9340_DEV_NAME \ | ||
DT_NORDIC_NRF_SPI_40004000_ILITEK_ILI9340_0_LABEL | ||
|
||
#define DT_ILI9340_RESET_GPIO_PORT_NAME \ | ||
DT_NORDIC_NRF_SPI_40004000_ILITEK_ILI9340_0_RESET_GPIOS_CONTROLLER | ||
|
||
#define DT_ILI9340_RESET_PIN \ | ||
DT_NORDIC_NRF_SPI_40004000_ILITEK_ILI9340_0_RESET_GPIOS_PIN | ||
|
||
#define DT_ILI9340_SPI_FREQ \ | ||
DT_NORDIC_NRF_SPI_40004000_ILITEK_ILI9340_0_SPI_MAX_FREQUENCY | ||
|
||
#define DT_ILI9340_CS_GPIO_PORT_NAME \ | ||
DT_NORDIC_NRF_SPI_40004000_CS_GPIOS_CONTROLLER | ||
|
||
#define DT_ILI9340_CS_GPIO_PIN \ | ||
DT_NORDIC_NRF_SPI_40004000_CS_GPIOS_PIN | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) 2018 Jan Van Winkel <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
&spi1 { | ||
status = "ok"; | ||
cs-gpios = <&gpio0 4 0>; | ||
|
||
ili9340@0 { | ||
compatible = "ilitek,ili9340"; | ||
label = "DISPLAY"; | ||
spi-max-frequency = <15151515>; | ||
reg = <0>; | ||
reset-gpios = <&gpio0 30 0>; | ||
cmd-data-gpios = <&gpio0 31 0>; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CONFIG_HEAP_MEM_POOL_SIZE=16384 | ||
|
||
CONFIG_DISPLAY=y | ||
CONFIG_DISPLAY_LOG_LEVEL_ERR=y | ||
|
||
CONFIG_LOG=y | ||
|
||
CONFIG_LVGL=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright (c) 2018 Jan Van Winkel <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
&spi3 { | ||
ssd1673fb@0 { | ||
label = "DISPLAY"; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sample: | ||
description: LVGL sample application | ||
name: lvgl | ||
tests: | ||
test: | ||
harness: display | ||
platform_whitelist: nrf52840_pca10056 reel_board | ||
tags: samples display gui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2018 Jan Van Winkel <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <device.h> | ||
#include <display.h> | ||
#include <lvgl.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <zephyr.h> | ||
|
||
#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL | ||
#include <logging/log.h> | ||
LOG_MODULE_REGISTER(app); | ||
|
||
void main(void) | ||
{ | ||
u32_t count = 0; | ||
char count_str[11] = {0}; | ||
struct device *display_dev; | ||
lv_obj_t *hello_world_label; | ||
lv_obj_t *count_label; | ||
|
||
display_dev = device_get_binding("DISPLAY"); | ||
|
||
if (display_dev == NULL) { | ||
LOG_ERR("device not found. Aborting test."); | ||
return; | ||
} | ||
|
||
hello_world_label = lv_label_create(lv_scr_act(), NULL); | ||
lv_label_set_text(hello_world_label, "Hello world!"); | ||
lv_obj_align(hello_world_label, NULL, LV_ALIGN_CENTER, 0, 0); | ||
|
||
count_label = lv_label_create(lv_scr_act(), NULL); | ||
lv_obj_align(count_label, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); | ||
|
||
display_blanking_off(display_dev); | ||
|
||
while (1) { | ||
if ((count % 100) == 0) { | ||
sprintf(count_str, "%d", count/100); | ||
lv_label_set_text(count_label, count_str); | ||
} | ||
lv_task_handler(); | ||
k_sleep(10); | ||
++count; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters