Description
I need to display some text on a screen (no touch, or user interaction this will be a dashboard).
I have a working proof of concept using montserrat_48
, but I need it to be really big (200px high) and montserrat_48
won’t do.
I’m trying to add freetype to the project but it won’t build (more info below).
What MCU/Processor/Board and compiler are you using?
ESP32
, using the esp-idf v5.1.1
framework
LVGL v8.3.*
was added to the project using the idf component manager.
The compiler is xtensa-esp32-elf-gcc
What do you want to achieve?
I’m trying to use the freetype espressif component, but I can’t make it build.
What have you tried so far?
I have added the exemple found in the doc.
I have installed the freetype component maintained by espressif (found here).
I did NOT install freetype on my computer nor added it to my project since the targetted platform is esp32 and not my computer. Also I don’t know where to add the include path and library to an esp-idf project.
Code to reproduce
# /main/idf_component.yml
dependencies:
idf:
version: ">=5.1.0"
# Espressif
freetype: "^2.13.0"
# 3rd party
lvgl/lvgl: ">=8.3.0"
# /main/CMakeLists.txt
set(srcs "test_lvgl.c")
idf_component_register(
SRCS ${srcs}
INCLUDE_DIRS "." # "../managed_components/espressif__freetype/freetype/include"
# optional, add here private include directories
PRIV_INCLUDE_DIRS
# optional, list the public requirements (component names)
REQUIRES esp_timer driver freetype vs23 lvgl
# optional, list the private requirements
PRIV_REQUIRES
)
/* /main/test_lvgl.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "driver/gpio.h"
#include "driver/spi_common.h"
#include "driver/spi_master.h"
#include "soc/spi_pins.h"
#include "freertos/task.h"
#include "lv_examples.h"
#include "vs23_driver.h"
#include "vs23_lvgl.h"
#include "lvgl.h"
#define WIDTH 200
#define HEIGHT 200
#if LV_BUILD_EXAMPLES
#if LV_USE_FREETYPE
/**
* Load a font with FreeType
*/
void lv_example_freetype_1(void)
{
/*Create a font*/
static lv_ft_info_t info;
/*FreeType uses C standard file system, so no driver letter is required.*/
info.name = "./lvgl/examples/libs/freetype/Lato-Regular.ttf";
info.weight = 24;
info.style = FT_FONT_STYLE_NORMAL;
info.mem = NULL;
if(!lv_ft_font_init(&info)) {
LV_LOG_ERROR("create failed.");
}
/*Create style with the new font*/
static lv_style_t style;
lv_style_init(&style);
lv_style_set_text_font(&style, info.font);
lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER);
/*Create a label with the new style*/
lv_obj_t * label = lv_label_create(lv_scr_act());
lv_obj_add_style(label, &style, 0);
lv_label_set_text(label, "Hello world\nI'm a font created with FreeType");
lv_obj_center(label);
}
#else
void lv_example_freetype_1(void)
{
/*TODO
*fallback for online examples*/
lv_obj_t * label = lv_label_create(lv_scr_act());
lv_label_set_text(label, "FreeType is not installed");
lv_obj_center(label);
}
#endif
#endif
void app_main(void) {
spi_bus_config_t buscfg = use_esp32_spi3_iomux_pins();
vs23_init_spi(
SPI3_HOST,
&buscfg,
SPI_DMA_CH_AUTO,
SPI3_IOMUX_PIN_NUM_CS
);
video_config_t video_config = {
.ops_register =
VS23_IC1_DISABLED |
VS23_IC2_DISABLED |
VS23_IC3_DISABLED,
.flags =
VS23_VIDEO_CONTROL1_SELECT_PLL_CLOCK |
VS23_VIDEO_CONTROL1_PLL_ENABLED,
.width = WIDTH, //430 works, but we need a multiple of 4
.height = HEIGHT, //260 works
.pllclks_per_pixel = 4,
.bits_per_pixel = 8,
.program = {
.op_1 = PICK_B + PICK_BITS(2) + SHIFT_BITS(2),
.op_2 = PICK_A + PICK_BITS(2) + SHIFT_BITS(2),
.op_3 = PICK_Y + PICK_BITS(4) + SHIFT_BITS(4),
.op_4 = PICK_NOTHING,
}
};
vs23_progressive_pal(&video_config);
lv_disp_t* disp = vs23_lv_init(video_config.width, video_config.height);
lv_obj_t *scr = lv_disp_get_scr_act(disp);
lv_example_freetype_1();
vs23_enter_fast_write_mode();
vs23_lv_start();
}
At compilation the following error messages occurs:
Executing action: all (aliases: build)
Running ninja in directory /mnt/src/esp_idf/vs23_driver/build
Executing "ninja all"...
[1/290] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/others/fragment/lv_fragment.c.obj
[2/290] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/others/fragment/lv_fragment_manager.c.obj
[3/290] Performing build step for 'bootloader'
[1/1] cd /mnt/src/esp_idf/vs23_driver/build/bootloader/esp-idf/esptool_py && /home/eric/.espressif/python_env/idf5.1_py3.11_env/bin/python /home/eric/esp/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 /mnt/src/esp_idf/vs23_driver/build/bootloader/bootloader.bin
Bootloader binary size 0x6ee0 bytes. 0x120 bytes (1%) free.
[4/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/others/gridnav/lv_gridnav.c.obj
[5/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/others/msg/lv_msg.c.obj
[6/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/others/snapshot/lv_snapshot.c.obj
[7/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/others/ime/lv_ime_pinyin.c.obj
[8/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/lv_extra.c.obj
[9/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/others/monkey/lv_monkey.c.obj
[10/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/libs/freetype/lv_freetype.c.obj
FAILED: esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/libs/freetype/lv_freetype.c.obj
/home/eric/.espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -DESP_PLATFORM -DIDF_VER=\"v5.1.1-233-gf0437b945f-dirty\" -DLV_CONF_INCLUDE_SIMPLE -DSOC_MMU_PAGE_SIZE=CONFIG_MMU_PAGE_SIZE -D_GNU_SOURCE -D_POSIX_READER_WRITER_LOCKS -I/mnt/src/esp_idf/vs23_driver/build/config -I/mnt/src/esp_idf/vs23_driver/managed_components/lvgl__lvgl -I/mnt/src/esp_idf/vs23_driver/managed_components/lvgl__lvgl/src -I/mnt/src/esp_idf/vs23_driver/managed_components -I/mnt/src/esp_idf/vs23_driver/managed_components/lvgl__lvgl/examples -I/mnt/src/esp_idf/vs23_driver/managed_components/lvgl__lvgl/demos -I/home/eric/esp/esp-idf/components/newlib/platform_include -I/home/eric/esp/esp-idf/components/freertos/FreeRTOS-Kernel/include -I/home/eric/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include -I/home/eric/esp/esp-idf/components/freertos/esp_additions/include/freertos -I/home/eric/esp/esp-idf/components/freertos/esp_additions/include -I/home/eric/esp/esp-idf/components/freertos/esp_additions/arch/xtensa/include -I/home/eric/esp/esp-idf/components/esp_hw_support/include -I/home/eric/esp/esp-idf/components/esp_hw_support/include/soc -I/home/eric/esp/esp-idf/components/esp_hw_support/include/soc/esp32 -I/home/eric/esp/esp-idf/components/esp_hw_support/port/esp32/. -I/home/eric/esp/esp-idf/components/esp_hw_support/port/esp32/private_include -I/home/eric/esp/esp-idf/components/heap/include -I/home/eric/esp/esp-idf/components/log/include -I/home/eric/esp/esp-idf/components/soc/include -I/home/eric/esp/esp-idf/components/soc/esp32 -I/home/eric/esp/esp-idf/components/soc/esp32/include -I/home/eric/esp/esp-idf/components/hal/esp32/include -I/home/eric/esp/esp-idf/components/hal/include -I/home/eric/esp/esp-idf/components/hal/platform_port/include -I/home/eric/esp/esp-idf/components/esp_rom/include -I/home/eric/esp/esp-idf/components/esp_rom/include/esp32 -I/home/eric/esp/esp-idf/components/esp_rom/esp32 -I/home/eric/esp/esp-idf/components/esp_common/include -I/home/eric/esp/esp-idf/components/esp_system/include -I/home/eric/esp/esp-idf/components/esp_system/port/soc -I/home/eric/esp/esp-idf/components/esp_system/port/include/private -I/home/eric/esp/esp-idf/components/xtensa/include -I/home/eric/esp/esp-idf/components/xtensa/esp32/include -I/home/eric/esp/esp-idf/components/lwip/include -I/home/eric/esp/esp-idf/components/lwip/include/apps -I/home/eric/esp/esp-idf/components/lwip/include/apps/sntp -I/home/eric/esp/esp-idf/components/lwip/lwip/src/include -I/home/eric/esp/esp-idf/components/lwip/port/include -I/home/eric/esp/esp-idf/components/lwip/port/freertos/include -I/home/eric/esp/esp-idf/components/lwip/port/esp32xx/include -I/home/eric/esp/esp-idf/components/lwip/port/esp32xx/include/arch -I/home/eric/esp/esp-idf/components/esp_timer/include -mlongcalls -Wno-frame-address -fdiagnostics-color=always -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-enum-conversion -gdwarf-4 -ggdb -Og -fmacro-prefix-map=/mnt/src/esp_idf/vs23_driver=. -fmacro-prefix-map=/home/eric/esp/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -DconfigENABLE_FREERTOS_DEBUG_OCDAWARE=1 -std=gnu17 -Wno-old-style-declaration -MD -MT esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/libs/freetype/lv_freetype.c.obj -MF esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/libs/freetype/lv_freetype.c.obj.d -o esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/libs/freetype/lv_freetype.c.obj -c /mnt/src/esp_idf/vs23_driver/managed_components/lvgl__lvgl/src/extra/libs/freetype/lv_freetype.c
/mnt/src/esp_idf/vs23_driver/managed_components/lvgl__lvgl/src/extra/libs/freetype/lv_freetype.c:12:10: fatal error: ft2build.h: No such file or directory
12 | #include "ft2build.h"
| ^~~~~~~~~~~~
compilation terminated.
[11/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/others/imgfont/lv_imgfont.c.obj
[12/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/widgets/calendar/lv_calendar_header_arrow.c.obj
[13/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/themes/basic/lv_theme_basic.c.obj
[14/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/widgets/calendar/lv_calendar_header_dropdown.c.obj
[15/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/widgets/keyboard/lv_keyboard.c.obj
[16/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/widgets/animimg/lv_animimg.c.obj
[17/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/widgets/calendar/lv_calendar.c.obj
[18/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/themes/mono/lv_theme_mono.c.obj
[19/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/widgets/imgbtn/lv_imgbtn.c.obj
[20/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/themes/default/lv_theme_default.c.obj
[21/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/widgets/colorwheel/lv_colorwheel.c.obj
[22/288] Linking CXX static library esp-idf/espressif__freetype/output/libfreetype.a
[23/288] Building C object esp-idf/lvgl__lvgl/CMakeFiles/__idf_lvgl__lvgl.dir/src/extra/widgets/chart/lv_chart.c.obj
ninja: build stopped: subcommand failed.
e[0;33mMissing "ft2build.h" file name found in the following component(s): espressif__freetype(/mnt/src/esp_idf/vs23_driver/managed_components/espressif__freetype/freetype/devel/ft2build.h), espressif__freetype(/mnt/src/esp_idf/vs23_driver/managed_components/espressif__freetype/freetype/include/ft2build.h). Maybe one of the components needs to add the missing header directory to INCLUDE_DIRS of idf_component_register call in CMakeLists.txt.e[0m
ninja failed with exit code 1, output of the command is in the /mnt/src/esp_idf/vs23_driver/build/log/idf_py_stderr_output_18408 and /mnt/src/esp_idf/vs23_driver/build/log/idf_py_stdout_output_18408
ft2build.h
exist in the directory /mnt/src/esp_idf/vs23_driver/managed_components/espressif__freetype/freetype/include
I’m a total newbie about C and esp-idf build systems, if anyone can provide insight, I would be appreciated.