merge the latest codes

This commit is contained in:
wlyu 2022-01-24 18:38:03 +08:00
commit df0404b4cc
1002 changed files with 317082 additions and 292 deletions

View File

@ -4,13 +4,16 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += framework_init.c
include $(APPDIR)/Application.mk
endif
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_DIR := general_functions app_test
SRC_FILES := main.c framework_init.c
ifeq ($(CONFIG_LIB_LV),y)
SRC_DIR += lv_app
endif
ifeq ($(CONFIG_APPLICATION_OTA),y)
SRC_DIR += ota

View File

@ -8,5 +8,26 @@ menu "test app"
bool "Config test spi flash"
default n
menuconfig USER_TEST_ADC
bool "Config test adc"
default n
if USER_TEST_ADC
if ADD_XIUOS_FETURES
config ADC_DEV_DRIVER
string "Set ADC dev path"
default "/dev/adc1_dev"
endif
endif
menuconfig USER_TEST_DAC
bool "Config test dac"
default n
if USER_TEST_DAC
if ADD_XIUOS_FETURES
config DAC_DEV_DRIVER
string "Set DAC dev path"
default "/dev/dac_dev"
endif
endif
endif
endmenu

View File

@ -4,4 +4,12 @@ ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y)
SRC_FILES += test_spi_flash.c
endif
ifeq ($(CONFIG_USER_TEST_ADC),y)
SRC_FILES += test_adc.c
endif
ifeq ($(CONFIG_USER_TEST_DAC),y)
SRC_FILES += test_dac.c
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_adc.c
* @brief: a application of adc function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/1/7
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
void test_adc()
{
int adc_fd;
uint8 adc_channel = 0x0;
uint16 adc_sample, adc_value_decimal = 0;
float adc_value;
adc_fd = PrivOpen(ADC_DEV_DRIVER, O_RDWR);
if (adc_fd < 0) {
KPrintf("open adc fd error %d\n", adc_fd);
return;
}
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = ADC_TYPE;
ioctl_cfg.args = &adc_channel;
if (0 != PrivIoctl(adc_fd, OPE_CFG, &ioctl_cfg)) {
KPrintf("ioctl adc fd error %d\n", adc_fd);
PrivClose(adc_fd);
return;
}
PrivRead(adc_fd, &adc_sample, 2);
adc_value = (float)adc_sample * (3.3 / 4096);
adc_value_decimal = (adc_value - (uint16)adc_value) * 1000;
printf("adc sample %u value integer %u decimal %u\n", adc_sample, (uint16)adc_value, adc_value_decimal);
PrivClose(adc_fd);
return;
}
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
// test_adc, test_adc, read 3.3 voltage data from adc);

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_dac.c
* @brief: a application of dac function
* @version: 2.0
* @author: AIIT XUOS Lab
* @date: 2022/1/11
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
void test_dac()
{
int dac_fd;
uint16 dac_set_value = 800;
uint16 dac_sample, dac_value_decimal = 0;
float dac_value;
dac_fd = PrivOpen(DAC_DEV_DRIVER, O_RDWR);
if (dac_fd < 0) {
KPrintf("open dac fd error %d\n", dac_fd);
return;
}
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = DAC_TYPE;
ioctl_cfg.args = &dac_set_value;
if (0 != PrivIoctl(dac_fd, OPE_CFG, &ioctl_cfg)) {
KPrintf("ioctl dac fd error %d\n", dac_fd);
PrivClose(dac_fd);
return;
}
PrivRead(dac_fd, &dac_sample, 2);
dac_value = (float)dac_sample * (3.3 / 4096);//Vref+ need to be 3.3V
dac_value_decimal = (dac_value - (uint16)dac_value) * 1000;
printf("dac sample %u value integer %u decimal %u\n", dac_sample, (uint16)dac_value, dac_value_decimal);
PrivClose(dac_fd);
return;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
test_dac, test_dac, set digital data to dac);

View File

@ -36,6 +36,8 @@ extern int Tb600bIaq10IaqInit(void);
extern int Tb600bTvoc10TvocInit(void);
extern int Tb600bWqHcho1osInit(void);
extern int lv_port_init(void);
typedef int (*InitFunc)(void);
struct InitDesc
{
@ -208,5 +210,9 @@ int FrameworkInit(void)
ConnectionDeviceFrameworkInit(framework);
#endif
#ifdef LIB_LV
lv_port_init();
#endif
return 0;
}

View File

@ -0,0 +1,3 @@
SRC_FILES := lv_init.c lv_demo.c lv_demo_calendar.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-17 Meco Man First version
*/
#include <lvgl.h>
#include <lv_port_indev_template.h>
#include "lv_demo_calendar.h"
#include <transform.h>
extern void lv_example_chart_2(void);
extern void lv_example_img_1(void);
extern void lv_example_img_2(void);
extern void lv_example_img_3(void);
extern void lv_example_img_4(void);
extern void lv_example_line_1(void);
extern void lv_example_aoteman(void);
void* lvgl_thread(void *parameter)
{
/* display demo; you may replace with your LVGL application at here */
// lv_demo_calendar();
// lv_example_img_1();
// lv_example_chart_2();
// lv_example_line_1();
lv_example_aoteman();
/* handle the tasks of LVGL */
while(1)
{
lv_task_handler();
PrivTaskDelay(10);
}
}
pthread_t lvgl_task;
static int lvgl_demo_init(void)
{
pthread_attr_t attr;
attr.schedparam.sched_priority = 25;
attr.stacksize = 4096;
PrivTaskCreate(&lvgl_task, &attr, lvgl_thread, NULL);
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),lvgl_demo_init, lvgl_demo_init, lvgl_demo_init );

View File

@ -0,0 +1,50 @@
#include <lvgl.h>
#include "lv_demo_calendar.h"
// #include <drv_lcd.h>
static void event_handler(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * obj = lv_event_get_current_target(e);
if(code == LV_EVENT_VALUE_CHANGED) {
lv_calendar_date_t date;
if(lv_calendar_get_pressed_date(obj, &date)) {
LV_LOG_USER("Clicked date: %02d.%02d.%d", date.day, date.month, date.year);
}
}
}
void lv_demo_calendar(void)
{
lv_obj_t * calendar = lv_calendar_create(lv_scr_act());
lv_obj_set_size(calendar, 320, 240);
lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event_cb(calendar, event_handler, LV_EVENT_ALL, NULL);
lv_calendar_set_today_date(calendar, 2021, 02, 23);
lv_calendar_set_showed_date(calendar, 2021, 02);
/*Highlight a few days*/
static lv_calendar_date_t highlighted_days[3]; /*Only its pointer will be saved so should be static*/
highlighted_days[0].year = 2021;
highlighted_days[0].month = 02;
highlighted_days[0].day = 6;
highlighted_days[1].year = 2021;
highlighted_days[1].month = 02;
highlighted_days[1].day = 11;
highlighted_days[2].year = 2021;
highlighted_days[2].month = 02;
highlighted_days[2].day = 22;
lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3);
#if LV_USE_CALENDAR_HEADER_DROPDOWN
lv_calendar_header_dropdown_create(calendar);
#elif LV_USE_CALENDAR_HEADER_ARROW
lv_calendar_header_arrow_create(calendar);
#endif
// lv_calendar_set_showed_date(calendar, 2021, 10);
}

View File

@ -0,0 +1,6 @@
#ifndef __LV_DEMO_CALENDAR_H__
#define __LV_DEMO_CALENDAR_H__
void lv_demo_calendar(void);
#endif

View File

@ -0,0 +1,39 @@
#include <lvgl.h>
#define DBG_TAG "LVGL"
#define DBG_LVL DBG_INFO
#ifndef PKG_USING_LVGL_DISP_DEVICE
#include <lv_port_disp_template.h>
#endif
#ifndef PKG_USING_LVGL_INDEV_DEVICE
#include <lv_port_indev_template.h>
#endif
extern void lv_port_disp_init(void);
extern void lv_port_indev_init(void);
#if LV_USE_LOG && LV_LOG_PRINTF
static void lv_rt_log(const char *buf)
{
printf(buf);
printf("\n");
}
#endif
int lv_port_init(void)
{
#if LV_USE_LOG && LV_LOG_PRINTF
lv_log_register_print_cb(lv_rt_log);
#endif
lv_init();
#ifndef PKG_USING_LVGL_DISP_DEVICE
lv_port_disp_init();
#endif
#ifndef PKG_USING_LVGL_INDEV_DEVICE
lv_port_indev_init();
#endif
return 0;
}

View File

@ -18,7 +18,9 @@
* @date 2021.12.10
*/
#include <user_api.h>
#ifdef ADD_XIUOS_FETURES
# include <user_api.h>
#endif
#include <sensor.h>
/**

View File

@ -18,7 +18,9 @@
* @date 2021.12.15
*/
#include <user_api.h>
#ifdef ADD_XIUOS_FETURES
# include <user_api.h>
#endif
#include <sensor.h>

View File

@ -18,7 +18,9 @@
* @date 2021.12.14
*/
#include <user_api.h>
#ifdef ADD_XIUOS_FETURES
# include <user_api.h>
#endif
#include <sensor.h>
// struct iaq_data {

View File

@ -18,7 +18,9 @@
* @date 2021.12.15
*/
#include <user_api.h>
#ifdef ADD_XIUOS_FETURES
# include <user_api.h>
#endif
#include <sensor.h>

View File

@ -34,6 +34,11 @@ config SENSOR_AS830
endif
if ADD_NUTTX_FETURES
config SENSOR_DEVICE_AS830_DEV
string "as830 device uart path"
default "/dev/ttyS1"
---help---
If USART1 is selected, then fill in /dev/ttyS1 here.
endif

View File

@ -0,0 +1,4 @@
############################################################################
# APP_Framework/Framework/sensor/ch4/Make.defs
############################################################################
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/ch4/*/Make.defs)

View File

@ -0,0 +1,6 @@
############################################################################
# APP_Framework/Framework/sensor/ch4/as830/Make.defs
############################################################################
ifneq ($(CONFIG_SENSOR_AS830),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/ch4/as830
endif

View File

@ -1,3 +1,11 @@
SRC_FILES := as830.c
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += as830.c
include $(APPDIR)/Application.mk
endif
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES := as830.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -34,6 +34,18 @@ static struct SensorProductInfo info =
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
#ifdef ADD_NUTTX_FETURES
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
sdev->fd = PrivOpen(SENSOR_DEVICE_AS830_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_AS830_DEV);
return -1;
}
return sdev->fd;
}
#else
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
@ -64,6 +76,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
return result;
}
#endif
/**
* @description: Read sensor device

View File

@ -34,6 +34,11 @@ config SENSOR_TB600B_WQ_HCHO1OS
endif
if ADD_NUTTX_FETURES
config SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV
string "tb600b wq_hcho1os device uart path"
default "/dev/ttyS1"
---help---
If USART1 is selected, then fill in /dev/ttyS1 here.
endif

View File

@ -0,0 +1,4 @@
############################################################################
# APP_Framework/Framework/sensor/hcho/Make.defs
############################################################################
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/hcho/*/Make.defs)

View File

@ -0,0 +1,6 @@
############################################################################
# APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os/Make.defs
############################################################################
ifneq ($(CONFIG_SENSOR_TB600B_WQ_HCHO1OS),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/hcho/tb600b_wq_hcho1os
endif

View File

@ -1,3 +1,12 @@
SRC_FILES := tb600b_wq_hcho1os.c
include $(KERNEL_ROOT)/.config
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += tb600b_wq_hcho1os.c
include $(APPDIR)/Application.mk
endif
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES := tb600b_wq_hcho1os.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -35,6 +35,18 @@ static struct SensorProductInfo info =
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
#ifdef ADD_NUTTX_FETURES
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
sdev->fd = PrivOpen(SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_TB600B_WQ_HCHO1OS_DEV);
return -1;
}
return sdev->fd;
}
#else
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
@ -65,6 +77,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
return result;
}
#endif
/**
* @description: Read sensor device

View File

@ -34,6 +34,11 @@ config SENSOR_TB600B_IAQ10
endif
if ADD_NUTTX_FETURES
config SENSOR_DEVICE_TB600B_IAQ10_DEV
string "tb600b iaq10 device uart path"
default "/dev/ttyS1"
---help---
If USART1 is selected, then fill in /dev/ttyS1 here.
endif

View File

@ -0,0 +1,4 @@
############################################################################
# APP_Framework/Framework/sensor/iaq/Make.defs
############################################################################
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/iaq/*/Make.defs)

View File

@ -0,0 +1,6 @@
############################################################################
# APP_Framework/Framework/sensor/iaq/tb600b_iaq10/Make.defs
############################################################################
ifneq ($(CONFIG_SENSOR_TB600B_IAQ10),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/iaq/tb600b_iaq10
endif

View File

@ -1,3 +1,12 @@
SRC_FILES := tb600b_iaq10.c
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += tb600b_iaq10.c
include $(APPDIR)/Application.mk
endif
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES := tb600b_iaq10.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -43,6 +43,17 @@ static struct SensorProductInfo info =
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
#ifdef ADD_NUTTX_FETURES
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
sdev->fd = PrivOpen(SENSOR_DEVICE_TB600B_IAQ10_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_TB600B_IAQ10_DEV);
}
return sdev->fd;
}
#else
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
@ -73,6 +84,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
return result;
}
#endif
/**
* @description: Read sensor device

View File

@ -34,6 +34,11 @@ config SENSOR_TB600B_TVOC10
endif
if ADD_NUTTX_FETURES
config SENSOR_DEVICE_TB600B_TVOC10_DEV
string "tb600b tvoc10 device uart path"
default "/dev/ttyS1"
---help---
If USART1 is selected, then fill in /dev/ttyS1 here.
endif

View File

@ -0,0 +1,4 @@
############################################################################
# APP_Framework/Framework/sensor/tvoc/Make.defs
############################################################################
include $(wildcard $(APPDIR)/../../../APP_Framework/Framework/sensor/tvoc/*/Make.defs)

View File

@ -0,0 +1,6 @@
############################################################################
# APP_Framework/Framework/sensor/tvoc/tb600b_tvoc10/Make.defs
############################################################################
ifneq ($(CONFIG_SENSOR_TB600B_TVOC10),)
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Framework/sensor/tvoc/tb600b_tvoc10
endif

View File

@ -1,3 +1,12 @@
SRC_FILES := tb600b_tvoc10.c
include $(KERNEL_ROOT)/.config
include $(KERNEL_ROOT)/compiler.mk
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += tb600b_tvoc10.c
include $(APPDIR)/Application.mk
endif
ifeq ($(CONFIG_ADD_XIUOS_FETURES),y)
SRC_FILES := tb600b_tvoc10.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -35,6 +35,18 @@ static struct SensorProductInfo info =
* @param sdev - sensor device pointer
* @return success: 1 , failure: other
*/
#ifdef ADD_NUTTX_FETURES
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
sdev->fd = PrivOpen(SENSOR_DEVICE_TB600B_TVOC10_DEV, O_RDWR);
if (sdev->fd < 0) {
printf("open %s error\n", SENSOR_DEVICE_TB600B_TVOC10_DEV);
return -1;
}
return sdev->fd;
}
#else
static int SensorDeviceOpen(struct SensorDevice *sdev)
{
int result = 0;
@ -65,6 +77,7 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
return result;
}
#endif
/**
* @description: Read sensor device

View File

@ -138,6 +138,13 @@ static int PrivPinIoctl(int fd, int cmd, void *args)
return ioctl(fd, cmd, pin_cfg);
}
static int PrivLcdIoctl(int fd, int cmd, void *args)
{
struct DeviceLcdInfo *lcd_cfg = (struct DeviceLcdInfo *)args;
return ioctl(fd, cmd, lcd_cfg);
}
int PrivIoctl(int fd, int cmd, void *args)
{
int ret;
@ -154,6 +161,13 @@ int PrivIoctl(int fd, int cmd, void *args)
case I2C_TYPE:
ret = ioctl(fd, cmd, ioctl_cfg->args);
break;
case LCD_TYPE:
ret = PrivLcdIoctl(fd, cmd, ioctl_cfg->args);
break;
case ADC_TYPE:
case DAC_TYPE:
ret = ioctl(fd, cmd, ioctl_cfg->args);
break;
default:
break;
}

View File

@ -138,6 +138,9 @@ enum IoctlDriverType
SPI_TYPE,
I2C_TYPE,
PIN_TYPE,
LCD_TYPE,
ADC_TYPE,
DAC_TYPE,
DEFAULT_TYPE,
};
@ -147,6 +150,38 @@ struct PrivIoctlCfg
void *args;
};
typedef struct
{
uint16 x_pos;
uint16 y_pos;
uint16 width;
uint16 height;
uint8 font_size;
uint8 *addr;
uint16 font_color;
uint16 back_color;
}LcdStringParam;
typedef struct
{
uint16 x_startpos;
uint16 x_endpos;
uint16 y_startpos;
uint16 y_endpos;
void* pixel_color;
}LcdPixelParam;
typedef struct
{
char type; // 0:write string;1:write dot
LcdPixelParam pixel_info;
LcdStringParam string_info;
}LcdWriteParam;
#define PRIV_SYSTICK_GET (CurrentTicksGain())
#define PRIV_LCD_DEV "/dev/lcd_dev"
#define MY_DISP_HOR_RES BSP_LCD_Y_MAX
#define MY_DISP_VER_RES BSP_LCD_X_MAX
/**********************mutex**************************/
int PrivMutexCreate(pthread_mutex_t *p_mutex, const pthread_mutexattr_t *attr);

View File

@ -5,8 +5,8 @@ menu "APP_Framework"
option env="SRC_APP_DIR"
default "."
source "$APP_DIR/Applications/Kconfig"
source "$APP_DIR/Framework/Kconfig"
source "$APP_DIR/Applications/Kconfig"
source "$APP_DIR/lib/Kconfig"

View File

@ -1,5 +1,4 @@
menu "lib"
choice
prompt "chose a kind of lib for app"
default APP_SELECT_NEWLIB
@ -12,4 +11,5 @@ menu "lib"
endchoice
source "$APP_DIR/lib/cJSON/Kconfig"
source "$APP_DIR/lib/queue/Kconfig"
source "$APP_DIR/lib/lvgl/Kconfig"
endmenu

View File

@ -1,9 +1,13 @@
SRC_DIR :=
# SRC_DIR := lvgl
ifeq ($(CONFIG_APP_SELECT_NEWLIB),y)
ifeq ($(CONFIG_SEPARATE_COMPILE),y)
SRC_DIR += app_newlib
endif
ifeq ($(CONFIG_SEPARATE_COMPILE),y)
SRC_DIR += app_newlib
endif
endif
ifeq ($(CONFIG_LIB_LV),y)
SRC_DIR += lvgl
endif

View File

@ -0,0 +1,8 @@
codecov:
notify:
require_ci_to_pass: true
comment: off
coverage:
status:
patch: off
project: off

View File

@ -0,0 +1,6 @@
[*.{c,h,ino}]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

View File

