Skip to content

Precompiling lvgl drastically reduces library compile time. #64

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
libraries: |
# Install the library from the local path.
- source-path: ./
- name: lvgl
# Additional library dependencies can be listed here.
# See: https://github.com/arduino/compile-sketches#libraries
sketch-paths: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extras/build
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ This library allows you to control and interact with the 6 DOF Braccio++ robot a
* [Help Center](https://support.arduino.cc/)
* [Forum](https://forum.arduino.cc)

### How-to-update precompiled `liblvgl`
```bash
git clone https://github.com/lvgl/lvgl
git clone https://github.com/arduino-libraries/Arduino_Braccio_plusplus
cd Arduino_Braccio_plusplus/extras
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j8
```

## :bug: Bugs & Issues

If you want to report an issue with this library, you can submit it to the [issue tracker](https://github.com/arduino-libraries/Arduino_Braccio_plusplus/issues) of this repository. Remember to include as much detail as you can about your hardware set-up, code and steps for reproducing the issue. Make sure you're using an original Arduino board.
Expand Down
27 changes: 27 additions & 0 deletions extras/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
##########################################################################
cmake_minimum_required(VERSION 3.16)
##########################################################################
project(lvgl)
##########################################################################
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
##########################################################################
add_library(${PROJECT_NAME} STATIC "")
##########################################################################
set(LVGL_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../lvgl)
set(LV_CONF_DIR ${CMAKE_SOURCE_DIR}/../src)
##########################################################################
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${LVGL_ROOT_DIR} ${LV_CONF_DIR})
##########################################################################
file(GLOB_RECURSE LVGL_SOURCES ${LVGL_ROOT_DIR}/src/*.c)
target_sources(${PROJECT_NAME} PUBLIC ${LVGL_SOURCES})
##########################################################################
target_compile_options(${PROJECT_NAME} PRIVATE -mcpu=cortex-m0plus -fPIC)
##########################################################################
file(WRITE ${CMAKE_BINARY_DIR}/cp-lvgl-hdr.cmake
"file(COPY ${LVGL_ROOT_DIR}/src DESTINATION ../../src/lib/lvgl FILES_MATCHING PATTERN *.h)\n"
)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND cp ${CMAKE_BINARY_DIR}/liblvgl.a ../../src/cortex-m0plus/liblvgl.a COMMENT "Copying libvgl.a")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND cp ${LVGL_ROOT_DIR}/lvgl.h ../../src/lib/lvgl COMMENT "Copying lvgl.h")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cp-lvgl-hdr.cmake COMMENT "Copying lvgl/src/*.h")
##########################################################################
3 changes: 2 additions & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ paragraph=This library allows you to control the Arduino Braccio++ 6-DOF 2nd gen
category=Communication
url=https://github.com/arduino-libraries/Arduino_Braccio_plusplus
architectures=mbed,mbed_nano
precompiled=true
ldflags=-llvgl
includes=Braccio++.h
depends=lvgl
2 changes: 1 addition & 1 deletion src/Braccio++.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "drivers/Ticker.h"

#include "lib/TFT_eSPI/TFT_eSPI.h" // Hardware-specific library
#include <lvgl.h>
#include "lib/lvgl/lvgl.h"

#include <chrono>
using namespace std::chrono;
Expand Down
Binary file added src/cortex-m0plus/liblvgl.a
Binary file not shown.
2 changes: 1 addition & 1 deletion src/gif.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* USA.
*/

#include <lvgl.h>
#include "lib/lvgl/lvgl.h"

#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
Expand Down
138 changes: 138 additions & 0 deletions src/lib/lvgl/lvgl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/**
* @file lvgl.h
* Include all LVGL related headers
*/

#ifndef LVGL_H
#define LVGL_H

#ifdef __cplusplus
extern "C" {
#endif

/***************************
* CURRENT VERSION OF LVGL
***************************/
#define LVGL_VERSION_MAJOR 8
#define LVGL_VERSION_MINOR 3
#define LVGL_VERSION_PATCH 0
#define LVGL_VERSION_INFO "dev"

/*********************
* INCLUDES
*********************/

#include "src/misc/lv_log.h"
#include "src/misc/lv_timer.h"
#include "src/misc/lv_math.h"
#include "src/misc/lv_mem.h"
#include "src/misc/lv_async.h"
#include "src/misc/lv_anim_timeline.h"
#include "src/misc/lv_printf.h"

#include "src/hal/lv_hal.h"

#include "src/core/lv_obj.h"
#include "src/core/lv_group.h"
#include "src/core/lv_indev.h"
#include "src/core/lv_refr.h"
#include "src/core/lv_disp.h"
#include "src/core/lv_theme.h"

#include "src/font/lv_font.h"
#include "src/font/lv_font_loader.h"
#include "src/font/lv_font_fmt_txt.h"

#include "src/widgets/lv_arc.h"
#include "src/widgets/lv_btn.h"
#include "src/widgets/lv_img.h"
#include "src/widgets/lv_label.h"
#include "src/widgets/lv_line.h"
#include "src/widgets/lv_table.h"
#include "src/widgets/lv_checkbox.h"
#include "src/widgets/lv_bar.h"
#include "src/widgets/lv_slider.h"
#include "src/widgets/lv_btnmatrix.h"
#include "src/widgets/lv_dropdown.h"
#include "src/widgets/lv_roller.h"
#include "src/widgets/lv_textarea.h"
#include "src/widgets/lv_canvas.h"
#include "src/widgets/lv_switch.h"

#include "src/draw/lv_draw.h"

#include "src/lv_api_map.h"

/*-----------------
* EXTRAS
*----------------*/
#include "src/extra/lv_extra.h"

/*********************
* DEFINES
*********************/

/**********************
* TYPEDEFS
**********************/

/**********************
* GLOBAL PROTOTYPES
**********************/

/**********************
* MACROS
**********************/

/** Gives 1 if the x.y.z version is supported in the current version
* Usage:
*
* - Require v6
* #if LV_VERSION_CHECK(6,0,0)
* new_func_in_v6();
* #endif
*
*
* - Require at least v5.3
* #if LV_VERSION_CHECK(5,3,0)
* new_feature_from_v5_3();
* #endif
*
*
* - Require v5.3.2 bugfixes
* #if LV_VERSION_CHECK(5,3,2)
* bugfix_in_v5_3_2();
* #endif
*
*/
#define LV_VERSION_CHECK(x,y,z) (x == LVGL_VERSION_MAJOR && (y < LVGL_VERSION_MINOR || (y == LVGL_VERSION_MINOR && z <= LVGL_VERSION_PATCH)))

/**
* Wrapper functions for VERSION macros
*/

static inline int lv_version_major(void)
{
return LVGL_VERSION_MAJOR;
}

static inline int lv_version_minor(void)
{
return LVGL_VERSION_MINOR;
}

static inline int lv_version_patch(void)
{
return LVGL_VERSION_PATCH;
}

static inline const char *lv_version_info(void)
{
return LVGL_VERSION_INFO;
}

#ifdef __cplusplus
} /*extern "C"*/
#endif

#endif /*LVGL_H*/
Loading