@ -0,0 +1,94 @@
if(ESP_PLATFORM)
file(GLOB_RECURSE SOURCES src/*.c)
idf_build_get_property(LV_MICROPYTHON LV_MICROPYTHON)
if (LV_MICROPYTHON)
idf_component_register(SRCS ${SOURCES}
INCLUDE_DIRS . src ../
REQUIRES main)
else()
idf_component_register(SRCS ${SOURCES}
INCLUDE_DIRS . src ../)
endif()
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_CONF_INCLUDE_SIMPLE")
if (CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM)
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_ATTRIBUTE_FAST_MEM=IRAM_ATTR")
endif()
elseif(ZEPHYR_BASE)
if(CONFIG_LVGL)
zephyr_include_directories(${ZEPHYR_BASE}/lib/gui/lvgl)
target_include_directories(lvgl INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
zephyr_compile_definitions(LV_CONF_KCONFIG_EXTERNAL_INCLUDE=<autoconf.h>)
zephyr_library()
file(GLOB_RECURSE SOURCES src/*.c)
zephyr_library_sources(${SOURCES})
endif(CONFIG_LVGL)
else()
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_LIST_DIR}/src/*.c)
file(GLOB_RECURSE EXAMPLE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/examples/*.c)
if(MICROPY_DIR)
# with micropython, build lvgl as interface library
# link chain is: lvgl_interface [lvgl] usermod_lvgl_bindings [lv_bindings] usermod [micropython] firmware [micropython]
add_library(lvgl_interface INTERFACE)
# ${SOURCES} must NOT be given to add_library directly for some reason (won't be built)
target_sources(lvgl_interface INTERFACE ${SOURCES})
# Micropython builds with -Werror; we need to suppress some warnings, such as:
#
# /home/test/build/lv_micropython/ports/rp2/build-PICO/lv_mp.c:29316:16: error: 'lv_style_transition_dsc_t_path_xcb_callback' defined but not used [-Werror=unused-function]
# 29316 | STATIC int32_t lv_style_transition_dsc_t_path_xcb_callback(const struct _lv_anim_t * arg0)
# | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target_compile_options(lvgl_interface INTERFACE -Wno-unused-function)
else(MICROPY_DIR)
# without micropython, build lvgl and examples libs normally
# default linux build uses this scope
add_library(lvgl STATIC ${SOURCES})
add_library(lvgl_examples STATIC ${EXAMPLE_SOURCES})
include_directories(${CMAKE_SOURCE_DIR})
# Lbrary and headers can be installed to system using make install
file(GLOB LVGL_PUBLIC_HEADERS
"${CMAKE_SOURCE_DIR}/lv_conf.h"
"${CMAKE_SOURCE_DIR}/lvgl.h")
if("${LIB_INSTALL_DIR}" STREQUAL "")
set(LIB_INSTALL_DIR "lib")
endif()
if("${INC_INSTALL_DIR}" STREQUAL "")
set(INC_INSTALL_DIR "include/lvgl")
endif()
install(DIRECTORY "${CMAKE_SOURCE_DIR}/src"
DESTINATION "${CMAKE_INSTALL_PREFIX}/${INC_INSTALL_DIR}/"
FILES_MATCHING
PATTERN "*.h")
set_target_properties(lvgl PROPERTIES
OUTPUT_NAME lvgl
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
PUBLIC_HEADER "${LVGL_PUBLIC_HEADERS}")
install(TARGETS lvgl
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}")
endif(MICROPY_DIR)
endif()

View File

@ -0,0 +1,860 @@
# Kconfig file for LVGL v8.0
menuconfig LIB_LV
bool "Enable LittleVGL "
default n
if 0
menu "LVGL configuration"
# Define CONFIG_LV_CONF_SKIP so we can use LVGL
# without lv_conf.h file, the lv_conf_internal.h and
# lv_conf_kconfig.h files are used instead.
config LV_CONF_SKIP
bool
default n
config LV_CONF_MINIMAL
bool "LVGL minimal configuration."
menu "Color settings"
choice
prompt "Color depth."
default LV_COLOR_DEPTH_16
help
Color depth to be used.
config LV_COLOR_DEPTH_32
bool "32: ARGB8888"
config LV_COLOR_DEPTH_16
bool "16: RGB565"
config LV_COLOR_DEPTH_8
bool "8: RGB232"
config LV_COLOR_DEPTH_1
bool "1: 1 byte per pixel"
endchoice
config LV_COLOR_DEPTH
int
default 1 if LV_COLOR_DEPTH_1
default 8 if LV_COLOR_DEPTH_8
default 16 if LV_COLOR_DEPTH_16
default 32 if LV_COLOR_DEPTH_32
config LV_COLOR_16_SWAP
bool "Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)."
depends on LV_COLOR_DEPTH_16
config LV_COLOR_SCREEN_TRANSP
bool "Enable more complex drawing routines to manage screens transparency."
depends on LV_COLOR_DEPTH_32
help
Can be used if the UI is above another layer, e.g. an OSD menu or video player.
Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to
non LV_OPA_COVER value
config LV_COLOR_MIX_ROUND_OFS
int "Adjust color mix functions rounding"
default 128 if !LV_COLOR_DEPTH_32
default 0 if LV_COLOR_DEPTH_32
range 0 254
help
0: no adjustment, get the integer part of the result (round down)
64: round up from x.75
128: round up from half
192: round up from x.25
254: round up
config LV_COLOR_CHROMA_KEY_HEX
hex "Images pixels with this color will not be drawn (if they are chroma keyed)."
range 0x000000 0xFFFFFF
default 0x00FF00
help
See misc/lv_color.h for some color values examples.
endmenu
menu "Memory settings"
config LV_MEM_CUSTOM
bool "If true use custom malloc/free, otherwise use the built-in `lv_mem_alloc()` and `lv_mem_free()`"
config LV_MEM_SIZE_KILOBYTES
int "Size of the memory used by `lv_mem_alloc` in kilobytes (>= 2kB)"
range 2 128
default 32
depends on !LV_MEM_CUSTOM
config LV_MEM_ADDR
hex "Address for the memory pool instead of allocating it as a normal array"
default 0x0
depends on !LV_MEM_CUSTOM
config LV_MEM_CUSTOM_INCLUDE
string "Header to include for the custom memory function"
default "stdlib.h"
depends on LV_MEM_CUSTOM
config LV_MEM_BUF_MAX_NUM
int "Number of the memory buffer"
default 16
help
Number of the intermediate memory buffer used during rendering and other
internal processing mechanisms. You will see an error log message if
there wasn't enough buffers.
config LV_MEMCPY_MEMSET_STD
bool "Use the standard memcpy and memset instead of LVGL's own functions"
endmenu
menu "HAL Settings"
config LV_DISP_DEF_REFR_PERIOD
int "Default display refresh period (ms)."
default 30
help
Can be changed in the display driver (`lv_disp_drv_t`).
config LV_INDEV_DEF_READ_PERIOD
int "Input device read period [ms]."
default 30
config LV_TICK_CUSTOM
bool "Use a custom tick source"
config LV_TICK_CUSTOM_INCLUDE
string "Header for the system time function"
default "Arduino.h"
depends on LV_TICK_CUSTOM
config LV_DPI_DEF
int "Default Dots Per Inch (in px)."
default 130
help
Used to initialize default sizes such as widgets sized, style paddings.
(Not so important, you can adjust it to modify default sizes and spaces)
endmenu
menu "Feature configuration"
menu "Drawing"
config LV_DRAW_COMPLEX
bool "Enable complex draw engine"
default y
help
Required to draw shadow, gradient, rounded corners, circles, arc, skew lines,
image transformations or any masks.
config LV_SHADOW_CACHE_SIZE
int "Allow buffering some shadow calculation"
depends on LV_DRAW_COMPLEX
default 0
help
LV_SHADOW_CACHE_SIZE is the max shadow size to buffer, where
shadow size is `shadow_width + radius`.
Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost.
config LV_CIRCLE_CACHE_SIZE
int "Set number of maximally cached circle data"
depends on LV_DRAW_COMPLEX
default 4
help
The circumference of 1/4 circle are saved for anti-aliasing
radius * 4 bytes are used per circle (the most often used
radiuses are saved).
Set to 0 to disable caching.
config LV_IMG_CACHE_DEF_SIZE
int "Default image cache size. 0 to disable caching."
default 0
help
If only the built-in image formats are used there is no real advantage of caching.
(I.e. no new image decoder is added).
With complex image decoders (e.g. PNG or JPG) caching can
save the continuous open/decode of images.
However the opened images might consume additional RAM.
config LV_DISP_ROT_MAX_BUF
int "Maximum buffer size to allocate for rotation"
default 10240
help
Only used if software rotation is enabled in the display driver.
endmenu
menu "GPU"
config LV_USE_EXTERNAL_RENDERER
bool
config LV_USE_GPU_STM32_DMA2D
bool "Enable STM32 DMA2D (aka Chrom Art) GPU."
config LV_GPU_DMA2D_CMSIS_INCLUDE
string "include path of CMSIS header of target processor"
depends on LV_USE_GPU_STM32_DMA2D
default ""
help
Must be defined to include path of CMSIS header of target processor
e.g. "stm32f769xx.h" or "stm32f429xx.h"
config LV_USE_GPU_NXP_PXP
bool "Use NXP's PXP GPU iMX RTxxx platforms."
config LV_USE_GPU_NXP_PXP_AUTO_INIT
bool "Call lv_gpu_nxp_pxp_init() automatically or manually."
depends on LV_USE_GPU_NXP_PXP
help
1: Add default bare metal and FreeRTOS interrupt handling
routines for PXP (lv_gpu_nxp_pxp_osa.c) and call
lv_gpu_nxp_pxp_init() automatically during lv_init().
Note that symbol SDK_OS_FREE_RTOS has to be defined in order
to use FreeRTOS OSA, otherwise bare-metal implementation is
selected.
0: lv_gpu_nxp_pxp_init() has to be called manually before
lv_init().
config LV_USE_GPU_NXP_VG_LITE
bool "Use NXP's VG-Lite GPU iMX RTxxx platforms."
config LV_USE_GPU_SDL
bool "Use SDL renderer API"
select LV_USE_EXTERNAL_RENDERER
default n
config LV_GPU_SDL_INCLUDE_PATH
string "include path of SDL header"
depends on LV_USE_GPU_SDL
default "SDL2/SDL.h"
endmenu
menu "Logging"
config LV_USE_LOG
bool "Enable the log module"
choice
bool "Default log verbosity" if LV_USE_LOG
default LV_LOG_LEVEL_WARN
help
Specify how important log should be added.
config LV_LOG_LEVEL_TRACE
bool "A lot of logs to give detailed information"
config LV_LOG_LEVEL_INFO
bool "Log important events"
config LV_LOG_LEVEL_WARN
bool "Log if something unwanted happened but didn't cause a problem"
config LV_LOG_LEVEL_ERROR
bool "Only critical issues, when the system may fail"
config LV_LOG_LEVEL_USER
bool "Only logs added by the user"
config LV_LOG_LEVEL_NONE
bool "Do not log anything"
endchoice
config LV_LOG_LEVEL
int
default 0 if LV_LOG_LEVEL_TRACE
default 1 if LV_LOG_LEVEL_INFO
default 2 if LV_LOG_LEVEL_WARN
default 3 if LV_LOG_LEVEL_ERROR
default 4 if LV_LOG_LEVEL_USER
default 5 if LV_LOG_LEVEL_NONE
config LV_LOG_PRINTF
bool "Print the log with 'printf'" if LV_USE_LOG
help
Use printf for log output.
If not set the user needs to register a callback with `lv_log_register_print_cb`.
config LV_LOG_TRACE_MEM
bool "Enable/Disable LV_LOG_TRACE in mem module"
default y
depends on LV_USE_LOG
config LV_LOG_TRACE_TIMER
bool "Enable/Disable LV_LOG_TRACE in timer module"
default y
depends on LV_USE_LOG
config LV_LOG_TRACE_INDEV
bool "Enable/Disable LV_LOG_TRACE in indev module"
default y
depends on LV_USE_LOG
config LV_LOG_TRACE_DISP_REFR
bool "Enable/Disable LV_LOG_TRACE in disp refr module"
default y
depends on LV_USE_LOG
config LV_LOG_TRACE_EVENT
bool "Enable/Disable LV_LOG_TRACE in event module"
default y
depends on LV_USE_LOG
config LV_LOG_TRACE_OBJ_CREATE
bool "Enable/Disable LV_LOG_TRACE in obj create module"
default y
depends on LV_USE_LOG
config LV_LOG_TRACE_LAYOUT
bool "Enable/Disable LV_LOG_TRACE in layout module"
default y
depends on LV_USE_LOG
config LV_LOG_TRACE_ANIM
bool "Enable/Disable LV_LOG_TRACE in anim module"
default y
depends on LV_USE_LOG
endmenu
menu "Asserts"
config LV_USE_ASSERT_NULL
bool "Check if the parameter is NULL. (Very fast, recommended)"
default y if !LV_CONF_MINIMAL
config LV_USE_ASSERT_MALLOC
bool "Checks if the memory is successfully allocated or no. (Very fast, recommended)"
default y if !LV_CONF_MINIMAL
config LV_USE_ASSERT_STYLE
bool "Check if the styles are properly initialized. (Very fast, recommended)"
config LV_USE_ASSERT_MEM_INTEGRITY
bool "Check the integrity of `lv_mem` after critical operations. (Slow)"
config LV_USE_ASSERT_OBJ
bool "Check NULL, the object's type and existence (e.g. not deleted). (Slow)."
config LV_ASSERT_HANDLER_INCLUDE
string "Header to include for the custom assert function"
default "assert.h"
endmenu
menu "Others"
config LV_USE_PERF_MONITOR
bool "Show CPU usage and FPS count in the right bottom corner."
config LV_USE_MEM_MONITOR
bool "Show the used memory and the memory fragmentation in the left bottom corner."
depends on !LV_MEM_CUSTOM
config LV_USE_REFR_DEBUG
bool "Draw random colored rectangles over the redrawn areas."
config LV_SPRINTF_CUSTOM
bool "Change the built-in (v)snprintf functions"
config LV_SPRINTF_INCLUDE
string "Header to include for the custom sprintf function"
depends on LV_SPRINTF_CUSTOM
default "stdio.h"
config LV_SPRINTF_USE_FLOAT
bool "Enable float in built-in (v)snprintf functions"
depends on !LV_SPRINTF_CUSTOM
config LV_USE_USER_DATA
bool "Add a 'user_data' to drivers and objects."
default y
config LV_ENABLE_GC
bool "Enable garbage collector"
config LV_GC_INCLUDE
string "Header to include for the garbage collector related things"
depends on LV_ENABLE_GC
default "gc.h"
endmenu
menu "Compiler settings"
config LV_BIG_ENDIAN_SYSTEM
bool "For big endian systems set to 1"
config LV_ATTRIBUTE_MEM_ALIGN_SIZE
int "Required alignment size for buffers"
default 1
config LV_ATTRIBUTE_FAST_MEM_USE_IRAM
bool "Set IRAM as LV_ATTRIBUTE_FAST_MEM"
help
Set this option to configure IRAM as LV_ATTRIBUTE_FAST_MEM
config LV_USE_LARGE_COORD
bool "Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t"
endmenu
endmenu
menu "Font usage"
menu "Enable built-in fonts"
config LV_FONT_MONTSERRAT_8
bool "Enable Montserrat 8"
config LV_FONT_MONTSERRAT_10
bool "Enable Montserrat 10"
config LV_FONT_MONTSERRAT_12
bool "Enable Montserrat 12"
config LV_FONT_MONTSERRAT_14
bool "Enable Montserrat 14"
default y if !LV_CONF_MINIMAL
config LV_FONT_MONTSERRAT_16
bool "Enable Montserrat 16"
config LV_FONT_MONTSERRAT_18
bool "Enable Montserrat 18"
config LV_FONT_MONTSERRAT_20
bool "Enable Montserrat 20"
config LV_FONT_MONTSERRAT_22
bool "Enable Montserrat 22"
config LV_FONT_MONTSERRAT_24
bool "Enable Montserrat 24"
config LV_FONT_MONTSERRAT_26
bool "Enable Montserrat 26"
config LV_FONT_MONTSERRAT_28
bool "Enable Montserrat 28"
config LV_FONT_MONTSERRAT_30
bool "Enable Montserrat 30"
config LV_FONT_MONTSERRAT_32
bool "Enable Montserrat 32"
config LV_FONT_MONTSERRAT_34
bool "Enable Montserrat 34"
config LV_FONT_MONTSERRAT_36
bool "Enable Montserrat 36"
config LV_FONT_MONTSERRAT_38
bool "Enable Montserrat 38"
config LV_FONT_MONTSERRAT_40
bool "Enable Montserrat 40"
config LV_FONT_MONTSERRAT_42
bool "Enable Montserrat 42"
config LV_FONT_MONTSERRAT_44
bool "Enable Montserrat 44"
config LV_FONT_MONTSERRAT_46
bool "Enable Montserrat 46"
config LV_FONT_MONTSERRAT_48
bool "Enable Montserrat 48"
config LV_FONT_MONTSERRAT_12_SUBPX
bool "Enable Montserrat 12 sub-pixel"
config LV_FONT_MONTSERRAT_28_COMPRESSED
bool "Enable Montserrat 28 compressed"
config LV_FONT_DEJAVU_16_PERSIAN_HEBREW
bool "Enable Dejavu 16 Persian, Hebrew, Arabic letters"
config LV_FONT_SIMSUN_16_CJK
bool "Enable Simsun 16 CJK"
config LV_FONT_UNSCII_8
bool "Enable UNSCII 8 (Perfect monospace font)"
default y if LV_CONF_MINIMAL
config LV_FONT_UNSCII_16
bool "Enable UNSCII 16 (Perfect monospace font)"
config LV_FONT_CUSTOM
bool "Enable the custom font"
config LV_FONT_CUSTOM_DECLARE
string "Header to include for the custom font"
depends on LV_FONT_CUSTOM
endmenu
choice LV_FONT_DEFAULT
prompt "Select theme default title font"
default LV_FONT_DEFAULT_MONTSERRAT_14 if !LV_CONF_MINIMAL
default LV_FONT_DEFAULT_UNSCII_8 if LV_CONF_MINIMAL
help
Select theme default title font
config LV_FONT_DEFAULT_MONTSERRAT_8
bool "Montserrat 8"
select LV_FONT_MONTSERRAT_8
config LV_FONT_DEFAULT_MONTSERRAT_12
bool "Montserrat 12"
select LV_FONT_MONTSERRAT_12
config LV_FONT_DEFAULT_MONTSERRAT_14
bool "Montserrat 14"
select LV_FONT_MONTSERRAT_14
config LV_FONT_DEFAULT_MONTSERRAT_16
bool "Montserrat 16"
select LV_FONT_MONTSERRAT_16
config LV_FONT_DEFAULT_MONTSERRAT_18
bool "Montserrat 18"
select LV_FONT_MONTSERRAT_18
config LV_FONT_DEFAULT_MONTSERRAT_20
bool "Montserrat 20"
select LV_FONT_MONTSERRAT_20
config LV_FONT_DEFAULT_MONTSERRAT_22
bool "Montserrat 22"
select LV_FONT_MONTSERRAT_22
config LV_FONT_DEFAULT_MONTSERRAT_24
bool "Montserrat 24"
select LV_FONT_MONTSERRAT_24
config LV_FONT_DEFAULT_MONTSERRAT_26
bool "Montserrat 26"
select LV_FONT_MONTSERRAT_26
config LV_FONT_DEFAULT_MONTSERRAT_28
bool "Montserrat 28"
select LV_FONT_MONTSERRAT_28
config LV_FONT_DEFAULT_MONTSERRAT_30
bool "Montserrat 30"
select LV_FONT_MONTSERRAT_30
config LV_FONT_DEFAULT_MONTSERRAT_32
bool "Montserrat 32"
select LV_FONT_MONTSERRAT_32
config LV_FONT_DEFAULT_MONTSERRAT_34
bool "Montserrat 34"
select LV_FONT_MONTSERRAT_34
config LV_FONT_DEFAULT_MONTSERRAT_36
bool "Montserrat 36"
select LV_FONT_MONTSERRAT_36
config LV_FONT_DEFAULT_MONTSERRAT_38
bool "Montserrat 38"
select LV_FONT_MONTSERRAT_38
config LV_FONT_DEFAULT_MONTSERRAT_40
bool "Montserrat 40"
select LV_FONT_MONTSERRAT_40
config LV_FONT_DEFAULT_MONTSERRAT_42
bool "Montserrat 42"
select LV_FONT_MONTSERRAT_42
config LV_FONT_DEFAULT_MONTSERRAT_44
bool "Montserrat 44"
select LV_FONT_MONTSERRAT_44
config LV_FONT_DEFAULT_MONTSERRAT_46
bool "Montserrat 46"
select LV_FONT_MONTSERRAT_46
config LV_FONT_DEFAULT_MONTSERRAT_48
bool "Montserrat 48"
select LV_FONT_MONTSERRAT_48
config LV_FONT_DEFAULT_MONTSERRAT_12_SUBPX
bool "Montserrat 12 sub-pixel"
select LV_FONT_MONTSERRAT_12_SUBPX
config LV_FONT_DEFAULT_MONTSERRAT_28_COMPRESSED
bool "Montserrat 28 compressed"
select LV_FONT_MONTSERRAT_28_COMPRESSED
config LV_FONT_DEFAULT_DEJAVU_16_PERSIAN_HEBREW
bool "Dejavu 16 Persian, Hebrew, Arabic letters"
select LV_FONT_DEJAVU_16_PERSIAN_HEBREW
config LV_FONT_DEFAULT_SIMSUN_16_CJK
bool "Simsun 16 CJK"
select LV_FONT_SIMSUN_16_CJK
config LV_FONT_DEFAULT_UNSCII_8
bool "UNSCII 8 (Perfect monospace font)"
select LV_FONT_UNSCII_8
config LV_FONT_DEFAULT_UNSCII_16
bool "UNSCII 16 (Perfect monospace font)"
select LV_FONT_UNSCII_16
endchoice
config LV_FONT_FMT_TXT_LARGE
bool "Enable it if you have fonts with a lot of characters."
help
The limit depends on the font size, font face and bpp
but with > 10,000 characters if you see issues probably you
need to enable it.
config LV_USE_FONT_COMPRESSED
bool "Sets support for compressed fonts."
config LV_USE_FONT_SUBPX
bool "Enable subpixel rendering."
config LV_FONT_SUBPX_BGR
bool "Use BGR instead RGB for sub-pixel rendering."
depends on LV_USE_FONT_SUBPX
help
Set the pixel order of the display.
Important only if "subpx fonts" are used.
With "normal" font it doesn't matter.
endmenu
menu "Text Settings"
choice LV_TXT_ENC
prompt "Select a character encoding for strings"
help
Select a character encoding for strings. Your IDE or editor should have the same character encoding.
default LV_TXT_ENC_UTF8 if !LV_CONF_MINIMAL
default LV_TXT_ENC_ASCII if LV_CONF_MINIMAL
config LV_TXT_ENC_UTF8
bool "UTF8"
config LV_TXT_ENC_ASCII
bool "ASCII"
endchoice
config LV_TXT_BREAK_CHARS
string "Can break (wrap) texts on these chars"
default " ,.;:-_"
config LV_TXT_LINE_BREAK_LONG_LEN
int "Line break long length"
default 0
help
If a word is at least this long, will break wherever 'prettiest'.
To disable, set to a value <= 0.
config LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN
int "Min num chars before break"
default 3
depends on LV_TXT_LINE_BREAK_LONG_LEN > 0
help
Minimum number of characters in a long word to put on a line before a break.
config LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN
int "Min num chars after break"
default 3
depends on LV_TXT_LINE_BREAK_LONG_LEN > 0
help
Minimum number of characters in a long word to put on a line after a break.
config LV_TXT_COLOR_CMD
string "The control character to use for signalling text recoloring"
default "#"
config LV_USE_BIDI
bool "Support bidirectional texts"
help
Allows mixing Left-to-Right and Right-to-Left texts.
The direction will be processed according to the Unicode Bidirectional Algorithm:
https://www.w3.org/International/articles/inline-bidi-markup/uba-basics
choice
prompt "Set the default BIDI direction"
default LV_BIDI_DIR_AUTO
depends on LV_USE_BIDI
config LV_BIDI_DIR_LTR
bool "Left-to-Right"
config LV_BIDI_DIR_RTL
bool "Right-to-Left"
config LV_BIDI_DIR_AUTO
bool "Detect texts base direction"
endchoice
config LV_USE_ARABIC_PERSIAN_CHARS
bool "Enable Arabic/Persian processing"
help
In these languages characters should be replaced with
an other form based on their position in the text.
endmenu
menu "Widget usage"
config LV_USE_ARC
bool "Arc."
default y if !LV_CONF_MINIMAL
config LV_USE_BAR
bool "Bar."
default y if !LV_CONF_MINIMAL
config LV_USE_BTN
bool "Button."
default y if !LV_CONF_MINIMAL
config LV_USE_BTNMATRIX
bool "Button matrix."
default y if !LV_CONF_MINIMAL
config LV_USE_CANVAS
bool "Canvas. Dependencies: lv_img."
default y if !LV_CONF_MINIMAL
config LV_USE_CHECKBOX
bool "Check Box"
default y if !LV_CONF_MINIMAL
config LV_USE_DROPDOWN
bool "Drop down list. Requires: lv_label."
select LV_USE_LABEL
default y if !LV_CONF_MINIMAL
config LV_USE_IMG
bool "Image. Requires: lv_label."
select LV_USE_LABEL
default y if !LV_CONF_MINIMAL
config LV_USE_LABEL
bool "Label."
default y if !LV_CONF_MINIMAL
config LV_LABEL_TEXT_SELECTION
bool "Enable selecting text of the label."
depends on LV_USE_LABEL
default y
config LV_LABEL_LONG_TXT_HINT
bool "Store extra some info in labels (12 bytes) to speed up drawing of very long texts."
depends on LV_USE_LABEL
default y
config LV_USE_LINE
bool "Line."
default y if !LV_CONF_MINIMAL
config LV_USE_ROLLER
bool "Roller. Requires: lv_label."
select LV_USE_LABEL
default y if !LV_CONF_MINIMAL
config LV_ROLLER_INF_PAGES
int "Number of extra 'pages' when the controller is infinite."
default 7
depends on LV_USE_ROLLER
config LV_USE_SLIDER
bool "Slider. Requires: lv_bar."
select LV_USE_BAR
default y if !LV_CONF_MINIMAL
config LV_USE_SWITCH
bool "Switch."
default y if !LV_CONF_MINIMAL
config LV_USE_TEXTAREA
bool "Text area. Requires: lv_label."
select LV_USE_LABEL
default y if !LV_CONF_MINIMAL
config LV_TEXTAREA_DEF_PWD_SHOW_TIME
int "Text area def. pwd show time [ms]."
default 1500
depends on LV_USE_TEXTAREA
config LV_USE_TABLE
bool "Table."
default y if !LV_CONF_MINIMAL
endmenu
menu "Extra Widgets"
config LV_USE_ANIMIMG
bool "Anim image."
default y if !LV_CONF_MINIMAL
config LV_USE_CALENDAR
bool "Calendar."
default y if !LV_CONF_MINIMAL
config LV_CALENDAR_WEEK_STARTS_MONDAY
bool "Calendar week starts monday."
depends on LV_USE_CALENDAR
config LV_USE_CALENDAR_HEADER_ARROW
bool "Use calendar header arrow"
depends on LV_USE_CALENDAR
default y
config LV_USE_CALENDAR_HEADER_DROPDOWN
bool "Use calendar header dropdown"
depends on LV_USE_CALENDAR
default y
config LV_USE_CHART
bool "Chart."
default y if !LV_CONF_MINIMAL
config LV_USE_COLORWHEEL
bool "Colorwheel."
default y if !LV_CONF_MINIMAL
config LV_USE_IMGBTN
bool "Imgbtn."
default y if !LV_CONF_MINIMAL
config LV_USE_KEYBOARD
bool "Keyboard."
default y if !LV_CONF_MINIMAL
config LV_USE_LED
bool "LED."
default y if !LV_CONF_MINIMAL
config LV_USE_LIST
bool "List."
default y if !LV_CONF_MINIMAL
config LV_USE_METER
bool "Meter."
default y if !LV_CONF_MINIMAL
config LV_USE_MSGBOX
bool "Msgbox."
default y if !LV_CONF_MINIMAL
config LV_USE_SPINBOX
bool "Spinbox."
default y if !LV_CONF_MINIMAL
config LV_USE_SPINNER
bool "Spinner."
default y if !LV_CONF_MINIMAL
config LV_USE_TABVIEW
bool "Tabview."
default y if !LV_CONF_MINIMAL
config LV_USE_TILEVIEW
bool "Tileview"
default y if !LV_CONF_MINIMAL
config LV_USE_WIN
bool "Win"
default y if !LV_CONF_MINIMAL
config LV_USE_SPAN
bool "span"
default y if !LV_CONF_MINIMAL
config LV_SPAN_SNIPPET_STACK_SIZE
int "Maximum number of span descriptor"
default 64
depends on LV_USE_SPAN
endmenu
menu "Themes"
config LV_USE_THEME_DEFAULT
bool "A simple, impressive and very complete theme"
default y if !LV_CONF_MINIMAL
config LV_THEME_DEFAULT_DARK
bool "Yes to set dark mode, No to set light mode"
depends on LV_USE_THEME_DEFAULT
config LV_THEME_DEFAULT_GROW
bool "Enable grow on press"
default y
depends on LV_USE_THEME_DEFAULT
config LV_THEME_DEFAULT_TRANSITION_TIME
int "Default transition time in [ms]"
default 80
depends on LV_USE_THEME_DEFAULT
config LV_USE_THEME_BASIC
bool "A very simple theme that is a good starting point for a custom theme"
default y if !LV_CONF_MINIMAL
endmenu
menu "Layouts"
config LV_USE_FLEX
bool "A layout similar to Flexbox in CSS."
default y if !LV_CONF_MINIMAL
config LV_USE_GRID
bool "A layout similar to Grid in CSS."
default y if !LV_CONF_MINIMAL
endmenu
menu "3rd Party Libraries"
config LV_USE_FS_STDIO
int "File system on top of stdio API"
default 0
config LV_FS_STDIO_PATH
string "Set the working directory"
depends on LV_USE_FS_STDIO
config LV_USE_FS_POSIX
int "File system on top of posix API"
default 0
config LV_FS_POSIX_PATH
string "Set the working directory"
depends on LV_USE_FS_POSIX
config LV_USE_FS_WIN32
int "File system on top of Win32 API"
default 0
config LV_FS_WIN32_PATH
string "Set the working directory"
depends on LV_USE_FS_WIN32
config LV_USE_FS_FATFS
int "File system on top of FatFS"
default 0
config LV_USE_PNG
bool "PNG decoder library"
config LV_USE_BMP
bool "BMP decoder library"
config LV_USE_SJPG
bool "JPG + split JPG decoder library"
config LV_USE_GIF
bool "GIF decoder library"
config LV_USE_QRCODE
bool "QR code library"
config LV_USE_FREETYPE
bool "FreeType library"
config LV_FREETYPE_CACHE_SIZE
int "Memory used by FreeType to cache characters [bytes] (-1: no caching)"
depends on LV_USE_FREETYPE
default 16384
config LV_USE_RLOTTIE
bool "Lottie library"
endmenu
menu "Others"
config LV_USE_SNAPSHOT
bool "Enable API to take snapshot"
default y if !LV_CONF_MINIMAL
endmenu
menu "Examples"
config LV_BUILD_EXAMPLES
bool "Enable the examples to be built"
default y if !LV_CONF_MINIMAL
endmenu
config LV_BUILD_EXAMPLES
bool "Enable the examples to be built with the library."
default y
endmenu
endif

View File

@ -0,0 +1,8 @@
MIT licence
Copyright (c) 2021 LVGL Kft
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,5 @@
LVGL_DIR := ..
LVGL_DIR_NAME = lvgl
SRC_FILES += $(VPATH)
include lvgl.mk
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,181 @@
<h1 align="center"> LVGL - Light and Versatile Graphics Library</h1>
<p align="center">
<img src="https://lvgl.io/assets/images/lvgl_widgets_demo.gif">
</p>
<p align="center">
LVGL provides everything you need to create an embedded GUI with easy-to-use graphical elements, beautiful visual effects and a low memory footprint.
</p>
<h4 align="center">
<a href="https://lvgl.io">Website </a> &middot;
<a href="https://docs.lvgl.io/">Docs</a> &middot;
<a href="https://forum.lvgl.io">Forum</a> &middot;
<a href="https://lvgl.io/services">Services</a> &middot;
<a href="https://docs.lvgl.io/master/examples.html">Interactive examples</a>
</h4>
---
#### Table of content
- [Overview](#overview)
- [Get started](#get-started)
- [Examples](#examples)
- [Services](#services)
- [Contributing](#contributing)
## Overview
### Features
* Powerful [building blocks](https://docs.lvgl.io/master/widgets/index.html): buttons, charts, lists, sliders, images, etc.
* Advanced graphics engine: animations, anti-aliasing, opacity, smooth scrolling, blending modes, etc
* Supports [various input devices](https://docs.lvgl.io/master/overview/indev.html): touchscreen, mouse, keyboard, encoder, buttons, etc.
* Supports [multiple displays](https://docs.lvgl.io/master/overview/display.html)
* Hardware independent, can be use with any microcontroller and display
* Scalable to operate with little memory (64 kB Flash, 16 kB RAM)
* Multi-language support with UTF-8 handling, CJK, Bidirectional and Arabic script support
* Fully customizable graphical elements via [CSS-like styles](https://docs.lvgl.io/master/overview/style.html)
* Powerful layouts inspired by CSS: [Flexbox](https://docs.lvgl.io/master/layouts/flex.html) and [Grid](https://docs.lvgl.io/master/layouts/grid.html)
* OS, External memory and GPU are supported but not required. (built in support for STM32 DMA2D, and NXP PXP and VGLite)
* Smooth rendering even with a [single frame buffer](https://docs.lvgl.io/master/porting/display.html)
* Written in C and compatibile with C++
* Micropython Binding exposes [LVGL API in Micropython](https://blog.lvgl.io/2019-02-20/micropython-bindings)
* [Simulator](https://docs.lvgl.io/master/get-started/pc-simulator.html) to develop on PC without embedded hardware
* 100+ simple [Examples](https://github.com/lvgl/lvgl/tree/master/examples)
* [Documentation](http://docs.lvgl.io/) and API references online and in PDF
### Requirements
Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are:
<table>
<tr>
<td> <strong>Name</strong> </td>
<td><strong>Minimal</strong></td>
<td><strong>Recommended</strong></td>
</tr>
<tr>
<td><strong>Architecture</strong></td>
<td colspan="2">16, 32 or 64 bit microcontroller or processor</td>
</tr>
<tr>
<td> <strong>Clock</strong></td>
<td> &gt; 16 MHz </td>
<td> &gt; 48 MHz</td>
</tr>
<tr>
<td> <strong>Flash/ROM</strong></td>
<td> &gt; 64 kB </td>
<td> &gt; 180 kB</td>
</tr>
<tr>
<td> <strong>Static RAM</strong></td>
<td> &gt; 16 kB </td>
<td> &gt; 48 kB</td>
</tr>
<tr>
<td> <strong>Draw buffer</strong></td>
<td> &gt; 1 &times; <em>hor. res.</em> pixels </td>
<td> &gt; 1/10 screen size </td>
</tr>
<tr>
<td> <strong>Compiler</strong></td>
<td colspan="2"> C99 or newer </td>
</tr>
</table>
*Note that the memory usage might vary depending on the architecture, compiler and build options.*
### Supported platforms
LVGL is completely platform independent and can be used with any MCU that fulfills the requirements.
Just to mention some platforms:
- NXP: Kinetis, LPC, iMX, iMX RT
- STM32F1, STM32F3, STM32F4, STM32F7, STM32L4, STM32L5, STM32H7
- Microchip dsPIC33, PIC24, PIC32MX, PIC32MZ
- [Linux frame buffer](https://blog.lvgl.io/2018-01-03/linux_fb) (/dev/fb)
- [Raspberry Pi](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl)
- [Espressif ESP32](https://github.com/lvgl/lv_port_esp32)
- [Infineon Aurix](https://github.com/lvgl/lv_port_aurix)
- Nordic NRF52 Bluetooth modules
- Quectel modems
LVGL is also avaiable as:
- [Arduino library](https://docs.lvgl.io/master/get-started/arduino.html)
- [PlatformIO package](https://platformio.org/lib/show/12440/lvgl)
- [Zephyr library](https://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_LVGL.html)
- [ESP32 component](https://docs.lvgl.io/master/get-started/espressif.html)
- [NXP MCUXpresso component](https://www.nxp.com/design/software/embedded-software/lvgl-open-source-graphics-library:LITTLEVGL-OPEN-SOURCE-GRAPHICS-LIBRARY)
- [NuttX library](https://docs.lvgl.io/master/get-started/nuttx.html)
## Get started
This list shows the recommended way of learning the library:
1. Check the [Online demos](https://lvgl.io/demos) to see LVGL in action (3 minutes)
2. Read the [Introduction](https://docs.lvgl.io/master/intro/index.html) page of the documentation (5 minutes)
3. Get familiar with the basics on the [Quick overview](https://docs.lvgl.io/master/get-started/quick-overview.html) page (15 minutes)
4. Set up a [Simulator](https://docs.lvgl.io/master/get-started/pc-simulator.html) (10 minutes)
5. Try out some [Examples](https://github.com/lvgl/lvgl/tree/master/examples)
6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/master/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_)
7. Read the [Overview](https://docs.lvgl.io/master/overview/index.html) page to get a better understanding of the library (2-3 hours)
8. Check the documentation of the [Widgets](https://docs.lvgl.io/master/widgets/index.html) to see their features and usage
9. If you have questions go to the [Forum](http://forum.lvgl.io/)
10. Read the [Contributing](https://docs.lvgl.io/master/CONTRIBUTING.html) guide to see how you can help to improve LVGL (15 minutes)
## Examples
For more examples see the [examples](https://github.com/lvgl/lvgl/tree/master/examples) folder.
![LVGL button with label example](https://github.com/lvgl/lvgl/raw/master/docs/misc/btn_example.png)
### C
```c
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button to the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 100, 50); /*Set its size*/
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL); /*Assign a callback to the button*/
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/
lv_obj_center(label); /*Align the label to the center*/
...
void btn_event_cb(lv_event_t * e)
{
printf("Clicked\n");
}
```
### Micropython
Learn more about [Micropython](https://docs.lvgl.io/master/get-started/micropython.html).
```python
def btn_event_cb(e):
print("Clicked")
# Create a Button and a Label
btn = lv.btn(lv.scr_act())
btn.set_pos(10, 10)
btn.set_size(100, 50)
btn.add_event_cb(btn_event_cb, lv.EVENT.CLICKED, None)
label = lv.label(btn)
label.set_text("Button")
label.center()
```
## Services
LVGL Kft was established to provide a solid background for LVGL library. We offer several type of services to help you in UI development:
- Graphics design
- UI implementation
- Consulting/Support
For more information see https://lvgl.io/services
Feel free to contact us if you have any questions.
## Contributing
LVGL is an open project and contribution is very welcome. There are many ways to contribute from simply speaking about your project, through writing examples, improving the documentation, fixing bugs to hosting your own project under the LVGL organization.
For a detailed description of contribution opportunities visit the [Contributing](https://docs.lvgl.io/master/CONTRIBUTING.html) section of the documentation.

View File

@ -0,0 +1,11 @@
# RT-Thread building script for bridge
import os
from building import *
objs = []
cwd = GetCurrentDir()
objs = objs + SConscript(cwd + '/rt-thread/SConscript')
Return('objs')

View File

@ -0,0 +1,34 @@
# ESP-IDF component file for make based commands
COMPONENT_SRCDIRS := . \
src \
src/core \
src/draw \
src/extra \
src/font \
src/gpu \
src/hal \
src/misc \
src/widgets \
src/extra/layouts \
src/extra/layouts/flex \
src/extra/layouts/grid \
src/extra/themes \
src/extra/themes/basic \
src/extra/themes/default \
src/extra/widgets/calendar \
src/extra/widgets/colorwheel \
src/extra/widgets \
src/extra/widgets/imgbtn \
src/extra/widgets/keyboard \
src/extra/widgets/led \
src/extra/widgets/list \
src/extra/widgets/msgbox \
src/extra/widgets/spinbox \
src/extra/widgets/spinner \
src/extra/widgets/tabview \
src/extra/widgets/tileview \
src/extra/widgets/win
COMPONENT_ADD_INCLUDEDIRS := $(COMPONENT_SRCDIRS) .

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team using the [contact form](https://lvgl.io/about). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@ -0,0 +1,89 @@
# Coding style
## File format
Use [misc/lv_templ.c](https://github.com/lvgl/lvgl/blob/master/src/misc/lv_templ.c) and [misc/lv_templ.h](https://github.com/lvgl/lvgl/blob/master/src/misc/lv_templ.h)
## Naming conventions
* Words are separated by '_'
* In variable and function names use only lower case letters (e.g. *height_tmp*)
* In enums and defines use only upper case letters (e.g. *e.g. MAX_LINE_NUM*)
* Global names (API):
* start with *lv*
* followed by module name: *btn*, *label*, *style* etc.
* followed by the action (for functions): *set*, *get*, *refr* etc.
* closed with the subject: *name*, *size*, *state* etc.
* Typedefs
* prefer `typedef struct` and `typedef enum` instead of `struct name` and `enum name`
* always end `typedef struct` and `typedef enum` type names with `_t`
* Abbreviations:
* Only words longer or equal than 6 characters can be abbreviated.
* Abbreviate only if it makes the word at least half as long
* Use only very straightforward and well-known abbreviations (e.g. pos: position, def: default, btn: button)
## Coding guide
* Functions:
* Try to write function shorter than is 50 lines
* Always shorter than 200 lines (except very straightforwards)
* Variables:
* One line, one declaration (BAD: char x, y;)
* Use `<stdint.h>` (*uint8_t*, *int32_t* etc)
* Declare variables where needed (not all at function start)
* Use the smallest required scope
* Variables in a file (outside functions) are always *static*
* Do not use global variables (use functions to set/get static variables)
## Comments
Before every function have a comment like this:
```c
/**
* Return with the screen of an object
* @param obj pointer to an object
* @return pointer to a screen
*/
lv_obj_t * lv_obj_get_scr(lv_obj_t * obj);
```
Always use `/*Something*/` format and NOT `//Something`
Write readable code to avoid descriptive comments like:
`x++; /*Add 1 to x*/`.
The code should show clearly what you are doing.
You should write **why** have you done this:
`x++; /*Because of closing '\0' of the string*/`
Short "code summaries" of a few lines are accepted. E.g. `/*Calculate the new coordinates*/`
In comments use \` \` when referring to a variable. E.g. ``/*Update the value of `x_act`*/``
### Formatting
Here is example to show bracket placing and using of white spaces:
```c
/**
* Set a new text for a label. Memory will be allocated to store the text by the label.
* @param label pointer to a label object
* @param text '\0' terminated character string. NULL to refresh with the current text.
*/
void lv_label_set_text(lv_obj_t * label, const char * text)
{ /*Main brackets of functions in new line*/
if(label == NULL) return; /*No bracket only if the command is inline with the if statement*/
lv_obj_inv(label);
lv_label_ext_t * ext = lv_obj_get_ext(label);
/*Comment before a section*/
if(text == ext->txt || text == NULL) { /*Bracket of statements start inline*/
lv_label_refr_text(label);
return;
}
...
}
```
Use 4 spaces indentation instead of tab.
You can use **astyle** to format the code. Run `code-formatter.sh` from the `scrips` folder.

View File

@ -0,0 +1,266 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/CONTRIBUTING.md
```
# Contributing
## Introduction
Join LVGL's community and leave your footprint in the library!
There are a lot of ways to contribute to LVGL even if you are new to the library or even new to programming.
It might be scary to make the first step but you have nothing to be afraid of.
A friendly and helpful community is waiting for you. Get to know like-minded people and make something great together.
So let's find which contribution option fits you the best and help you join the development of LVGL!
Before getting started here are some guidelines to make contribution smoother:
- Be kind and friendly.
- Be sure to read the relevant part of the documentation before posting a question.
- Ask questions in the [Forum](https://forum.lvgl.io/) and use [GitHub](https://github.com/lvgl/) for development-related discussions.
- Always fill out the post or issue templates in the Forum or GitHub (or at least provide equivalent information). It makes understanding your contribution or issue easier and you will get a useful response faster.
- If possible send an absolute minimal but buildable code example in order to reproduce the issue. Be sure it contains all the required variable declarations, constants, and assets (images, fonts).
- Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to format your posts. You can learn it in 10 minutes.
- Speak about one thing in one issue or topic. It makes your post easier to find later for someone with the same question.
- Give feedback and close the issue or mark the topic as solved if your question is answered.
- For non-trivial fixes and features, it's better to open an issue first to discuss the details instead of sending a pull request directly.
- Please read and follow the <a href="https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md">Coding style</a> guide.
## Pull request
Merging new code into the lvgl, documentation, blog, examples, and other repositories happen via *Pull requests* (PR for short).
A PR is a notification like "Hey, I made some updates to your project. Here are the changes, you can add them if you want."
To do this you need a copy (called fork) of the original project under your account, make some changes there, and notify the original repository about your updates.
You can see what it looks like on GitHub for LVGL here: [https://github.com/lvgl/lvgl/pulls](https://github.com/lvgl/lvgl/pulls).
To add your changes you can edit files online on GitHub and send a new Pull request from there (recommended for small changes) or
add the updates in your favorite editor/IDE and use git to publish the changes (recommended for more complex updates).
### From GitHub
1. Navigate to the file you want to edit.
2. Click the Edit button in the top right-hand corner.
3. Add your changes to the file.
4. Add a commit message on the bottom of the page.
5. Click the *Propose changes* button.
### From command line
The instructions describe the main `lvgl` repository but it works the same way for the other repositories.
1. Fork the [lvgl repository](https://github.com/lvgl/lvgl). To do this click the "Fork" button in the top right corner.
It will "copy" the `lvgl` repository to your GitHub account (`https://github.com/<YOUR_NAME>?tab=repositories`)
2. Clone your forked repository.
3. Add your changes. You can create a *feature branch* from *master* for the updates: `git checkout -b the-new-feature`
4. Commit and push your changes to the forked `lvgl` repository.
5. Create a PR on GitHub from the page of your `lvgl` repository (`https://github.com/<YOUR_NAME>/lvgl`) by clicking the *"New pull request"* button. Don't forget to select the branch where you added your changes.
7. Set the base branch. It means where you want to merge your update. In the `lvgl` repo fixes go to `master`, new features to `dev` branch.
8. Describe what is in the update. An example code is welcome if applicable.
9. If you need to make more changes, just update your forked `lvgl` repo with new commits. They will automatically appear in the PR.
### Commit message format
In commit messages please follow the [Angular Commit Format](https://gist.github.com/brianclements/841ea7bffdb01346392c).
Some examples:
```
fix(img) update size if a new source is set
```
```
fix(bar) fix memory leak
The animations weren't deleted in the destructor.
Fixes: #1234
```
```
feat add span widget
The span widget allows mixing different font sizes, colors and styles.
It's similar to HTML <span>
```
```
docs(porting) fix typo
```
## Developer Certification of Origin (DCO)
### Overview
To ensure all licensing criteria are met for every repository of the LVGL project, we apply a process called DCO (Developer's Certificate of Origin).
The text of DCO can be read here: [https://developercertificate.org/](https://developercertificate.org/).
By contributing to any repositories of the LVGL project you agree that your contribution complies with the DCO.
If your contribution fulfills the requirements of the DCO no further action is needed. If you are unsure feel free to ask us in a comment.
### Accepted licenses and copyright notices
To make the DCO easier to digest, here are some practical guides about specific cases:
#### Your own work
The simplest case is when the contribution is solely your own work.
In this case you can just send a Pull Request without worrying about any licensing issues.
#### Use code from online source
If the code you would like to add is based on an article, post or comment on a website (e.g. StackOverflow) the license and/or rules of that site should be followed.
For example in case of StackOwerflow a notice like this can be used:
```
/* The original version of this code-snippet was published on StackOverflow.
* Post: http://stackoverflow.com/questions/12345
* Author: http://stackoverflow.com/users/12345/username
* The following parts of the snippet were changed:
* - Check this or that
* - Optimize performance here and there
*/
... code snippet here ...
```
#### Use MIT licensed code
As LVGL is MIT licensed, other MIT licensed code can be integrated without issues.
The MIT license requires a copyright notice be added to the derived work. Any derivative work based on MIT licensed code must copy the original work's license file or text.
#### Use GPL licensed code
The GPL license is not compatible with the MIT license. Therefore, LVGL can not accept GPL licensed code.
## Ways to contribute
Even if you're just getting started with LVGL there are plenty of ways to get your feet wet.
Most of these options don't even require knowing a single line of LVGL code.
Below we have collected some opportunities about the ways you can contribute to LVGL.
### Give LVGL a Star
Show that you like LVGL by giving it star on GitHub!
<!-- Place this tag in your head or just before your close body tag. -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
<!-- Place this tag where you want the button to render. -->
<a class="github-button" href="https://github.com/lvgl/lvgl" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star lvgl/lvgl on GitHub">Star</a>
This simple click makes LVGL more visible on GitHub and makes it more attractive to other people.
So with this, you already helped a lot!
### Tell what you have achieved
Have you already started using LVGL in a [Simulator](/get-started/pc-simulator), a development board, or on your custom hardware?
Was it easy or were there some obstacles? Are you happy with the result?
Showing your project to others is a win-win situation because it increases your and LVGL's reputation at the same time.
You can post about your project on Twitter, Facebook, LinkedIn, create a YouTube video, and so on.
Only one thing: On social media don't forget to add a link to `https://lvgl.io` or `https://github.com/lvgl` and use the hashtag `#lvgl`. Thank you! :)
You can also open a new topic in the [My projects](https://forum.lvgl.io/c/my-projects/10) category of the Forum.
The [LVGL Blog](https://blog.lvgl.io) welcomes posts from anyone.
It's a good place to talk about a project you created with LVGL, write a tutorial, or share some nice tricks.
The latest blog posts are shown on the [homepage of LVGL](https://lvgl.io) to make your work more visible.
The blog is hosted on GitHub. If you add a post GitHub automatically turns it into a website.
See the [README](https://github.com/lvgl/blog) of the blog repo to see how to add your post.
Any of these help to spread the word and familiarize new developers with LVGL.
If you don't want to speak about your project publicly, feel free to use [Contact form](https://lvgl.io/#contact) on lvgl.io to private message to us.
### Write examples
As you learn LVGL you will probably play with the features of widgets. Why not publish your experiments?
Each widgets' documentation contains examples. For instance, here are the examples of the [Drop-down list](/widgets/core/dropdown#examples) widget.
The examples are directly loaded from the [lvgl/examples](https://github.com/lvgl/lvgl/tree/master/examples) folder.
So all you need to do is send a [Pull request](#pull-request) to the [lvgl](https://github.com/lvgl/lvgl) repository and follow some conventions:
- Name the examples like `lv_example_<widget_name>_<index>`.
- Make the example as short and simple as possible.
- Add comments to explain what the example does.
- Use 320x240 resolution.
- Update `index.rst` in the example's folder with your new example. To see how other examples are added, look in the [lvgl/examples/widgets](https://github.com/lvgl/lvgl/tree/master/examples/widgets) folder.
### Improve the docs
As you read the documentation you might see some typos or unclear sentences. All the documentation is located in the [lvgl/docs](https://github.com/lvgl/lvgl/tree/master/docs) folder.
For typos and straightforward fixes, you can simply edit the file on GitHub.
Note that the documentation is also formatted in [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet).
### Report bugs
As you use LVGL you might find bugs. Before reporting them be sure to check the relevant parts of the documentation.
If it really seems like a bug feel free to open an [issue on GitHub](https://github.com/lvgl/lvgl/issues).
When filing the issue be sure to fill out the template. It helps find the root of the problem while avoiding extensive questions and exchanges with other developers.
### Send fixes
The beauty of open-source software is you can easily dig in to it to understand how it works. You can also fix or adjust it as you wish.
If you found and fixed a bug don't hesitate to send a [Pull request](#pull-request) with the fix.
In your Pull request please also add a line to [`CHANGELOG.md`](https://github.com/lvgl/lvgl/blob/master/CHANGELOG.md).
### Join the conversations in the Forum
It feels great to know you are not alone if something is not working. It's even better to help others when they struggle with something.
While you were learning LVGL you might have had questions and used the Forum to get answers. As a result, you probably have more knowledge about how LVGL works.
One of the best ways to give back is to use the Forum and answer the questions of newcomers - like you were once.
Just read the titles and if you are familiar with the topic don't hesitate to share your thoughts and suggestions.
Participating in the discussions is one of the best ways to become part of the project and get to know like-minded people!
### Add features
If you have created a cool widget, or added useful feature to LVGL feel free to open a new PR for it.
We collect the optional features (a.k.a. plugins) in [lvgl/src/extra](https://github.com/lvgl/lvgl/tree/master/src/extra) folder so if you are interested in adding a new features please use this folder.
The [README](https://github.com/lvgl/lvgl/blob/master/src/extra/README.md) file describes the basics rules of contribution and also lists some ideas.
For further ideas take a look at the [Roadmap](/ROADMAP) page. If you are interested in any of them feel free to share your opinion and/or participate in the implementation.
Other features which are (still) not on the road map are listed in the [Feature request](https://forum.lvgl.io/c/feature-request/9) category of the Forum.
When adding a new features the followings also needs to be updated:
- Update [lv_conf_template.h](https://github.com/lvgl/lvgl/blob/master/lv_conf_template.h)
- Add description in the [docs](https://github.com/lvgl/lvgl/tree/master/docs)
- Add [examples](https://github.com/lvgl/lvgl/tree/master/examples)
- Update the [changelog](https://github.com/lvgl/lvgl/tree/master/docs/CHANGELOG.md)
### Become a maintainer
If you want to become part of the core development team, you can become a maintainer of a repository.
By becoming a maintainer:
- You get write access to that repo:
- Add code directly without sending a pull request
- Accept pull requests
- Close/reopen/edit issues
- Your input has higher impact when we are making decisions
You can become a maintainer by invitation, however the following conditions need to met
1. Have > 50 replies in the Forum. You can look at your stats [here](https://forum.lvgl.io/u?period=all)
2. Send > 5 non-trivial pull requests to the repo where you would like to be a maintainer
If you are interested, just send a message (e.g. from the Forum) to the current maintainers of the repository. They will check if the prerequisites are met.
Note that meeting the prerequisites is not a guarantee of acceptance, i.e. if the conditions are met you won't automatically become a maintainer.
It's up to the current maintainers to make the decision.
### Move your project repository under LVGL organization
Besides the core `lvgl` repository there are other repos for ports to development boards, IDEs or other environment.
If you ported LVGL to a new platform we can host it under the LVGL organization among the other repos.
This way your project will become part of the whole LVGL project and can get more visibility.
If you are interested in this opportunity just open an [issue in lvgl repo](https://github.com/lvgl/lvgl/issues) and tell what you have!
If we agree that your port fit well into the LVGL organization, we will open a repository for your project where you will have admin rights.
To make this concept sustainable there a few rules to follow:
- You need to add a README to your repo.
- We expect to maintain the repo to some extent:
- Follow at least the major versions of LVGL
- Respond to the issues (in a reasonable time)
- If there is no activity in a repo for 1 year it will be archived

View File

@ -0,0 +1,82 @@
# Roadmap
This is a summary for planned new features and a collection of ideas.
This list indicates only the current intention and it can be changed.
## v8.1
### Features
- [x] Unit testing (gtest?). See #1658
- [ ] Benchmarking (gem5 or qemu?). See #1660
- [ ] lv_snapshot: buffer a widget and all of its children into an image. The source widget can be on a different screen too. The resulting image can be transformed.
- [ ] High level GPU support. See #2058
#### New features
- [x] merge MicroPython examples
- [x] add a "Try out yourself" button to the Micropython examples
### Discuss
- [ ] CPP binding
- [ ] Plugins. In v8 core and extra widgets are separated. With the new flexible events, the behavior of the widgets can be modified in a modular way. E.g. a plugin to add faded area to a line chart (as in the widgets demo)
### Docs
- [x] Display the Micropytohn examples too.
- [x] Add a link to the example C and py files
- [x] List of all examples on a page. All in iframes grouped by category (e.g. flex, style, button)
### Others
- [ ] Add automatic rebuild to get binary directly. Similarly to [STM32F746 project](https://github.com/lvgl/lv_port_stm32f746_disco#try-it-with-just-a-few-clicks).
- [ ] Implement release scripts. I've added a basic specification [here](https://github.com/lvgl/lvgl/tree/master/scripts/release), but we should discuss it.
- [ ] Unit test for the core widgets
## v8.2
- [ ] Optimize line and circle drawing and masking
- [ ] Handle stride. See [#1858](https://github.com/lvgl/lvgl/issues/1858)
- [ ] Support LV_STATE_HOVERED
## Ideas
- Reconsider color format management for run time color format setting, and custom color format usage. (Also [RGB888](https://github.com/lvgl/lvgl/issues/1722))
- Make gradients more versatile
- Make image transformations more versatile
- Switch to RGBA colors in styles
- Consider direct binary font format support
- Simplify `group`s. Discussion is [here](https://forum.lvgl.io/t/lv-group-tabindex/2927/3).
- Use [generate-changelog](https://github.com/lob/generate-changelog) to automatically generate changelog
- lv_mem_alloc_aligned(size, align)
- Text node. See [#1701](https://github.com/lvgl/lvgl/issues/1701#issuecomment-699479408)
- CPP binding. See [Forum](https://forum.lvgl.io/t/is-it-possible-to-officially-support-optional-cpp-api/2736)
- Optimize font decompression
- Need coverage report for tests
- Need static analyze (via coverity.io or somehing else)
- Support dot_begin and dot_middle long modes for labels
- Add new label alignment modes. [#1656](https://github.com/lvgl/lvgl/issues/1656)
- Support larger images: [#1892](https://github.com/lvgl/lvgl/issues/1892)
---
## v8
- Create an `extra` folder for complex widgets
- It makes the core LVGL leaner
- In `extra` we can have a lot and specific widgets
- Good place for contributions
- New scrolling:
- See [feat/new-scroll](https://github.com/lvgl/lvgl/tree/feat/new-scroll) branch and [#1614](https://github.com/lvgl/lvgl/issues/1614)) issue.
- Remove `lv_page` and support scrolling on `lv_obj`
- Support "elastic" scrolling when scrolled in
- Support scroll chaining among any objects types (not only `lv_pages`s)
- Remove `lv_drag`. Similar effect can be achieved by setting the position in `LV_EVENT_PRESSING`
- Add snapping
- Add snap stop to scroll max 1 snap point
- Already working
- New layouts:
- See [#1615](https://github.com/lvgl/lvgl/issues/1615) issue
- [CSS Grid](https://css-tricks.com/snippets/css/a-guide-to-grid/)-like layout support
- [CSS Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)-like layout support
- Remove `lv_cont` and support layouts on `lv_obj`
- Simplified File system interface ([feat/new_fs_api](https://github.com/lvgl/lvgl/tree/feat/new-fs-api) branch) to make porting easier
- Work in progress
- Remove the align parameter from `lv_canvas_draw_text`
- Remove the copy parameter from create functions
- Optimize and simplify styles [#1832](https://github.com/lvgl/lvgl/issues/1832)
- Use a more generic inheritance [#1919](https://github.com/lvgl/lvgl/issues/1919)
- Allow adding multiple events to an object

View File

@ -0,0 +1,98 @@
import os
from docutils import nodes
from docutils.parsers.rst import Directive, directives
from docutils.parsers.rst.directives.images import Image
from sphinx.directives.code import LiteralInclude
def excluded_list(argument):
return argument.split(',')
class LvExample(Directive):
required_arguments = 1
option_spec = {
'excluded_languages': excluded_list,
'language': directives.unchanged,
'description': directives.unchanged
}
def get_example_code_path(self, example_path, language):
return os.path.abspath("../examples/" + example_path + "." + language)
def human_language_name(self, language):
if language == 'py':
return 'MicroPython'
elif language == 'c':
return 'C'
else:
return language
def github_path(self, example_path, language):
env = self.state.document.settings.env
return f"https://github.com/lvgl/lvgl/blob/{env.config.repo_commit_hash}/examples/{example_path}.{language}"
def embed_code(self, example_file, example_path, language, buttons={}):
toggle = nodes.container('', literal_block=False, classes=['toggle'])
header = nodes.container('', literal_block=False, classes=['header'])
toggle.append(header)
try:
with open(example_file) as f:
contents = f.read()
except FileNotFoundError:
contents = 'Error encountered while trying to open ' + example_file
literal_list = nodes.literal_block(contents, contents)
literal_list['language'] = language
toggle.append(literal_list)
paragraph_node = nodes.raw(text=f"<p>{self.human_language_name(language)} code &nbsp;</p>", format='html')
for text, url in buttons.items():
paragraph_node.append(nodes.raw(text=f"<a class='lv-example-link-button' onclick=\"event.stopPropagation();\" href='{url}'>{text}</a>", format='html'))
header.append(paragraph_node)
return toggle
def run(self):
example_path = self.arguments[0]
example_name = os.path.split(example_path)[1]
excluded_languages = self.options.get('excluded_languages', [])
node_list = []
env = self.state.document.settings.env
iframe_html = ""
c_path = self.get_example_code_path(example_path, 'c')
py_path = self.get_example_code_path(example_path, 'py')
c_code = self.embed_code(c_path, example_path, 'c', buttons={
'<i class="fa fa-github"></i>&nbsp;GitHub': self.github_path(example_path, 'c')
})
py_code = self.embed_code(py_path, example_path, 'py', buttons={
'<i class="fa fa-github"></i>&nbsp;GitHub': self.github_path(example_path, 'py'),
'<i class="fa fa-play"></i>&nbsp;Simulator': f"https://sim.lvgl.io/v{env.config.version}/micropython/ports/javascript/index.html?script_startup=https://raw.githubusercontent.com/lvgl/lvgl/{env.config.repo_commit_hash}/examples/header.py&script=https://raw.githubusercontent.com/lvgl/lvgl/{env.config.repo_commit_hash}/examples/{example_path}.py"
})
if not 'c' in excluded_languages:
if env.app.tags.has('html'):
iframe_html = f"<div class='lv-example' data-real-src='/{env.config.version}/_static/built_lv_examples?example={example_name}&w=320&h=240'></div>"
description_html = f"<div class='lv-example-description'>{self.options.get('description', '')}</div>"
layout_node = nodes.raw(text=f"<div class='lv-example-container'>{iframe_html}{description_html}</div>", format='html')
node_list.append(layout_node)
if not 'c' in excluded_languages:
node_list.append(c_code)
if not 'py' in excluded_languages:
node_list.append(py_code)
trailing_node = nodes.raw(text=f"<hr/>", format='html')
node_list.append(trailing_node)
return node_list
def setup(app):
app.add_directive("lv_example", LvExample)
app.add_config_value("repo_commit_hash", "", "env")
return {
'version': '0.1',
'parallel_read_safe': True,
'parallel_write_safe': True,
}

View File

@ -0,0 +1,108 @@
table, th, td {
border: 1px solid #bbb;
padding: 10px;
}
td {
text-align:center;
}
span.pre
{
padding-right:8px;
}
span.pre:first-child
{
padding-right:0px;
}
code.sig-name
{
/*margin-left:8px;*/
}
.toggle .header {
display: block;
clear: both;
cursor: pointer;
font-weight: bold;
}
.toggle .header:before {
font-family: FontAwesome, "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;
content: "\f0da \00a0 Show ";
display: inline-block;
font-size: 1.1em;
}
.toggle .header.open:before {
content: "\f0d7 \00a0 Hide ";
}
.header p {
display: inline-block;
font-size: 1.1em;
margin-bottom: 8px;
}
.wy-side-nav-search {
background-color: #f5f5f5;
}
.wy-side-nav-search>div.version {
color: #333;
display: none; /*replaced by dropdown*/
}
.home-img {
width:32%;
transition: transform .3s ease-out;
}
.home-img:hover {
transform: translate(0, -10px);
}
.lv-example, .lv-example > iframe {
border: none;
outline: none;
padding: none;
display: block;
width: 320px;
height: 240px;
flex: none;
position: relative;
}
.lv-example > iframe {
position: absolute;
top: 0;
left: 0;
}
.lv-example-container {
display: flex;
padding-bottom: 16px;
}
.lv-example-description {
flex: 1 1 auto;
margin-left: 1rem;
}
.lv-example-link-button {
display: inline-block;
padding: 4px 8px;
border-radius: 4px;
background-color: #2980b9;
color: white;
margin: 0 4px;
}
.lv-example-link-button:hover {
color: white;
filter: brightness(120%);
}
.lv-example-link-button:visited {
color: white;
}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

View File

@ -0,0 +1,31 @@
{% extends "!layout.html" %}
{%- block extrahead %}
{{ super() }}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-78811084-3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-78811084-3', { 'anonymize_ip': true });
</script>
{% endblock %}
{% block footer %}
{{ super() }}
<div class="footer">This page uses <a href="https://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ?
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();
</script>
</div>
{% endblock %}

View File

@ -0,0 +1,82 @@
{% extends "!page.html" %}
{% block footer %}
<style>
.wy-side-nav-search > div[role="search"] {
color: black;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$(".toggle > *").hide();
$(".toggle .header").show();
$(".toggle .header").click(function() {
$(this).parent().children().not(".header").toggle(400);
$(this).parent().children(".header").toggleClass("open");
})
});
</script>
<script type="text/javascript">
function add_version_selector()
{
return fetch("https://raw.githubusercontent.com/lvgl/docs_compiled/gh-pages/versionlist.txt")
.then(res => res.text())
.then(text => {
const versions = text.split("\n").filter(version => version.trim().length > 0);
let p = document.getElementById("rtd-search-form").parentElement;
p.innerHTML = `
<select name="versions" id="versions" onchange="ver_sel()" style="border-radius:5px; margin-bottom:15px">
${versions.map(version => {
let versionName = "";
if(version == "master") versionName = "master (latest)";
else versionName = "v" + ((version.indexOf(".") != -1) ? version : (version + " (latest minor)"));
return `<option value="${version}">${versionName}</option>`;
})}
</select>` + p.innerHTML;
});
}
function ver_sel()
{
var x = document.getElementById("versions").value;
window.location.href = window.location.protocol + "//" + window.location.host + "/" + x + "/";
}
document.addEventListener('DOMContentLoaded', (event) => {
add_version_selector().then(() => {
var value = window.location.pathname.split('/')[1];
document.getElementById("versions").value = value;
});
})
document.addEventListener('DOMContentLoaded', (event) => {
function onIntersection(entries) {
entries.forEach(entry => {
let currentlyLoaded = entry.target.getAttribute("data-is-loaded") == "true";
let shouldBeLoaded = entry.intersectionRatio > 0;
if(currentlyLoaded != shouldBeLoaded) {
entry.target.setAttribute("data-is-loaded", shouldBeLoaded);
if(shouldBeLoaded) {
let iframe = document.createElement("iframe");
iframe.src = entry.target.getAttribute("data-real-src");
entry.target.appendChild(iframe);
} else {
let iframe = entry.target.querySelector("iframe");
iframe.parentNode.removeChild(iframe);
}
}
});
}
const config = {
rootMargin: '600px 0px',
threshold: 0.01
};
let observer = new IntersectionObserver(onIntersection, config);
document.querySelectorAll(".lv-example").forEach(iframe => {
observer.observe(iframe);
});
});
</script>
{% endblock %}

View File

@ -0,0 +1,80 @@
#!/usr/bin/env python3
import sys
import os
import subprocess
import re
import example_list as ex
langs = ['en']
# Change to script directory for consistency
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
def cmd(s):
print("")
print(s)
print("-------------------------------------")
r = os.system(s)
if r != 0:
print("Exit build due to previous error")
exit(-1)
# Get the current branch name
status, br = subprocess.getstatusoutput("git branch | grep '*'")
_, gitcommit = subprocess.getstatusoutput("git rev-parse HEAD")
br = re.sub('\* ', '', br)
# Generate the list of examples
ex.exec()
urlpath = re.sub('release/', '', br)
# Be sure the github links point to the right branch
f = open("header.rst", "w")
f.write(".. |github_link_base| replace:: https://github.com/lvgl/lvgl/blob/" + gitcommit + "/docs")
f.close()
base_html = "html_baseurl = 'https://docs.lvgl.io/" + urlpath + "/en/html/'"
os.system("sed -i \"s|html_baseurl = .*|" + base_html +"|\" conf.py")
clean = 0
trans = 0
skip_latex = False
args = sys.argv[1:]
if len(args) >= 1:
if "clean" in args: clean = 1
if "skip_latex" in args: skip_latex = True
lang = "en"
print("")
print("****************")
print("Building")
print("****************")
if clean:
cmd("rm -rf " + lang)
cmd("mkdir " + lang)
print("Running doxygen")
cmd("cd ../scripts && doxygen Doxyfile")
# BUILD PDF
if not skip_latex:
# Silly workarond to include the more or less correct PDF download link in the PDF
#cmd("cp -f " + lang +"/latex/LVGL.pdf LVGL.pdf | true")
cmd("sphinx-build -b latex . out_latex")
# Generate PDF
cmd("cd out_latex && latexmk -pdf 'LVGL.tex'")
# Copy the result PDF to the main directory to make it avaiable for the HTML build
cmd("cd out_latex && cp -f LVGL.pdf ../LVGL.pdf")
else:
print("skipping latex build as requested")
# BULD HTML
cmd("sphinx-build -b html . ../out_html")

View File

@ -0,0 +1,239 @@
#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
#
# LVGL documentation build configuration file, created by
# sphinx-quickstart on Wed Jun 12 16:38:40 2019.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
import subprocess
sys.path.insert(0, os.path.abspath('./_ext'))
import recommonmark
from recommonmark.transform import AutoStructify
from sphinx.builders.html import StandaloneHTMLBuilder
from subprocess import Popen, PIPE
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'recommonmark',
'sphinx_markdown_tables',
'breathe',
'sphinx_sitemap',
'lv_example'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The default language to highlight source code in. The default is 'python'.
# The value should be a valid Pygments lexer name, see Showing code examples for more details.
highlight_language = 'c'
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
source_suffix = ['.rst', '.md']
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = 'LVGL'
copyright = '2021, LVGL Kft'
author = 'LVGL community'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
# embeddedt: extract using scripts/find_version.sh
version = subprocess.run(["../scripts/find_version.sh"], capture_output=True).stdout.decode("utf-8").strip()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'doxygen_html', 'Thumbs.db', '.DS_Store',
'README.md', 'lv_examples', 'out_html' ]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
'collapse_navigation' : False,
'logo_only': True,
}
# For site map generation
html_baseurl = 'https://docs.lvgl.io/' + version + "/"
sitemap_url_scheme = "{link}"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
]
}
html_favicon = 'favicon.png'
html_logo = 'logo_lvgl.png'
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'LVGLdoc'
html_last_updated_fmt = ''
# -- Options for LaTeX output ---------------------------------------------
latex_engine = 'xelatex'
latex_use_xindy = False
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
'inputenc': '',
'utf8extra': '',
'classoptions': ',openany,oneside',
'babel': '\\usepackage{babel}',
'passoptionstopackages': r'''
\PassOptionsToPackage{bookmarksdepth=5}{hyperref}% depth of pdf bookmarks
''',
'preamble': r'''
\usepackage{fontspec}
\setmonofont{DejaVu Sans Mono}
\usepackage{silence}
\WarningsOff*
''',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'LVGL.tex', 'LVGL Documentation ' + version,
'LVGL community', 'manual'),
]
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'lvgl', 'LVGL Documentation ' + version,
[author], 1)
]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'LVGL', 'LVGL Documentation ' + version,
author, 'Contributors of LVGL', 'One line description of project.',
'Miscellaneous'),
]
breathe_projects = {
"lvgl":"xml/",
}
StandaloneHTMLBuilder.supported_image_types = [
'image/svg+xml',
'image/gif', #prefer gif over png
'image/png',
'image/jpeg'
]
smartquotes = False
_, repo_commit_hash = subprocess.getstatusoutput("git rev-parse HEAD")
# Example configuration for intersphinx: refer to the Python standard library.
def setup(app):
app.add_config_value('recommonmark_config', {
'enable_eval_rst': True,
'enable_auto_toc_tree': 'True',
}, True)
app.add_transform(AutoStructify)
app.add_css_file('css/custom.css')
app.add_css_file('css/fontawesome.min.css')

View File

@ -0,0 +1,125 @@
#!/usr/bin/env python3
import os
def process_index_rst(path):
# print(path)
with open(path) as fp:
last_line=""
line=""
title_tmp=""
line = fp.readline()
d = {}
while line:
if line[0:3] == '"""':
title_tmp = last_line
elif line[0:15] ==".. lv_example::":
name = line[16:].strip()
title_tmp = title_tmp.strip()
d[name] = title_tmp
last_line = line
line = fp.readline()
return(d)
h1= {
"get_started":"Get started",
"styles":"Styles",
"anim":"Animations",
"event":"Events",
"layouts":"Layouts",
"scroll":"Scrolling",
"widgets":"Widgets"
}
widgets = {
"obj":"Base object",
"arc":"Arc",
"bar":"Bar",
"btn":"Button",
"btnmatrix":"Button matrix",
"calendar":"Calendar",
"canvas":"Canvas",
"chart":"Chart",
"checkbox":"Checkbox",
"colorwheel":"Colorwheel",
"dropdown":"Dropdown",
"img":"Image",
"imgbtn":"Image button",
"keyboard":"Keyboard",
"label":"Label",
"led":"LED",
"line":"Line",
"list":"List",
"meter":"Meter",
"msgbox":"Message box",
"roller":"Roller",
"slider":"Slider",
"span":"Span",
"spinbox":"Spinbox",
"spinner":"Spinner",
"switch":"Switch",
"table":"Table",
"tabview":"Tabview",
"textarea":"Textarea",
"tileview":"Tabview",
"win":"Window",
}
layouts = {
"flex":"Flex",
"grid":"Grid",
}
def print_item(path, lvl, d, fout):
for k in d:
v = d[k]
if k.startswith(path + "/lv_example_"):
fout.write("#"*lvl + " " + v + "\n")
fout.write('```eval_rst\n')
fout.write(f".. lv_example:: {k}\n")
fout.write('```\n')
fout.write("\n")
def exec():
path ="../examples/"
fout = open("examples.md", "w")
filelist = []
for root, dirs, files in os.walk(path):
for f in files:
#append the file name to the list
filelist.append(os.path.join(root,f))
filelist = [ fi for fi in filelist if fi.endswith("index.rst") ]
d_all = {}
#print all the file names
for fn in filelist:
d_act = process_index_rst(fn)
d_all.update(d_act)
fout.write("```eval_rst\n")
fout.write(".. include:: /header.rst\n")
fout.write(":github_url: |github_link_base|/examples.md\n")
fout.write("```\n")
fout.write("\n")
fout.write("# Examples\n")
for h in h1:
fout.write("## " + h1[h] + "\n")
if h == "widgets":
for w in widgets:
fout.write("### " + widgets[w] + "\n")
print_item(h + "/" + w, 4, d_all, fout)
elif h == "layouts":
for l in layouts:
fout.write("### " + layouts[l] + "\n")
print_item(h + "/" + l, 4, d_all, fout)
else:
print_item(h, 3, d_all, fout)
fout.write("")

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

View File

@ -0,0 +1,70 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/get-started/arduino.md
```
# Arduino
The [core LVGL library](https://github.com/lvgl/lvgl) and the [demos](https://github.com/lvgl/lv_demos) are directly available as Arduino libraries.
Note that you need to choose a powerful enough board to run LVGL and your GUI. See the [requirements of LVGL](https://docs.lvgl.io/latest/en/html/intro/index.html#requirements).
For example ESP32 is a good candidate to create your UI with LVGL.
## Get the LVGL Arduino library
LVGL can be installed via the Arduino IDE Library Manager or as a .ZIP library.
## Set up drivers
To get started it's recommended to use [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) library as a TFT driver to simplify testing.
To make it work, setup `TFT_eSPI` according to your TFT display type via editing either
- `User_Setup.h`
- or by selecting a configuration in the `User_Setup_Select.h`
Both files are located in `TFT_eSPI` library's folder.
## Configure LVGL
LVGL has its own configuration file called `lv_conf.h`. When LVGL is installed, follow these configuration steps:
1. Go to directory of the installed Arduino libraries
2. Go to `lvgl` and copy `lv_conf_template.h` as `lv_conf.h` into the Arduino Libraries directory next to the `lvgl` library folder.
3. Open `lv_conf.h` and change the first `#if 0` to `#if 1`
4. Set the color depth of you display in `LV_COLOR_DEPTH`
5. Set `LV_TICK_CUSTOM 1`
## Initialize LVGL and run an example
Take a look at [LVGL_Arduino.ino](https://github.com/lvgl/lvgl/blob/master/examples/arduino/LVGL_Arduino/LVGL_Arduino.ino) to see how to initialize LVGL.
TFT_eSPI is used as the display driver.
In the INO file you can see how to register a display and a touchpad for LVGL and call an example.
Note that, there is no dedicated INO file for every example, but you can open the examples in `lvgl/examples` folder and copy-paste them to your INO file.
You can NOT call the examples like `lv_example_btn_1()` because the Arduino doesn't compile the examples.
You can the [lv_demos](https://github.com/lvgl/lv_demos) library which needs to be installed and configured separately.
## Debugging and logging
LVGL can display debug information in case of trouble.
In the `LVGL_Arduino.ino` example there is a `my_print` method, which sends this debug information to the serial interface.
To enable this feature you have to edit the `lv_conf.h` file and enable logging in the section `log settings`:
```c
/*Log settings*/
#define USE_LV_LOG 1 /*Enable/disable the log module*/
#if LV_USE_LOG
/* How important log should be added:
* LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
* LV_LOG_LEVEL_INFO Log important events
* LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
* LV_LOG_LEVEL_NONE Do not log anything
*/
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
```
After enabling the log module and setting LV_LOG_LEVEL accordingly, the output log is sent to the `Serial` port @ 115200 bps.

View File

@ -0,0 +1,47 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/get-started/espressif.md
```
# Espressif (ESP32)
Since v7.7.1 LVGL includes a Kconfig file, so LVGL can be used as an ESP-IDF v4 component.
## Get the LVGL demo project for ESP32
We've created [lv_port_esp32](https://github.com/lvgl/lv_port_esp32), a project using ESP-IDF and LVGL to show one of the demos from [lv_examples](https://github.com/lvgl/lv_examples).
You are able to configure the project to use one of the many supported display controllers, see [lvgl_esp32_drivers](https://github.com/lvgl/lvgl_esp32_drivers) for a complete list
of supported display and indev (touch) controllers.
## Use LVGL in your ESP32 project
### Prerequisites
ESP-IDF v4 framework is the suggested version to use.
### Get LVGL
It is suggested that you add LVGL as a "component" to your project. This component can be located inside a directory named "components" in the project root directory.
When your project is a git repository you can include LVGL as a git submodule:
```c
git submodule add https://github.com/lvgl/lvgl.git components/lvgl
```
The above command will clone LVGL's main repository into the `components/lvgl` directory. LVGL includes a `CMakeLists.txt` file that sets some configuration options so you can use LVGL right away.
When you are ready to configure LVGL, launch the configuration menu with `idf.py menuconfig` on your project root directory, go to `Component config` and then `LVGL configuration`.
## Use lvgl_esp32_drivers in your project
You can also add `lvgl_esp32_drivers` as a "component". This component can be located inside a directory named "components" on your project root directory.
When your project is a git repository you can include `lvgl_esp32_drivers` as a git submodule:
```c
git submodule add https://github.com/lvgl/lvgl_esp32_drivers.git components/lvgl_esp32_drivers
```
### Support for ESP32-S2
Basic support for ESP32-S2 has been added into the `lvgl_esp32_drivers` repository.

View File

@ -0,0 +1,34 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/get-started/index.md
```
# Get started
There are several ways to get your feet wet with LVGL. Here is one recommended order of documents to read and things to play with when you are learning to use LVGL:
1. Check the [Online demos](https://lvgl.io/demos) to see LVGL in action (3 minutes)
2. Read the [Introduction](https://docs.lvgl.io/latest/en/html/intro/index.html) page of the documentation (5 minutes)
3. Read the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page of the documentation (15 minutes)
4. Set up a [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) (10 minutes)
5. Try out some [Examples](https://github.com/lvgl/lv_examples/)
6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/latest/en/html/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_&type=&language=)
7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library. (2-3 hours)
8. Check the documentation of the [Widgets](https://docs.lvgl.io/latest/en/html/widgets/index.html) to see their features and usage
9. If you have questions got to the [Forum](http://forum.lvgl.io/)
10. Read the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) guide to see how you can help to improve LVGL (15 minutes)
```eval_rst
.. toctree::
:maxdepth: 2
:hidden:
quick-overview
pc-simulator
stm32
nxp
espressif
arduino
micropython
nuttx
```

View File

@ -0,0 +1,96 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/get-started/micropython.md
```
# Micropython
## What is Micropython?
[Micropython](http://micropython.org/) is Python for microcontrollers.
Using Micropython, you can write Python3 code and run it even on a bare metal architecture with limited resources.
### Highlights of Micropython
- **Compact** - Fits and runs within just 256k of code space and 16k of RAM. No OS is needed, although you can also run it with an OS, if you want.
- **Compatible** - Strives to be as compatible as possible with normal Python (known as CPython).
- **Versatile** - Supports many architectures (x86, x86-64, ARM, ARM Thumb, Xtensa).
- **Interactive** - No need for the compile-flash-boot cycle. With the REPL (interactive prompt) you can type commands and execute them immediately, run scripts, etc.
- **Popular** - Many platforms are supported. The user base is growing bigger. Notable forks: [MicroPython](https://github.com/micropython/micropython), [CircuitPython](https://github.com/adafruit/circuitpython), [MicroPython_ESP32_psRAM_LoBo](https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo)
- **Embedded Oriented** - Comes with modules specifically for embedded systems, such as the [machine module](https://docs.micropython.org/en/latest/library/machine.html#classes) for accessing low-level hardware (I/O pins, ADC, UART, SPI, I2C, RTC, Timers etc.)
---
## Why Micropython + LVGL?
Currently, Micropython [does not have a good high-level GUI library](https://forum.micropython.org/viewtopic.php?f=18&t=5543) by default. LVGL is an [Object Oriented Component Based](https://blog.lvgl.io/2018-12-13/extend-lvgl-objects) high-level GUI library, which seems to be a natural candidate to map into a higher level language, such as Python. LVGL is implemented in C and its APIs are in C.
### Here are some advantages of using LVGL in Micropython:
- Develop GUI in Python, a very popular high level language. Use paradigms such as Object-Oriented Programming.
- Usually, GUI development requires multiple iterations to get things right. With C, each iteration consists of **`Change code` > `Build` > `Flash` > `Run`**.
In Micropython it's just **`Change code` > `Run`** ! You can even run commands interactively using the [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) (the interactive prompt)
### Micropython + LVGL could be used for:
- Fast prototyping GUI.
- Shortening the cycle of changing and fine-tuning the GUI.
- Modelling the GUI in a more abstract way by defining reusable composite objects, taking advantage of Python's language features such as Inheritance, Closures, List Comprehension, Generators, Exception Handling, Arbitrary Precision Integers and others.
- Make LVGL accessible to a larger audience. No need to know C to create a nice GUI on an embedded system.
This goes well with [CircuitPython vision](https://learn.adafruit.com/welcome-to-circuitpython/what-is-circuitpython). CircuitPython was designed with education in mind, to make it easier for new or unexperienced users to get started with embedded development.
- Creating tools to work with LVGL at a higher level (e.g. drag-and-drop designer).
---
## So what does it look like?
> TL;DR:
> It's very much like the C API, but Object-Oriented for LVGL components.
Let's dive right into an example!
### A simple example
```python
import lvgl as lv
lv.init()
scr = lv.obj()
btn = lv.btn(scr)
btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text("Button")
lv.scr_load(scr)
```
## How can I use it?
### Online Simulator
If you want to experiment with LVGL + Micropython without downloading anything - you can use our online simulator!
It's a fully functional LVGL + Micropython that runs entirely in the browser and allows you to edit a python script and run it.
[Click here to experiment on the online simulator](https://sim.lvgl.io/)
[Hello World](https://sim.lvgl.io/v7/micropython/ports/javascript/bundle_out/index.html?script=https://gist.githubusercontent.com/amirgon/51299ce9b6448328a855826149482ae6/raw/0f235c6d40462fd2f0e55364b874f14fe3fd613c/lvgl_hello_world.py&script_startup=https://gist.githubusercontent.com/amirgon/7bf15a66ba6d959bbf90d10f3da571be/raw/8684b5fa55318c184b1310663b187aaab5c65be6/init_lv_mp_js.py)
Note: the online simulator is available for lvgl v6 and v7.
### PC Simulator
Micropython is ported to many platforms. One notable port is "unix", which allows you to build and run Micropython (+LVGL) on a Linux machine. (On a Windows machine you might need Virtual Box or WSL or MinGW or Cygwin etc.)
[Click here to know more information about building and running the unix port](https://github.com/lvgl/lv_micropython)
### Embedded platform
In the end, the goal is to run it all on an embedded platform.
Both Micropython and LVGL can be used on many embedded architectures, such as stm32, ESP32 etc.
You would also need display and input drivers. We have some sample drivers (ESP32+ILI9341, as well as some other examples), but chances are you would want to create your own input/display drivers for your specific hardware.
Drivers can be implemented either in C as a Micropython module, or in pure Micropython!
## Where can I find more information?
- In this [Blog Post](https://blog.lvgl.io/2019-02-20/micropython-bindings)
- `lv_micropython` [README](https://github.com/lvgl/lv_micropython)
- `lv_binding_micropython` [README](https://github.com/lvgl/lv_binding_micropython)
- The [LVGL micropython forum](https://forum.lvgl.io/c/micropython) (Feel free to ask anything!)
- At Micropython: [docs](http://docs.micropython.org/en/latest/) and [forum](https://forum.micropython.org/)

View File

@ -0,0 +1,101 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/get-started/nuttx.md
```
# NuttX RTOS
## What is NuttX?
[NuttX](https://nuttx.apache.org/) is a mature and secure real-time operating system (RTOS) with an emphasis on technical standards compliance and small size.
It is scalable from 8-bit to 64-bit microcontrollers and microprocessors and compliant with the Portable Operating System Interface (POSIX) and the American National Standards Institute (ANSI) standards and with many Linux-like subsystems.
The best way to think about NuttX is to think of it as a small Unix/Linux for microcontrollers.
### Highlights of NuttX
- **Small** - Fits and runs in microcontrollers as small as 32 kB Flash and 8 kB of RAM.
- **Compliant** - Strives to be as compatible as possible with POSIX and Linux.
- **Versatile** - Supports many architectures (ARM, ARM Thumb, AVR, MIPS, OpenRISC, RISC-V 32-bit and 64-bit, RX65N, x86-64, Xtensa, Z80/Z180, etc.).
- **Modular** - Its modular design allows developers to select only what really matters and use modules to include new features.
- **Popular** - NuttX is used by many companies around the world. Probably you already used a product with NuttX without knowing it was running NuttX.
- **Predictable** - NuttX is a preemptible Realtime kernel, so you can use it to create predictable applications for realtime control.
---
## Why NuttX + LVGL?
Although NuttX has its own graphic library called [NX](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629474), LVGL is a good alternative because users could find more eye-candy demos and they can reuse code from previous projects.
LVGL is an [Object Oriented Component Based](https://blog.lvgl.io/2018-12-13/extend-lvgl-objects) high-level GUI library, that could fit very well for a RTOS with advanced features like NuttX.
LVGL is implemented in C and its APIs are in C.
### Here are some advantages of using LVGL in NuttX
- Develop GUI in Linux first and when it is done just compile it for NuttX. Nothing more, no wasting of time.
- Usually, GUI development for low level RTOS requires multiple iterations to get things right, where each iteration consists of **`Change code` > `Build` > `Flash` > `Run`**.
Using LVGL, Linux and NuttX you can reduce this process and just test everything on your computer and when it is done, compile it on NuttX and that is it.
### NuttX + LVGL could be used for
- GUI demos to demonstrate your board graphics capacities.
- Fast prototyping GUI for MVP (Minimum Viable Product) presentation.
- visualize sensor data directly and easily on the board without using a computer.
- Final products with a GUI without a touchscreen (i.e. 3D Printer Interface using Rotary Encoder to Input data).
- Final products with a touchscreen (and all sorts of bells and whistles).
---
## How to get started with NuttX and LVGL?
There are many boards in the [NuttX mainline](https://github.com/apache/incubator-nuttx) with support for LVGL.
Let's use the [STM32F429IDISCOVERY](https://www.st.com/en/evaluation-tools/32f429idiscovery.html) as an example because it is a very popular board.
### First you need to install the pre-requisites on your system
Let's use the [Windows Subsystem for Linux](https://acassis.wordpress.com/2018/01/10/how-to-build-nuttx-on-windows-10/)
```shell
$ sudo apt-get install automake bison build-essential flex gcc-arm-none-eabi gperf git libncurses5-dev libtool libusb-dev libusb-1.0.0-dev pkg-config kconfig-frontends openocd
```
### Now let's create a workspace to save our files
```shell
$ mkdir ~/nuttxspace
$ cd ~/nuttxspace
```
### Clone the NuttX and Apps repositories:
```shell
$ git clone https://github.com/apache/incubator-nuttx nuttx
$ git clone https://github.com/apache/incubator-nuttx-apps apps
```
### Configure NuttX to use the stm32f429i-disco board and the LVGL Demo
```shell
$ ./tools/configure.sh stm32f429i-disco:lvgl
$ make
```
If everything went fine you should have now the file `nuttx.bin` to flash on your board:
```shell
$ ls -l nuttx.bin
-rwxrwxr-x 1 alan alan 287144 Jun 27 09:26 nuttx.bin
```
### Flashing the firmware in the board using OpenOCD:
```shell
$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000"
```
Reset the board and using the 'NSH>' terminal start the LVGL demo:
```shell
nsh> lvgldemo
```
## Where can I find more information?
- This blog post: [LVGL on LPCXpresso54628](https://acassis.wordpress.com/2018/07/19/running-nuttx-on-lpcxpresso54628-om13098/)
- NuttX mailing list: [Apache NuttX Mailing List](http://nuttx.incubator.apache.org/community/)

View File

@ -0,0 +1,71 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/get-started/nxp.md
```
# NXP
NXP has integrated LVGL into the MCUXpresso SDK packages for several of their general
purpose and crossover microcontrollers, allowing easy evaluation and migration into your
product design. [Download an SDK for a supported board](https://www.nxp.com/design/software/embedded-software/littlevgl-open-source-graphics-library:LITTLEVGL-OPEN-SOURCE-GRAPHICS-LIBRARY?&tid=vanLITTLEVGL-OPEN-SOURCE-GRAPHICS-LIBRARY)
today and get started with your next GUI application.
## Creating new project with LVGL
Downloading the MCU SDK example project is recommended as a starting point. It comes fully
configured with LVGL (and with PXP support if module is present), no additional integration
work is required.
## Adding HW acceleration for NXP iMX RT platforms using PXP (PiXel Pipeline) engine for existing projects
Several drawing features in LVGL can be offloaded to the PXP engine. The CPU is available for other operations while the PXP is running. An RTOS is required to block the LVGL drawing thread and switch to another task or suspend the CPU for power savings.
#### Features supported:
- RGB565 color format
- Area fill + optional transparency
- BLIT (BLock Image Transfer) + optional transparency
- Color keying + optional transparency
- Recoloring (color tint) + optional transparency
- RTOS integration layer
- Default FreeRTOS and bare metal code provided
#### Basic configuration:
- Select NXP PXP engine in lv_conf.h: Set `LV_USE_GPU_NXP_PXP` to 1
- Enable default implementation for interrupt handling, PXP start function and automatic initialization: Set `LV_USE_GPU_NXP_PXP_AUTO_INIT` to 1
- If `FSL_RTOS_FREE_RTOS` symbol is defined, FreeRTOS implementation will be used, otherwise bare metal code will be included
#### Basic initialization:
- If `LV_USE_GPU_NXP_PXP_AUTO_INIT` is enabled, no user code is required; PXP is initialized automatically in `lv_init()`
- For manual PXP initialization, default configuration structure for callbacks can be used. Initialize PXP before calling `lv_init()`
```c
#if LV_USE_GPU_NXP_PXP
#include "lv_gpu/lv_gpu_nxp_pxp.h"
#include "lv_gpu/lv_gpu_nxp_pxp_osa.h"
#endif
. . .
#if LV_USE_GPU_NXP_PXP
if (lv_gpu_nxp_pxp_init(&pxp_default_cfg) != LV_RES_OK) {
PRINTF("PXP init error. STOP.\n");
for ( ; ; ) ;
}
#endif
```
#### Project setup:
- Add PXP related files to project:
- lv_gpu/lv_gpu_nxp.c, lv_gpu/lv_gpu_nxp.h: low level drawing calls for LVGL
- lv_gpu/lv_gpu_nxp_osa.c, lv_gpu/lv_gpu_osa.h: default implementation of OS-specific functions (bare metal and FreeRTOS only)
- optional, required only if `LV_USE_GPU_NXP_PXP_AUTO_INIT` is set to 1
- PXP related code depends on two drivers provided by MCU SDK. These drivers need to be added to project:
- fsl_pxp.c, fsl_pxp.h: PXP driver
- fsl_cache.c, fsl_cache.h: CPU cache handling functions
#### Advanced configuration:
- Implementation depends on multiple OS-specific functions. The struct `lv_nxp_pxp_cfg_t` with callback pointers is used
as a parameter for the `lv_gpu_nxp_pxp_init()` function. Default implementation for FreeRTOS and baremetal is provided in lv_gpu_nxp_osa.c
- `pxp_interrupt_init()`: Initialize PXP interrupt (HW setup, OS setup)
- `pxp_interrupt_deinit()`: Deinitialize PXP interrupt (HW setup, OS setup)
- `pxp_run()`: Start PXP job. Use OS-specific mechanism to block drawing thread. PXP must finish drawing before leaving this function.
- There are configurable area thresholds which are used to decide whether the area will be processed by CPU, or by PXP. Areas smaller than a
defined value will be processed by CPU and those bigger than the threshold will be processed by PXP. These thresholds may be defined as
preprocessor variables. Default values are defined lv_gpu/lv_gpu_nxp_pxp.h
- `GPU_NXP_PXP_BLIT_SIZE_LIMIT`: size threshold for image BLIT, BLIT with color keying, and BLIT with recolor (OPA > LV_OPA_MAX)
- `GPU_NXP_PXP_BLIT_OPA_SIZE_LIMIT`: size threshold for image BLIT and BLIT with color keying with transparency (OPA < LV_OPA_MAX)
- `GPU_NXP_PXP_FILL_SIZE_LIMIT`: size threshold for fill operation (OPA > LV_OPA_MAX)
- `GPU_NXP_PXP_FILL_OPA_SIZE_LIMIT`: size threshold for fill operation with transparency (OPA < LV_OPA_MAX)

View File

@ -0,0 +1,98 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/get-started/pc-simulator.md
```
# Simulator on PC
You can try out LVGL **using only your PC** (i.e. without any development boards). LVGL will run on a simulator environment on the PC where anyone can write and experiment with real LVGL applications.
Using the simulator on a PC has the following advantages:
- Hardware independent - Write code, run it on the PC and see the result on a monitor.
- Cross-platform - Any Windows, Linux or macOS system can run the PC simulator.
- Portability - The written code is portable, which means you can simply copy it when migrating to embedded hardware.
- Easy Validation - The simulator is also very useful to report bugs because it provides a common platform for every user. So it's a good idea to reproduce a bug in the simulator and use that code snippet in the [Forum](https://forum.lvgl.io).
## Select an IDE
The simulator is ported to various IDEs (Integrated Development Environments). Choose your favorite IDE, read its README on GitHub, download the project, and load it to the IDE.
- [Eclipse with SDL driver](https://github.com/lvgl/lv_sim_eclipse_sdl): Recommended on Linux and Mac
- [CodeBlocks](https://github.com/lvgl/lv_sim_codeblocks_win): Recommended on Windows
- [VisualStudio with SDL driver](https://github.com/lvgl/lv_sim_visual_studio_sdl): For Windows
- [VSCode with SDL driver](https://github.com/lvgl/lv_sim_vscode_sdl): Recommended on Linux and Mac
- [PlatformIO with SDL driver](https://github.com/lvgl/lv_platformio): Recommended on Linux and Mac
You can use any IDE for development but, for simplicity, the configuration for Eclipse CDT is what we'll focus on in this tutorial.
The following section describes the set-up guide of Eclipse CDT in more detail.
**Note: If you are on Windows, it's usually better to use the Visual Studio or CodeBlocks projects instead. They work out of the box without requiring extra steps.**
## Set-up Eclipse CDT
### Install Eclipse CDT
[Eclipse CDT](https://eclipse.org/cdt/) is a C/C++ IDE.
Eclipse is a Java-based tool so be sure **Java Runtime Environment** is installed on your system.
On Debian-based distros (e.g. Ubuntu): `sudo apt-get install default-jre`
Note: If you are using other distros, then please install a 'Java Runtime Environment' suitable to your distro.
Note: If you are using macOS and get a "Failed to create the Java Virtual Machine" error, uninstall any other Java JDK installs and install Java JDK 8u. This should fix the problem.
You can download Eclipse's CDT from: [https://www.eclipse.org/cdt/downloads.php](https://www.eclipse.org/cdt/downloads.php). Start the installer and choose *Eclipse CDT* from the list.
### Install SDL 2
The PC simulator uses the [SDL 2](https://www.libsdl.org/download-2.0.php) cross-platform library to simulate a TFT display and a touchpad.
#### Linux
On **Linux** you can easily install SDL2 using a terminal:
1. Find the current version of SDL2: `apt-cache search libsdl2 (e.g. libsdl2-2.0-0)`
2. Install SDL2: `sudo apt-get install libsdl2-2.0-0` (replace with the found version)
3. Install SDL2 development package: `sudo apt-get install libsdl2-dev`
4. If build essentials are not installed yet: `sudo apt-get install build-essential`
#### Windows
If you are using **Windows** firstly you need to install MinGW ([64 bit version](http://mingw-w64.org/doku.php/download)). After installing MinGW, do the following steps to add SDL2:
1. Download the development libraries of SDL.
Go to [https://www.libsdl.org/download-2.0.php](https://www.libsdl.org/download-2.0.php) and download _Development Libraries: SDL2-devel-2.0.5-mingw.tar.gz_
2. Decompress the file and go to _x86_64-w64-mingw32_ directory (for 64 bit MinGW) or to _i686-w64-mingw32_ (for 32 bit MinGW)
3. Copy _..._mingw32/include/SDL2_ folder to _C:/MinGW/.../x86_64-w64-mingw32/include_
4. Copy _..._mingw32/lib/_ content to _C:/MinGW/.../x86_64-w64-mingw32/lib_
5. Copy _..._mingw32/bin/SDL2.dll_ to _{eclipse_worksapce}/pc_simulator/Debug/_. Do it later when Eclipse is installed.
Note: If you are using **Microsoft Visual Studio** instead of Eclipse then you don't have to install MinGW.
#### OSX
On **OSX** you can easily install SDL2 with brew: `brew install sdl2`
If something is not working, then please refer [this tutorial](http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php) to get started with SDL.
### Pre-configured project
A pre-configured graphics library project (based on the latest release) is always available to get started easily.
You can find the latest one on [GitHub](https://github.com/lvgl/lv_sim_eclipse_sdl).
(Please note that, the project is configured for Eclipse CDT).
### Add the pre-configured project to Eclipse CDT
Run Eclipse CDT. It will show a dialogue about the **workspace path**. Before accepting the path, check that path and copy (and unzip) the downloaded pre-configured project there. After that, you can accept the workspace path. Of course you can modify this path but in that case copy the project to the corresponding location.
Close the start-up window and go to **File-&gt;Import** and choose **General-&gt;Existing project into Workspace**. **Browse the root directory** of the project and click **Finish**
On **Windows** you have to do two additional things:
- Copy the **SDL2.dll** into the project's Debug folder
- Right-click on the project -&gt; Project properties -&gt; C/C++ Build -&gt; Settings -&gt; Libraries -&gt; Add ... and add _mingw32_ above SDLmain and SDL. (The order is important: mingw32, SDLmain, SDL)
### Compile and Run
Now you are ready to run LVGL on your PC. Click on the Hammer Icon on the top menu bar to Build the project. If you have done everything right, then you will not get any errors. Note that on some systems additional steps might be required to "see" SDL 2 from Eclipse but in most cases the configuration in the downloaded project is enough.
After a successful build, click on the Play button on the top menu bar to run the project. Now a window should appear in the middle of your screen.
Now you are ready to use LVGL and begin development on your PC.

View File

@ -0,0 +1,270 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/get-started/quick-overview.md
```
# Quick overview
Here you can learn the most important things about LVGL.
You should read this first to get a general impression and read the detailed [Porting](/porting/index) and [Overview](/overview/index) sections after that.
## Get started in a simulator
Instead of porting LVGL to embedded hardware straight away, it's highly recommended to get started in a simulator first.
LVGL is ported to many IDEs to be sure you will find your favorite one.
Go to the [Simulators](/get-started/pc-simulator) section to get ready-to-use projects that can be run on your PC.
This way you can save the time of porting for now and get some experience with LVGL immediately.
## Add LVGL into your project
If you would rather try LVGL on your own project follow these steps:
- [Download](https://github.com/lvgl/lvgl/archive/master.zip) or clone the library from GitHub with `git clone https://github.com/lvgl/lvgl.git`.
- Copy the `lvgl` folder into your project.
- Copy `lvgl/lv_conf_template.h` as `lv_conf.h` next to the `lvgl` folder, change the first `#if 0` to `1` to enable the file's content and set the `LV_COLOR_DEPTH` defines.
- Include `lvgl/lvgl.h` in files where you need to use LVGL related functions.
- Call `lv_tick_inc(x)` every `x` milliseconds in a Timer or Task (`x` should be between 1 and 10). It is required for the internal timing of LVGL.
Alternatively, configure `LV_TICK_CUSTOM` (see `lv_conf.h`) so that LVGL can retrieve the current time directly.
- Call `lv_init()`
- Create a draw buffer: LVGL will render the graphics here first, and send the rendered image to the display.
The buffer size can be set freely but 1/10 screen size is a good starting point.
```c
static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf1[DISP_HOR_RES * DISP_VER_RES / 10]; /*Declare a buffer for 1/10 screen size*/
lv_disp_draw_buf_init(&draw_buf, buf1, NULL, MY_DISP_HOR_RES * MY_DISP_VER_SER / 10); /*Initialize the display buffer.*/
```
- Implement and register a function which can copy the rendered image to an area of your display:
```c
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/
disp_drv.draw_buf = &draw_buf; /*Assign the buffer to the display*/
disp_drv.hor_res = MY_DISP_HOR_RES; /*Set the horizontal resolution of the display*/
disp_drv.ver_res = MY_DISP_VER_RES; /*Set the vertical resolution of the display*/
lv_disp_drv_register(&disp_drv); /*Finally register the driver*/
void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p)
{
int32_t x, y;
/*It's a very slow but simple implementation.
*`set_pixel` needs to be written by you to a set pixel on the screen*/
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
set_pixel(x, y, *color_p);
color_p++;
}
}
lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/
}
```
- Implement and register a function which can read an input device. E.g. for a touchpad:
```c
static lv_indev_drv_t indev_drv; /*Descriptor of a input device driver*/
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/
indev_drv.read_cb = my_touchpad_read; /*Set your driver function*/
lv_indev_drv_register(&indev_drv); /*Finally register the driver*/
void my_touchpad_read(lv_indev_t * indev, lv_indev_data_t * data)
{
/*`touchpad_is_pressed` and `touchpad_get_xy` needs to be implemented by you*/
if(touchpad_is_pressed()) {
data->state = LV_INDEV_STATE_PRESSED;
touchpad_get_xy(&data->point.x, &data->point.y);
} else {
data->state = LV_INDEV_STATE_RELEASED;
}
}
```
- Call `lv_timer_handler()` periodically every few milliseconds in the main `while(1)` loop or in an operating system task.
It will redraw the screen if required, handle input devices, animation etc.
For a more detailed guide go to the [Porting](/porting/index) section.
## Learn the basics
### Widgets
The graphical elements like Buttons, Labels, Sliders, Charts etc. are called objects or widgets. Go to [Widgets](/widgets/index) to see the full list of available widgets.
Every object has a parent object where it is created. For example, if a label is created on a button, the button is the parent of label.
The child object moves with the parent and if the parent is deleted the children will be deleted too.
Children can be visible only within their parent's bounding area. In other words, the parts of the children outside the parent are clipped.
A Screen is the "root" parent. You can have any number of screens.
To get the current screen call `lv_scr_act()`, and to load a screen use `lv_scr_load(scr1)`.
You can create a new object with `lv_<type>_create(parent)`. It will return an `lv_obj_t *` variable that can be used as a reference to the object to set its parameters.
For example:
```c
lv_obj_t * slider1 = lv_slider_create(lv_scr_act());
```
To set some basic attributes `lv_obj_set_<parameter_name>(obj, <value>)` functions can be used. For example:
```c
lv_obj_set_x(btn1, 30);
lv_obj_set_y(btn1, 10);
lv_obj_set_size(btn1, 200, 50);
```
Along with the basic attributes, widgets can have type specific parameters which are set by `lv_<widget_type>_set_<parameter_name>(obj, <value>)` functions. For example:
```c
lv_slider_set_value(slider1, 70, LV_ANIM_ON);
```
To see the full API visit the documentation of the widgets or the related header file (e.g. [lvgl/src/widgets/lv_slider.h](https://github.com/lvgl/lvgl/blob/master/src/widgets/lv_slider.h)).
### Events
Events are used to inform the user that something has happened with an object.
You can assign one or more callbacks to an object which will be called if the object is clicked, released, dragged, being deleted, etc.
A callback is assigned like this:
```c
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL); /*Assign a callback to the button*/
...
void btn_event_cb(lv_event_t * e)
{
printf("Clicked\n");
}
```
`LV_EVENT_ALL` can be used instead of `LV_EVENT_CLICKED` to invoke the callback for any event.
From `lv_event_t * e` the current event code can be retrieved with:
```c
lv_event_code_t code = lv_event_get_code(e);
```
The object that triggered the event can be retrieved with:
```c
lv_obj_t * obj = lv_event_get_target(e);
```
To learn all features of the events go to the [Event overview](/overview/event) section.
### Parts
Widgets might be built from one or more *parts*. For example, a button has only one part called `LV_PART_MAIN`.
However, a [Slider](/widgets/core/slider) has `LV_PART_MAIN`, `LV_PART_INDICATOR` and `LV_PART_KNOB`.
By using parts you can apply different styles to sub-elements of a widget. (See below)
Read the widgets' documentation to learn which parts each uses.
### States
LVGL objects can be in a combination of the following states:
- `LV_STATE_DEFAULT` Normal, released state
- `LV_STATE_CHECKED` Toggled or checked state
- `LV_STATE_FOCUSED` Focused via keypad or encoder or clicked via touchpad/mouse
- `LV_STATE_FOCUS_KEY` Focused via keypad or encoder but not via touchpad/mouse
- `LV_STATE_EDITED` Edit by an encoder
- `LV_STATE_HOVERED` Hovered by mouse (not supported now)
- `LV_STATE_PRESSED` Being pressed
- `LV_STATE_SCROLLED` Being scrolled
- `LV_STATE_DISABLED` Disabled
For example, if you press an object it will automatically go to the `LV_STATE_FOCUSED` and `LV_STATE_PRESSED` states and when you release it the `LV_STATE_PRESSED` state will be removed while focus remains active.
To check if an object is in a given state use `lv_obj_has_state(obj, LV_STATE_...)`. It will return `true` if the object is currently in that state.
To manually add or remove states use:
```c
lv_obj_add_state(obj, LV_STATE_...);
lv_obj_clear_state(obj, LV_STATE_...);
```
### Styles
A style instance contains properties such as background color, border width, font, etc. that describe the appearance of objects.
Styles are represented with `lv_style_t` variables. Only their pointer is saved in the objects so they need to be defined as static or global.
Before using a style it needs to be initialized with `lv_style_init(&style1)`. After that, properties can be added to configure the style. For example:
```
static lv_style_t style1;
lv_style_init(&style1);
lv_style_set_bg_color(&style1, lv_color_hex(0xa03080))
lv_style_set_border_width(&style1, 2))
```
See the full list of properties [here](/overview/style.html#properties).
Styles are assigned using the ORed combination of an object's part and state. For example to use this style on the slider's indicator when the slider is pressed:
```c
lv_obj_add_style(slider1, &style1, LV_PART_INDICATOR | LV_STATE_PRESSED);
```
If the *part* is `LV_PART_MAIN` it can be omitted:
```c
lv_obj_add_style(btn1, &style1, LV_STATE_PRESSED); /*Equal to LV_PART_MAIN | LV_STATE_PRESSED*/
```
Similarly, `LV_STATE_DEFAULT` can be omitted too:
```c
lv_obj_add_style(slider1, &style1, LV_PART_INDICATOR); /*Equal to LV_PART_INDICATOR | LV_STATE_DEFAULT*/
```
For `LV_STATE_DEFAULT` and `LV_PART_MAIN` simply write `0`:
```c
lv_obj_add_style(btn1, &style1, 0); /*Equal to LV_PART_MAIN | LV_STATE_DEFAULT*/
```
Styles can be cascaded (similarly to CSS). It means you can add more styles to a part of an object.
For example `style_btn` can set a default button appearance, and `style_btn_red` can overwrite the background color to make the button red:
```c
lv_obj_add_style(btn1, &style_btn, 0);
lv_obj_add_style(btn1, &style1_btn_red, 0);
```
If a property is not set on for the current state, the style with `LV_STATE_DEFAULT` will be used. A default value is used if the property is not defined in the default state.
Some properties (typically the text-related ones) can be inherited. This means if a property is not set in an object it will be searched for in its parents too.
For example, you can set the font once in the screen's style and all text on that screen will inherit it by default.
Local style properties also can be added to objects. This creates a style which resides inside the object and is used only by the object:
```c
lv_obj_set_style_bg_color(slider1, lv_color_hex(0x2080bb), LV_PART_INDICATOR | LV_STATE_PRESSED);
```
To learn all the features of styles see the [Style overview](/overview/style) section.
### Themes
Themes are the default styles for objects. Styles from a theme are applied automatically when objects are created.
The theme for your application is a compile time configuration set in `lv_conf.h`.
## Examples
```eval_rst
.. include:: ../../examples/get_started/index.rst
```
## Micropython
Learn more about [Micropython](/get-started/micropython).
```python
# Create a Button and a Label
scr = lv.obj()
btn = lv.btn(scr)
btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text("Button")
# Load the screen
lv.scr_load(scr)
```

View File

@ -0,0 +1,8 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/get-started/stm32.md
```
# STM32
TODO

View File

@ -0,0 +1 @@
.. |github_link_base| replace:: https://github.com/lvgl/lvgl/blob/c6f99ad200c7862c2f3cca3811bc2bdc2c95e971/docs

View File

@ -0,0 +1,42 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/index.md
```
```eval_rst
PDF version: :download:`LVGL.pdf <LVGL.pdf>`
```
# Welcome to the documentation of LVGL!
<img src="_static/img/home_banner.jpg" style="width:100%">
<div style="margin-bottom:48px">
<a href="intro/index.html"><img class="home-img" src="_static/img/home_1.png" alt="Get familiar with the LVGL project"></a>
<a href="get-started/index.html"><img class="home-img" src="_static/img/home_2.png" alt="Learn the basic of LVGL and its usage on various platforms"></a>
<a href="porting/index.html"><img class="home-img" src="_static/img/home_3.png" alt="See how to port LVGL to any platform"></a>
<a href="overview/index.html"><img class="home-img" src="_static/img/home_4.png" alt="Learn the how LVGL works in more detail"></a>
<a href="widgets/index.html"><img class="home-img" src="_static/img/home_5.png" alt="Take a look at the description of the available widgets"></a>
<a href="CONTRIBUTING.html"><img class="home-img" src="_static/img/home_6.png" alt="Be part of the development of LVGL"></a>
</div>
```eval_rst
.. toctree::
:maxdepth: 2
intro/index
examples
get-started/index
porting/index
overview/index
widgets/index
layouts/index
libs/index
others/index
CONTRIBUTING
CHANGELOG
ROADMAP
```

View File

@ -0,0 +1,209 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/intro/index.md
```
# Introduction
LVGL (Light and Versatile Graphics Library) is a free and open-source graphics library providing everything you need to create an embedded GUI with easy-to-use graphical elements, beautiful visual effects and a low memory footprint.
## Key features
- Powerful building blocks such as buttons, charts, lists, sliders, images, etc.
- Advanced graphics with animations, anti-aliasing, opacity, smooth scrolling
- Various input devices such as touchpad, mouse, keyboard, encoder, etc.
- Multi-language support with UTF-8 encoding
- Multi-display support, i.e. use multiple TFT, monochrome displays simultaneously
- Fully customizable graphic elements with CSS-like styles
- Hardware independent: use with any microcontroller or display
- Scalable: able to operate with little memory (64 kB Flash, 16 kB RAM)
- OS, external memory and GPU are supported but not required
- Single frame buffer operation even with advanced graphic effects
- Written in C for maximal compatibility (C++ compatible)
- Simulator to start embedded GUI design on a PC without embedded hardware
- Binding to MicroPython
- Tutorials, examples, themes for rapid GUI design
- Documentation is available online and as PDF
- Free and open-source under MIT license
## Requirements
Basically, every modern controller which is able to drive a display is suitable to run LVGL. The minimal requirements are:
<ul>
<li> 16, 32 or 64 bit microcontroller or processor</li>
<li>&gt; 16 MHz clock speed is recommended</li>
<li> Flash/ROM: &gt; 64 kB for the very essential components (&gt; 180 kB is recommended)</li>
<li> RAM:
<ul>
<li> Static RAM usage: ~2 kB depending on the used features and object types</li>
<li> Stack: &gt; 2kB (&gt; 8 kB is recommended)</li>
<li> Dynamic data (heap): &gt; 4 KB (&gt; 32 kB is recommended if using several objects).
    Set by <em>LV_MEM_SIZE</em> in <em>lv_conf.h</em>. </li>
<li> Display buffer:  &gt; <em>"Horizontal resolution"</em> pixels (&gt; 10 &times; <em>"Horizontal resolution"</em> is recommended) </li>
<li> One frame buffer in the MCU or in an external display controller</li>
</ul>
</li>
<li> C99 or newer compiler</li>
<li> Basic C (or C++) knowledge:
<a href="https://www.tutorialspoint.com/cprogramming/c_pointers.htm">pointers</a>,
<a href="https://www.tutorialspoint.com/cprogramming/c_structures.htm">structs</a>,
<a href="https://www.geeksforgeeks.org/callbacks-in-c/">callbacks</a>.</li>
</ul>
<em>Note that memory usage may vary depending on architecture, compiler and build options.</em>
## License
The LVGL project (including all repositories) is licensed under [MIT license](https://github.com/lvgl/lvgl/blob/master/LICENCE.txt).
This means you can use it even in commercial projects.
It's not mandatory but we highly appreciate it if you write a few words about your project in the [My projects](https://forum.lvgl.io/c/my-projects/10) category of the forum or a private message to [lvgl.io](https://lvgl.io/#contact).
Although you can get LVGL for free there is a massive amount of work behind it. It's created by a group of volunteers who made it available for you in their free time.
To make the LVGL project sustainable, please consider [contributing](/CONTRIBUTING) to the project.
You can choose from [many different ways of contributing](/CONTRIBUTING) such as simply writing a tweet about you are using LVGL, fixing bugs, translating the documentation, or even becoming a maintainer.
## Repository layout
All repositories of the LVGL project are hosted on GitHub: https://github.com/lvgl
You will find these repositories there:
- [lvgl](https://github.com/lvgl/lvgl) The library itself with many [examples](https://github.com/lvgl/lvgl/blob/master/examples/).
- [lv_demos](https://github.com/lvgl/lv_demos) Demos created with LVGL.
- [lv_drivers](https://github.com/lvgl/lv_drivers) Display and input device drivers
- [blog](https://github.com/lvgl/blog) Source of the blog's site (https://blog.lvgl.io)
- [sim](https://github.com/lvgl/sim) Source of the online simulator's site (https://sim.lvgl.io)
- [lv_sim_...](https://github.com/lvgl?q=lv_sim&type=&language=) Simulator projects for various IDEs and platforms
- [lv_port_...](https://github.com/lvgl?q=lv_port&type=&language=) LVGL ports to development boards
- [lv_binding_..](https://github.com/lvgl?q=lv_binding&type=&language=l) Bindings to other languages
- [lv_...](https://github.com/lvgl?q=lv_&type=&language=) Ports to other platforms
## Release policy
The core repositories follow the rules of [Semantic versioning](https://semver.org/):
- Major versions for incompatible API changes. E.g. v5.0.0, v6.0.0
- Minor version for new but backward-compatible functionalities. E.g. v6.1.0, v6.2.0
- Patch version for backward-compatible bug fixes. E.g. v6.1.1, v6.1.2
Tags like `vX.Y.Z` are created for every release.
### Release cycle
- Bug fixes: Released on demand even weekly
- Minor releases: Every 3-4 months
- Major releases: Approximately yearly
### Branches
The core repositories have at least the following branches:
- `master` latest version, patches are merged directly here.
- `release/vX.Y` stable versions of the minor releases
- `fix/some-description` temporary branches for bug fixes
- `feat/some-description` temporary branches for features
### Changelog
The changes are recorded in [CHANGELOG.md](/CHANGELOG).
### Version support
Before v8 every minor release of major releases is supported for 1 year.
Starting from v8, every minor release is supported for 1 year.
| Version | Release date | Support end | Active |
|---------|--------------|-------------|--------|
| v5.3 | Feb 1, 2019 |Feb 1, 2020 | No |
| v6.1 | Nov 26, 2019 |Nov 26, 2020 | No |
| v7.11 | Mar 16, 2021 |Mar 16, 2022 | Yes |
| v8.0 | 1 Jun, 2021 |1 Jun, 2022 | Yes |
| v8.1 | In progress | | |
## FAQ
### Where can I ask questions?
You can ask questions in the forum: [https://forum.lvgl.io/](https://forum.lvgl.io/).
We use [GitHub issues](https://github.com/lvgl/lvgl/issues) for development related discussion.
You should use them only if your question or issue is tightly related to the development of the library.
### Is my MCU/hardware supported?
Every MCU which is capable of driving a display via parallel port, SPI, RGB interface or anything else and fulfills the [Requirements](#requirements) is supported by LVGL.
This includes:
- "Common" MCUs like STM32F, STM32H, NXP Kinetis, LPC, iMX, dsPIC33, PIC32 etc.
- Bluetooth, GSM, Wi-Fi modules like Nordic NRF and Espressif ESP32
- Linux with frame buffer device such as /dev/fb0. This includes Single-board computers like the Raspberry Pi
- Anything else with a strong enough MCU and a peripheral to drive a display
### Is my display supported?
LVGL needs just one simple driver function to copy an array of pixels into a given area of the display.
If you can do this with your display then you can use it with LVGL.
Some examples of the supported display types:
- TFTs with 16 or 24 bit color depth
- Monitors with an HDMI port
- Small monochrome displays
- Gray-scale displays
- even LED matrices
- or any other display where you can control the color/state of the pixels
See the [Porting](/porting/display) section to learn more.
### Nothing happens, my display driver is not called. What have I missed?
Be sure you are calling `lv_tick_inc(x)` in an interrupt and `lv_timer_handler()` in your main `while(1)`.
Learn more in the [Tick](/porting/tick) and [Task handler](/porting/task-handler) sections.
### Why is the display driver called only once? Only the upper part of the display is refreshed.
Be sure you are calling `lv_disp_flush_ready(drv)` at the end of your "*display flush callback*".
### Why do I see only garbage on the screen?
Probably there a bug in your display driver. Try the following code without using LVGL. You should see a square with red-blue gradient.
```c
#define BUF_W 20
#define BUF_H 10
lv_color_t buf[BUF_W * BUF_H];
lv_color_t * buf_p = buf;
uint16_t x, y;
for(y = 0; y &lt; BUF_H; y++) {
    lv_color_t c = lv_color_mix(LV_COLOR_BLUE, LV_COLOR_RED, (y * 255) / BUF_H);
    for(x = 0; x &lt; BUF_W; x++){
        (*buf_p) =  c;
        buf_p++;
    }
}
lv_area_t a;
a.x1 = 10;
a.y1 = 40;
a.x2 = a.x1 + BUF_W - 1;
a.y2 = a.y1 + BUF_H - 1;
my_flush_cb(NULL, &a, buf);
```
### Why do I see nonsense colors on the screen?
Probably LVGL's color format is not compatible with your display's color format. Check `LV_COLOR_DEPTH` in *lv_conf.h*.
If you are using 16-bit colors with SPI (or another byte-oriented interface) you probably need to set `LV_COLOR_16_SWAP  1` in *lv_conf.h*.
It swaps the upper and lower bytes of the pixels.
### How to speed up my UI?
- Turn on compiler optimization and enable cache if your MCU has it
- Increase the size of the display buffer
- Use two display buffers and flush the buffer with DMA (or similar peripheral) in the background
- Increase the clock speed of the SPI or parallel port if you use them to drive the display
- If your display has a SPI port consider changing to a model with a parallel interface because it has much higher throughput
- Keep the display buffer in internal RAM (not in external SRAM) because LVGL uses it a lot and it should have a fast access time
 
### How to reduce flash/ROM usage?
You can disable all the unused features (such as animations, file system, GPU etc.) and object types in *lv_conf.h*.
If you are using GCC you can add `-fdata-sections -ffunction-sections` compiler flags and `--gc-sections` linker flag to remove unused functions and variables from the final binary.
### How to reduce the RAM usage
- Lower the size of the *Display buffer*
- Reduce `LV_MEM_SIZE` in *lv_conf.h*. This memory is used when you create objects like buttons, labels, etc.
- To work with lower `LV_MEM_SIZE` you can create objects only when required and delete them when they are not needed anymore
 
### How to work with an operating system?
To work with an operating system where tasks can interrupt each other (preemptively) you should protect LVGL related function calls with a mutex.
See the [Operating system and interrupts](/porting/os) section to learn more.

View File

@ -0,0 +1,123 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/layouts/flex.md
```
# Flex
## Overview
The Flexbox (or Flex for short) is a subset of [CSS Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/).
It can arrange items into rows or columns (tracks), handle wrapping, adjust the spacing between the items and tracks, handle *grow* to make the item(s) fill the remaining space with respect to min/max width and height.
To make an object flex container call `lv_obj_set_layout(obj, LV_LAYOUT_FLEX)`.
Note that the flex layout feature of LVGL needs to be globally enabled with `LV_USE_FLEX` in `lv_conf.h`.
## Terms
- tracks: the rows or columns
- main direction: row or column, the direction in which the items are placed
- cross direction: perpendicular to the main direction
- wrap: if there is no more space in the track a new track is started
- grow: if set on an item it will grow to fill the remaining space on the track.
The available space will be distributed among items respective to their grow value (larger value means more space)
- gap: the space between the rows and columns or the items on a track
## Simple interface
With the following functions you can set a Flex layout on any parent.
### Flex flow
`lv_obj_set_flex_flow(obj, flex_flow)`
The possible values for `flex_flow` are:
- `LV_FLEX_FLOW_ROW` Place the children in a row without wrapping
- `LV_FLEX_FLOW_COLUMN` Place the children in a column without wrapping
- `LV_FLEX_FLOW_ROW_WRAP` Place the children in a row with wrapping
- `LV_FLEX_FLOW_COLUMN_WRAP` Place the children in a column with wrapping
- `LV_FLEX_FLOW_ROW_REVERSE` Place the children in a row without wrapping but in reversed order
- `LV_FLEX_FLOW_COLUMN_REVERSE` Place the children in a column without wrapping but in reversed order
- `LV_FLEX_FLOW_ROW_WRAP_REVERSE` Place the children in a row with wrapping but in reversed order
- `LV_FLEX_FLOW_COLUMN_WRAP_REVERSE` Place the children in a column with wrapping but in reversed order
### Flex align
To manage the placement of the children use `lv_obj_set_flex_align(obj, main_place, cross_place, track_cross_place)`
- `main_place` determines how to distribute the items in their track on the main axis. E.g. flush the items to the right on `LV_FLEX_FLOW_ROW_WRAP`. (It's called `justify-content` in CSS)
- `cross_place` determines how to distribute the items in their track on the cross axis. E.g. if the items have different height place them to the bottom of the track. (It's called `align-items` in CSS)
- `track_cross_place` determines how to distribute the tracks (It's called `align-content` in CSS)
The possible values are:
- `LV_FLEX_ALIGN_START` means left on a horizontally and top vertically. (default)
- `LV_FLEX_ALIGN_END` means right on a horizontally and bottom vertically
- `LV_FLEX_ALIGN_CENTER` simply center
- `LV_FLEX_ALIGN_SPACE_EVENLY` items are distributed so that the spacing between any two items (and the space to the edges) is equal. Does not apply to `track_cross_place`.
- `LV_FLEX_ALIGN_SPACE_AROUND` items are evenly distributed in the track with equal space around them.
Note that visually the spaces arent equal, since all the items have equal space on both sides.
The first item will have one unit of space against the container edge, but two units of space between the next item because that next item has its own spacing that applies. Not applies to `track_cross_place`.
- `LV_FLEX_ALIGN_SPACE_BETWEEN` items are evenly distributed in the track: first item is on the start line, last item on the end line. Not applies to `track_cross_place`.
### Flex grow
Flex grow can be used to make one or more children fill the available space on the track. When more children have grow parameters, the available space will be distributed proportionally to the grow values.
For example, there is 400 px remaining space and 4 objects with grow:
- `A` with grow = 1
- `B` with grow = 1
- `C` with grow = 2
`A` and `B` will have 100 px size, and `C` will have 200 px size.
Flex grow can be set on a child with `lv_obj_set_flex_grow(child, value)`. `value` needs to be &gt; 1 or 0 to disable grow on the child.
## Style interface
All the Flex-related values are style properties under the hood and you can use them similarly to any other style property. The following flex related style properties exist:
- `FLEX_FLOW`
- `FLEX_MAIN_PLACE`
- `FLEX_CROSS_PLACE`
- `FLEX_TRACK_PLACE`
- `FLEX_GROW`
### Internal padding
To modify the minimum space flexbox inserts between objects, the following properties can be set on the flex container style:
- `pad_row` Sets the padding between the rows.
- `pad_column` Sets the padding between the columns.
These can for example be used if you don't want any padding between your objects: `lv_style_set_pad_column(&row_container_style,0)`
## Other features
### RTL
If the base direction of the container is set the `LV_BASE_DIR_RTL` the meaning of `LV_FLEX_ALIGN_START` and `LV_FLEX_ALIGN_END` is swapped on `ROW` layouts. I.e. `START` will mean right.
The items on `ROW` layouts, and tracks of `COLUMN` layouts will be placed from right to left.
### New track
You can force Flex to put an item into a new line with `lv_obj_add_flag(child, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK)`.
## Example
```eval_rst
.. include:: ../../examples/layouts/flex/index.rst
```
## API
```eval_rst
.. doxygenfile:: lv_flex.h
:project: lvgl
```

View File

@ -0,0 +1,117 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/layouts/grid.md
```
# Grid
## Overview
The Grid layout is a subset of [CSS Flexbox](https://css-tricks.com/snippets/css/complete-guide-grid/).
It can arrange items into a 2D "table" that has rows or columns (tracks). The item can span through multiple columns or rows.
The track's size can be set in pixel, to the largest item (`LV_GRID_CONTENT`) or in "Free unit" (FR) to distribute the free space proportionally.
To make an object a grid container call `lv_obj_set_layout(obj, LV_LAYOUT_GRID)`.
Note that the grid layout feature of LVGL needs to be globally enabled with `LV_USE_GRID` in `lv_conf.h`.
## Terms
- tracks: the rows or columns
- free unit (FR): if set on track's size is set in `FR` it will grow to fill the remaining space on the parent.
- gap: the space between the rows and columns or the items on a track
## Simple interface
With the following functions you can easily set a Grid layout on any parent.
### Grid descriptors
First you need to describe the size of rows and columns. It can be done by declaring 2 arrays and the track sizes in them. The last element must be `LV_GRID_TEMPLATE_LAST`.
For example:
```
static lv_coord_t column_dsc[] = {100, 400, LV_GRID_TEMPLATE_LAST}; /*2 columns with 100 and 400 ps width*/
static lv_coord_t row_dsc[] = {100, 100, 100, LV_GRID_TEMPLATE_LAST}; /*3 100 px tall rows*/
```
To set the descriptors on a parent use `lv_obj_set_grid_dsc_array(obj, col_dsc, row_dsc)`.
Besides simple settings the size in pixel you can use two special values:
- `LV_GRID_CONTENT` set the width to the largest children on this track
- `LV_GRID_FR(X)` tell what portion of the remaining space should be used by this track. Larger value means larger space.
### Grid items
By default, the children are not added to the grid. They need to be added manually to a cell.
To do this call `lv_obj_set_grid_cell(child, column_align, column_pos, column_span, row_align, row_pos, row_span)`.
`column_align` and `row_align` determine how to align the children in its cell. The possible values are:
- `LV_GRID_ALIGN_START` means left on a horizontally and top vertically. (default)
- `LV_GRID_ALIGN_END` means right on a horizontally and bottom vertically
- `LV_GRID_ALIGN_CENTER` simply center
`colum_pos` and `row_pos` means the zero based index of the cell into the item should be placed.
`colum_span` and `row_span` means how many tracks should the item involve from the start cell. Must be &gt; 1.
### Grid align
If there are some empty space the track can be aligned several ways:
- `LV_GRID_ALIGN_START` means left on a horizontally and top vertically. (default)
- `LV_GRID_ALIGN_END` means right on a horizontally and bottom vertically
- `LV_GRID_ALIGN_CENTER` simply center
- `LV_GRID_ALIGN_SPACE_EVENLY` items are distributed so that the spacing between any two items (and the space to the edges) is equal. Not applies to `track_cross_place`.
- `LV_GRID_ALIGN_SPACE_AROUND` items are evenly distributed in the track with equal space around them.
Note that visually the spaces arent equal, since all the items have equal space on both sides.
The first item will have one unit of space against the container edge, but two units of space between the next item because that next item has its own spacing that applies. Not applies to `track_cross_place`.
- `LV_GRID_ALIGN_SPACE_BETWEEN` items are evenly distributed in the track: first item is on the start line, last item on the end line. Not applies to `track_cross_place`.
To set the track's alignment use `lv_obj_set_grid_align(obj, column_align, row_align)`.
## Style interface
All the Grid related values are style properties under the hood and you can use them similarly to any other style properties. The following Grid related style properties exist:
- `GRID_COLUMN_DSC_ARRAY`
- `GRID_ROW_DSC_ARRAY`
- `GRID_COLUMN_ALIGN`
- `GRID_ROW_ALIGN`
- `GRID_CELL_X_ALIGN`
- `GRID_CELL_COLUMN_POS`
- `GRID_CELL_COLUMN_SPAN`
- `GRID_CELL_Y_ALIGN`
- `GRID_CELL_ROW_POS`
- `GRID_CELL_ROW_SPAN`
### Internal padding
To modify the minimum space Grid inserts between objects, the following properties can be set on the Grid container style:
- `pad_row` Sets the padding between the rows.
- `pad_column` Sets the padding between the columns.
## Other features
### RTL
If the base direction of the container is set to `LV_BASE_DIR_RTL`, the meaning of `LV_GRID_ALIGN_START` and `LV_GRID_ALIGN_END` is swapped. I.e. `START` will mean right-most.
The columns will be placed from right to left.
## Example
```eval_rst
.. include:: ../../examples/layouts/grid/index.rst
```
## API
```eval_rst
.. doxygenfile:: lv_grid.h
:project: lvgl
```

View File

@ -0,0 +1,15 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/layouts/index.md
```
# Layouts
```eval_rst
.. toctree::
:maxdepth: 2
flex
grid
```

View File

@ -0,0 +1,42 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/libs/bmp.md
```
# BMP decoder
This extension allows the use of BMP images in LVGL.
This implementation uses [bmp-decoder](https://github.com/caj-johnson/bmp-decoder) library.
The pixel are read on demand (not the whole image is loaded) so using BMP images requires very little RAM.
If enabled in `lv_conf.h` by `LV_USE_BMP` LVGL will register a new image decoder automatically so BMP files can be directly used as image sources. For example:
```
lv_img_set_src(my_img, "S:path/to/picture.bmp");
```
Note that, a file system driver needs to registered to open images from files. Read more about it [here](https://docs.lvgl.io/master/overview/file-system.html) or just enable one in `lv_conf.h` with `LV_USE_FS_...`
## Limitations
- Only BMP files are supported and BMP images as C array (`lv_img_dsc_t`) are not. It's because there is no practical differences between how the BMP files and LVGL's image format stores the image data.
- BMP files can be loaded only from file. If you want to store them in flash it's better to convert them to C array with [LVGL's image converter](https://lvgl.io/tools/imageconverter).
- The BMP files color format needs to match with `LV_COLOR_DEPTH`. Use GIMP to save the image in the required format.
Both RGB888 and ARGB888 works with `LV_COLOR_DEPTH 32`
- Palette is not supported.
- Because not the whole image is read in can not be zoomed or rotated.
## Example
```eval_rst
.. include:: ../../examples/libs/bmp/index.rst
```
## API
```eval_rst
.. doxygenfile:: lv_bmp.h
:project: lvgl
```

View File

@ -0,0 +1,39 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/libs/bmp.md
```
# FreeType support
Interface to [FreeType](https://www.freetype.org/) to generate font bitmaps run time.
## Install FreeType
- Download Freetype from [here](https://sourceforge.net/projects/freetype/files/)
- `make`
- `sudo make install`
## Add FreeType to your project
- Add include path: `/usr/include/freetype2` (for GCC: `-I/usr/include/freetype2 -L/usr/local/lib`)
- Add library: `freetype` (for GCC: `-L/usr/local/lib -lfreetype`)
## Usage
Enable `LV_USE_FREETYPE` in `lv_conf.h`.
See the examples below.
Note that, the FreeType extension doesn't use LVGL's file system.
You can simply pass the path to the font as usual on your operating system or platform.
## Learn more
- FreeType [tutorial](https://www.freetype.org/freetype2/docs/tutorial/step1.html)
- LVGL's [font interface](https://docs.lvgl.io/v7/en/html/overview/font.html#add-a-new-font-engine)
## API
```eval_rst
.. doxygenfile:: lv_freetype.h
:project: lvgl
```

View File

@ -0,0 +1,20 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/libs/fsdrv.md
```
# File System Interfaces
LVGL has a [File system](https://docs.lvgl.io/master/overview/file-system.html) module to provides an abstraction layer for various file system drivers.
LVG has build in support for
- [FATFS](http://elm-chan.org/fsw/ff/00index_e.html)
- STDIO (Linux and Windows using C standard function .e.g fopen, fread)
- POSIX (Linux and Windows using POSIX function .e.g open, read)
- WIN32 (Windows using Win32 API function .e.g CreateFileA, ReadFile)
You still need to provide the drivers and libraries, this extensions provide only the bridge between FATFS, STDIO, POSIX, WIN32 and LVGL.
## Usage
In `lv_conf.h` set a driver letter for one or more `LV_FS_USE_...` define(s). After that you can access files using that driver letter. Setting `'\0'` will disable use of that interface.

View File

@ -0,0 +1,48 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/libs/gif.md
```
# GIF decoder
Allow to use of GIF images in LVGL. Based on https://github.com/lecram/gifdec
When enabled in `lv_conf.h` with `LV_USE_GIF` `lv_gif_create(parent)` can be used to create a gif widget.
`lv_gif_set_src(obj, src)` works very similarly to `lv_img_set_src`. As source It also accepts images as variables (`lv_img_dsc_t`) or files.
## Convert GIF files to C array
To convert a GIF file to byte values array use [LVGL's online converter](https://lvgl.io/tools/imageconverter). Select "Raw" color format and "C array" Output format.
## Use GIF images from file
For example:
```c
lv_gif_set_src(obj, "S:path/to/example.gif");
```
Note that, a file system driver needs to regsitered to open images from files. Read more about it [here](https://docs.lvgl.io/master/overview/file-system.html) or just enable one in `lv_conf.h` with `LV_USE_FS_...`
## Memory requirements
To decode and display a GIF animation the following amount of RAM is required:
- `LV_COLOR_DEPTH 8`: 3 x image width x image height
- `LV_COLOR_DEPTH 16`: 4 x image width x image height
- `LV_COLOR_DEPTH 32`: 5 x image width x image height
## Example
```eval_rst
.. include:: ../../examples/libs/gif/index.rst
```
## API
```eval_rst
.. doxygenfile:: lv_gif.h
:project: lvgl
```

View File

@ -0,0 +1,22 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/libs/index.md
```
# 3rd party libraries
```eval_rst
.. toctree::
:maxdepth: 1
fsdrv
bmp
sjpg
png
gif
freetype
qrcode
rlottie
```

View File

@ -0,0 +1,31 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/libs/png.md
```
# PNG decoder
Allow the use of PNG images in LVGL. This implementation uses [lodepng](https://github.com/lvandeve/lodepng) library.
If enabled in `lv_conf.h` by `LV_USE_PNG` LVGL will register a new image decoder automatically so PNG files can be directly used as any other image sources.
Note that, a file system driver needs to registered to open images from files. Read more about it [here](https://docs.lvgl.io/master/overview/file-system.html) or just enable one in `lv_conf.h` with `LV_USE_FS_...`
The whole PNG image is decoded so during decoding RAM equals to `image width x image height x 4` bytes are required.
As it might take significant time to decode PNG images LVGL's [images caching](https://docs.lvgl.io/master/overview/image.html#image-caching) feature can be useful.
## Example
```eval_rst
.. include:: ../../examples/libs/png/index.rst
```
## API
```eval_rst
.. doxygenfile:: lv_png.h
:project: lvgl

View File

@ -0,0 +1,42 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/libs/qrcode.md
```
# QR code
QR code generation with LVGL. Uses [QR-Code-generator](https://github.com/nayuki/QR-Code-generator) by [nayuki](https://github.com/nayuki).
## Get started
- Download or clone this repository
- [Download](https://github.com/lvgl/lv_lib_qrcode.git) from GitHub
- Clone: git clone https://github.com/lvgl/lv_lib_qrcode.git
- Include the library: `#include "lv_lib_qrcode/lv_qrcode.h"`
- Test with the following code:
```c
const char * data = "Hello world";
/*Create a 100x100 QR code*/
lv_obj_t * qr = lv_qrcode_create(lv_scr_act(), 100, lv_color_hex3(0x33f), lv_color_hex3(0xeef));
/*Set data*/
lv_qrcode_update(qr, data, strlen(data));
```
## Notes
- QR codes with less data are smaller but they scaled by an integer numbers number to best fit to the given size
## Example
```eval_rst
.. include:: ../../examples/libs/qrcode/index.rst
```
## API
```eval_rst
.. doxygenfile:: lv_qrcode.h
:project: lvgl

View File

@ -0,0 +1,86 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/libs/rlottie.md
```
# Lottie player
Allows to use Lottie animations in LVGL. Taken from this [base repository](https://github.com/ValentiWorkLearning/lv_rlottie)
LVGL provides the interface to [Samsung/rlottie](https://github.com/Samsung/rlottie) library's C API. That is the actual Lottie player is not part of LVGL, it needs to be built separately.
## Build Rlottie
To build Samsung's Rlottie C++14-compatible compiler and optionally CMake 3.14 or higher is required.
To build on desktop you can follow the instrutions from Rlottie's [README](https://github.com/Samsung/rlottie/blob/master/README.md). In the most basic case it looks like this:
```
mkdir rlottie_workdir
cd rlottie_workdir
git clone https://github.com/Samsung/rlottie.git
mkdir build
cd build
cmake ../rlottie
make -j
sudo make install
```
And finally add the `-lrlottie` flag to your linker.
On embedded systems you need to take care of integrating Rlottie to the given build system.
## Usage
You can use animation from files or raw data (text). In either case first you need to enable `LV_USE_RLOTTIE` in `lv_conf.h`.
The `width` and `height` of the object be set in the *create* function and the animation will be scaled accordingly.
### Use Rlottie from file
To create a Lottie animation from file use:
```c
lv_obj_t * lottie = lv_rlottie_create_from_file(parent, width, height, "path/to/lottie.json");
```
Note that, Rlottie uses the standard STDIO C file API, so you can use the path "normally" and no LVGL specific driver letter is required.
### Use Rlottie from raw string data
`lv_example_rlottie_approve.c` contains an example animation in raw format. Instead storing the JSON string a hex array is stored for the following reasons:
- avoid escaping `"` in the JSON file
- some compilers don't support very long strings
`lvgl/scripts/filetohex.py` can be used to convert a Lottie file a hex array. E.g.:
```
./filetohex.py path/to/lottie.json > out.txt
```
To create an animation from raw data:
```c
extern const uint8_t lottie_data[];
lv_obj_t* lottie = lv_rlottie_create_from_raw(parent, width, height, (const char *)lottie_data);
```
## Getting animations
Lottie is standard and popular format so you can find many animation files on the web.
For example: https://lottiefiles.com/
You can also create your own animations with Adobe After Effects or similar software.
## Example
```eval_rst
.. include:: ../../examples/libs/rlottie/index.rst
```
## API
```eval_rst
.. doxygenfile:: lv_rlottie.h
:project: lvgl

View File

@ -0,0 +1,77 @@
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/libs/sjpg.md
```
# JPG decoder
Allow the use of JPG images in LVGL. Besides that it also allows the use of a custom format, called Split JPG (SJPG), which can be decided in more optimal way on embedded systems.
## Overview
- Supports both normal JPG and the custom SJPG formats.
- Decoding normal JPG consumes RAM with the size fo the whole uncompressed image (recommended only for devices with more RAM)
- SJPG is a custom format based on "normal" JPG and specially made for LVGL.
- SJPG is 'split-jpeg' which is a bundle of small jpeg fragments with an sjpg header.
- SJPG size will be almost comparable to the jpg file or might be a slightly larger.
- File read from file and c-array are implemented.
- SJPEG frame fragment cache enables fast fetching of lines if availble in cache.
- By default the sjpg image cache will be image width * 2 * 16 bytes (can be modified)
- Currently only 16 bit image format is supported (TODO)
- Only the required partion of the JPG and SJPG images are decoded, therefore they can't be zoomed or rotated.
## Usage
If enabled in `lv_conf.h` by `LV_USE_SJPG` LVGL will register a new image decoder automatically so JPG and SJPG files can be directly used as image sources. For example:
```
lv_img_set_src(my_img, "S:path/to/picture.jpg");
```
Note that, a file system driver needs to registered to open images from files. Read more about it [here](https://docs.lvgl.io/master/overview/file-system.html) or just enable one in `lv_conf.h` with `LV_USE_FS_...`
## Converter
### Converting JPG to C array
- Use lvgl online tool https://lvgl.io/tools/imageconverter
- Color format = RAW, output format = C Array
### Converting JPG to SJPG
python3 and the PIL library required. (PIL can be installed with `pip3 install pillow`)
To create SJPG from JPG:
- Copy the image to convert into `lvgl/scripts`
- `cd lvgl/scripts`
- `python3 jpg_to_sjpg.py image_to_convert.jpg`. It creates both a C files and an SJPG image.
The expected result is:
```sh
Conversion started...
Input:
image_to_convert.jpg
RES = 640 x 480
Output:
Time taken = 1.66 sec
bin size = 77.1 KB
walpaper.sjpg (bin file)
walpaper.c (c array)
All good!
```
## Example
```eval_rst
.. include:: ../../examples/libs/sjpg/index.rst
```
## API
```eval_rst
.. doxygenfile:: lv_sjpg.h
:project: lvgl

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Some files were not shown because too many files have changed in this diff Show More