From 287399f9932eb5562917c3fc4986cc65bec7fed2 Mon Sep 17 00:00:00 2001 From: JF002 Date: Tue, 1 Jun 2021 21:01:32 +0200 Subject: [PATCH 1/4] Navigation app: reduce memory usage (#362) * Navigation app: - Renaming and reformatting according to coding conventions - declare iconMap as constexpr and use char* instead of std::string This reduces the flash usage from 424644B to 419344B (-5300B)! --- src/displayapp/screens/Navigation.cpp | 137 +++++++++++++++++++++----- src/displayapp/screens/Navigation.h | 101 +------------------ 2 files changed, 118 insertions(+), 120 deletions(-) diff --git a/src/displayapp/screens/Navigation.cpp b/src/displayapp/screens/Navigation.cpp index b5ce8b83..79b04e21 100644 --- a/src/displayapp/screens/Navigation.cpp +++ b/src/displayapp/screens/Navigation.cpp @@ -24,6 +24,106 @@ using namespace Pinetime::Applications::Screens; LV_FONT_DECLARE(lv_font_navi_80) +namespace { + constexpr std::array, 86> m_iconMap = {{ + {"arrive-left", "\xEE\xA4\x81"}, + {"arrive-right", "\xEE\xA4\x82"}, + {"arrive-straight", "\xEE\xA4\x80"}, + {"arrive", "\xEE\xA4\x80"}, + {"close", "\xEE\xA4\x83"}, + {"continue-left", "\xEE\xA4\x85"}, + {"continue-right", "\xEE\xA4\x86"}, + {"continue-slight-left", "\xEE\xA4\x87"}, + {"continue-slight-right", "\xEE\xA4\x88"}, + {"continue-straight", "\xEE\xA4\x84"}, + {"continue-uturn", "\xEE\xA4\x89"}, + {"continue", "\xEE\xA4\x84"}, + {"depart-left", "\xEE\xA4\x8B"}, + {"depart-right", "\xEE\xA4\x8C"}, + {"depart-straight", "\xEE\xA4\x8A"}, + {"end-of-road-left", "\xEE\xA4\x8D"}, + {"end-of-road-right", "\xEE\xA4\x8E"}, + {"ferry", "\xEE\xA4\x8F"}, + {"flag", "\xEE\xA4\x90"}, + {"fork-left", "\xEE\xA4\x92"}, + {"fork-right", "\xEE\xA4\x93"}, + {"fork-slight-left", "\xEE\xA4\x94"}, + {"fork-slight-right", "\xEE\xA4\x95"}, + {"fork-straight", "\xEE\xA4\x96"}, + {"invalid", "\xEE\xA4\x84"}, + {"invalid-left", "\xEE\xA4\x85"}, + {"invalid-right", "\xEE\xA4\x86"}, + {"invalid-slight-left", "\xEE\xA4\x87"}, + {"invalid-slight-right", "\xEE\xA4\x88"}, + {"invalid-straight", "\xEE\xA4\x84"}, + {"invalid-uturn", "\xEE\xA4\x89"}, + {"merge-left", "\xEE\xA4\x97"}, + {"merge-right", "\xEE\xA4\x98"}, + {"merge-slight-left", "\xEE\xA4\x99"}, + {"merge-slight-right", "\xEE\xA4\x9A"}, + {"merge-straight", "\xEE\xA4\x84"}, + {"new-name-left", "\xEE\xA4\x85"}, + {"new-name-right", "\xEE\xA4\x86"}, + {"new-name-sharp-left", "\xEE\xA4\x9B"}, + {"new-name-sharp-right", "\xEE\xA4\x9C"}, + {"new-name-slight-left", "\xEE\xA4\x87"}, + {"new-name-slight-right", "\xEE\xA4\x88"}, + {"new-name-straight", "\xEE\xA4\x84"}, + {"notification-left", "\xEE\xA4\x85"}, + {"notification-right", "\xEE\xA4\x86"}, + {"notification-sharp-left", "\xEE\xA4\x9B"}, + {"notification-sharp-right", "\xEE\xA4\xA5"}, + {"notification-slight-left", "\xEE\xA4\x87"}, + {"notification-slight-right", "\xEE\xA4\x88"}, + {"notification-straight", "\xEE\xA4\x84"}, + {"off-ramp-left", "\xEE\xA4\x9D"}, + {"off-ramp-right", "\xEE\xA4\x9E"}, + {"off-ramp-slight-left", "\xEE\xA4\x9F"}, + {"off-ramp-slight-right", "\xEE\xA4\xA0"}, + {"on-ramp-left", "\xEE\xA4\x85"}, + {"on-ramp-right", "\xEE\xA4\x86"}, + {"on-ramp-sharp-left", "\xEE\xA4\x9B"}, + {"on-ramp-sharp-right", "\xEE\xA4\xA5"}, + {"on-ramp-slight-left", "\xEE\xA4\x87"}, + {"on-ramp-slight-right", "\xEE\xA4\x88"}, + {"on-ramp-straight", "\xEE\xA4\x84"}, + {"rotary", "\xEE\xA4\xA1"}, + {"rotary-left", "\xEE\xA4\xA2"}, + {"rotary-right", "\xEE\xA4\xA3"}, + {"rotary-sharp-left", "\xEE\xA4\xA4"}, + {"rotary-sharp-right", "\xEE\xA4\xA5"}, + {"rotary-slight-left", "\xEE\xA4\xA6"}, + {"rotary-slight-right", "\xEE\xA4\xA7"}, + {"rotary-straight", "\xEE\xA4\xA8"}, + {"roundabout", "\xEE\xA4\xA1"}, + {"roundabout-left", "\xEE\xA4\xA2"}, + {"roundabout-right", "\xEE\xA4\xA3"}, + {"roundabout-sharp-left", "\xEE\xA4\xA4"}, + {"roundabout-sharp-right", "\xEE\xA4\xA5"}, + {"roundabout-slight-left", "\xEE\xA4\xA6"}, + {"roundabout-slight-right", "\xEE\xA4\xA7"}, + {"roundabout-straight", "\xEE\xA4\xA8"}, + {"turn-left", "\xEE\xA4\x85"}, + {"turn-right", "\xEE\xA4\x86"}, + {"turn-sharp-left", "\xEE\xA4\x9B"}, + {"turn-sharp-right", "\xEE\xA4\xA5"}, + {"turn-slight-left", "\xEE\xA4\x87"}, + {"turn-slight-right", "\xEE\xA4\x88"}, + {"turn-straight", "\xEE\xA4\x84"}, + {"updown", "\xEE\xA4\xA9"}, + {"uturn", "\xEE\xA4\x89"}, + }}; + + const char* iconForName(const std::string& icon) { + for (auto iter : m_iconMap) { + if (iter.first == icon) { + return iter.second; + } + } + return "\xEE\xA4\x90"; + } +} + /** * Navigation watchapp * @@ -68,27 +168,25 @@ Navigation::~Navigation() { } bool Navigation::Refresh() { - - if (m_flag != navService.getFlag()) { - m_flag = navService.getFlag(); - lv_label_set_text(imgFlag, iconForName(m_flag)); - // lv_img_set_src_arr(imgFlag, iconForName(m_flag)); + if (flag != navService.getFlag()) { + flag = navService.getFlag(); + lv_label_set_text(imgFlag, iconForName(flag)); } - if (m_narrative != navService.getNarrative()) { - m_narrative = navService.getNarrative(); - lv_label_set_text(txtNarrative, m_narrative.data()); + if (narrative != navService.getNarrative()) { + narrative = navService.getNarrative(); + lv_label_set_text(txtNarrative, narrative.data()); } - if (m_manDist != navService.getManDist()) { - m_manDist = navService.getManDist(); - lv_label_set_text(txtManDist, m_manDist.data()); + if (manDist != navService.getManDist()) { + manDist = navService.getManDist(); + lv_label_set_text(txtManDist, manDist.data()); } - if (m_progress != navService.getProgress()) { - m_progress = navService.getProgress(); - lv_bar_set_value(barProgress, m_progress, LV_ANIM_OFF); - if (m_progress > 90) { + if (progress != navService.getProgress()) { + progress = navService.getProgress(); + lv_bar_set_value(barProgress, progress, LV_ANIM_OFF); + if (progress > 90) { lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED); } else { lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE); @@ -98,11 +196,4 @@ bool Navigation::Refresh() { return running; } -const char* Navigation::iconForName(std::string icon) { - for (auto iter : m_iconMap) { - if (iter.first == icon) { - return iter.second; - } - } - return "\xEE\xA4\x90"; -} + diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h index 46816c33..eb7e00c4 100644 --- a/src/displayapp/screens/Navigation.h +++ b/src/displayapp/screens/Navigation.h @@ -45,103 +45,10 @@ namespace Pinetime { Pinetime::Controllers::NavigationService& navService; - std::string m_flag; - std::string m_narrative; - std::string m_manDist; - int m_progress; - - /** Watchapp */ - - const char* iconForName(std::string icon); - - std::array, 89> m_iconMap = {{ - {"arrive-left", "\xEE\xA4\x81"}, - {"arrive-right", "\xEE\xA4\x82"}, - {"arrive-straight", "\xEE\xA4\x80"}, - {"arrive", "\xEE\xA4\x80"}, - {"close", "\xEE\xA4\x83"}, - {"continue-left", "\xEE\xA4\x85"}, - {"continue-right", "\xEE\xA4\x86"}, - {"continue-slight-left", "\xEE\xA4\x87"}, - {"continue-slight-right", "\xEE\xA4\x88"}, - {"continue-straight", "\xEE\xA4\x84"}, - {"continue-uturn", "\xEE\xA4\x89"}, - {"continue", "\xEE\xA4\x84"}, - {"depart-left", "\xEE\xA4\x8B"}, - {"depart-right", "\xEE\xA4\x8C"}, - {"depart-straight", "\xEE\xA4\x8A"}, - {"end-of-road-left", "\xEE\xA4\x8D"}, - {"end-of-road-right", "\xEE\xA4\x8E"}, - {"ferry", "\xEE\xA4\x8F"}, - {"flag", "\xEE\xA4\x90"}, - {"fork-left", "\xEE\xA4\x92"}, - {"fork-right", "\xEE\xA4\x93"}, - {"fork-slight-left", "\xEE\xA4\x94"}, - {"fork-slight-right", "\xEE\xA4\x95"}, - {"fork-straight", "\xEE\xA4\x96"}, - {"invalid", "\xEE\xA4\x84"}, - {"invalid-left", "\xEE\xA4\x85"}, - {"invalid-right", "\xEE\xA4\x86"}, - {"invalid-slight-left", "\xEE\xA4\x87"}, - {"invalid-slight-right", "\xEE\xA4\x88"}, - {"invalid-straight", "\xEE\xA4\x84"}, - {"invalid-uturn", "\xEE\xA4\x89"}, - {"merge-left", "\xEE\xA4\x97"}, - {"merge-right", "\xEE\xA4\x98"}, - {"merge-slight-left", "\xEE\xA4\x99"}, - {"merge-slight-right", "\xEE\xA4\x9A"}, - {"merge-straight", "\xEE\xA4\x84"}, - {"new-name-left", "\xEE\xA4\x85"}, - {"new-name-right", "\xEE\xA4\x86"}, - {"new-name-sharp-left", "\xEE\xA4\x9B"}, - {"new-name-sharp-right", "\xEE\xA4\x9C"}, - {"new-name-slight-left", "\xEE\xA4\x87"}, - {"new-name-slight-right", "\xEE\xA4\x88"}, - {"new-name-straight", "\xEE\xA4\x84"}, - {"notification-left", "\xEE\xA4\x85"}, - {"notification-right", "\xEE\xA4\x86"}, - {"notification-sharp-left", "\xEE\xA4\x9B"}, - {"notification-sharp-right", "\xEE\xA4\xA5"}, - {"notification-slight-left", "\xEE\xA4\x87"}, - {"notification-slight-right", "\xEE\xA4\x88"}, - {"notification-straight", "\xEE\xA4\x84"}, - {"off-ramp-left", "\xEE\xA4\x9D"}, - {"off-ramp-right", "\xEE\xA4\x9E"}, - {"off-ramp-slight-left", "\xEE\xA4\x9F"}, - {"off-ramp-slight-right", "\xEE\xA4\xA0"}, - {"on-ramp-left", "\xEE\xA4\x85"}, - {"on-ramp-right", "\xEE\xA4\x86"}, - {"on-ramp-sharp-left", "\xEE\xA4\x9B"}, - {"on-ramp-sharp-right", "\xEE\xA4\xA5"}, - {"on-ramp-slight-left", "\xEE\xA4\x87"}, - {"on-ramp-slight-right", "\xEE\xA4\x88"}, - {"on-ramp-straight", "\xEE\xA4\x84"}, - {"rotary", "\xEE\xA4\xA1"}, - {"rotary-left", "\xEE\xA4\xA2"}, - {"rotary-right", "\xEE\xA4\xA3"}, - {"rotary-sharp-left", "\xEE\xA4\xA4"}, - {"rotary-sharp-right", "\xEE\xA4\xA5"}, - {"rotary-slight-left", "\xEE\xA4\xA6"}, - {"rotary-slight-right", "\xEE\xA4\xA7"}, - {"rotary-straight", "\xEE\xA4\xA8"}, - {"roundabout", "\xEE\xA4\xA1"}, - {"roundabout-left", "\xEE\xA4\xA2"}, - {"roundabout-right", "\xEE\xA4\xA3"}, - {"roundabout-sharp-left", "\xEE\xA4\xA4"}, - {"roundabout-sharp-right", "\xEE\xA4\xA5"}, - {"roundabout-slight-left", "\xEE\xA4\xA6"}, - {"roundabout-slight-right", "\xEE\xA4\xA7"}, - {"roundabout-straight", "\xEE\xA4\xA8"}, - {"turn-left", "\xEE\xA4\x85"}, - {"turn-right", "\xEE\xA4\x86"}, - {"turn-sharp-left", "\xEE\xA4\x9B"}, - {"turn-sharp-right", "\xEE\xA4\xA5"}, - {"turn-slight-left", "\xEE\xA4\x87"}, - {"turn-slight-right", "\xEE\xA4\x88"}, - {"turn-straight", "\xEE\xA4\x84"}, - {"updown", "\xEE\xA4\xA9"}, - {"uturn", "\xEE\xA4\x89"}, - }}; + std::string flag; + std::string narrative; + std::string manDist; + int progress; }; } } From c0b0f8cb732f0cd8c6a519a97f41b0ef6275a24f Mon Sep 17 00:00:00 2001 From: JF002 Date: Tue, 1 Jun 2021 21:02:15 +0200 Subject: [PATCH 2/4] Remove debug defines (DEBUG & DEBUG_NRF_USER) from the build. These debug can be useful for debugging purposes but not in production (release). (#400) This reduces the size of the binary by about 6KB! This also removes filepath that were embedded into the binary (.bin) file. --- src/CMakeLists.txt | 6 ++++-- src/FreeRTOS/port_cmsis.c | 39 +++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ccd4ce7..43608568 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -746,15 +746,17 @@ link_directories( set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wno-unknown-pragmas -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type) add_definitions(-DCONFIG_GPIO_AS_PINRESET) -add_definitions(-DDEBUG) add_definitions(-DNIMBLE_CFG_CONTROLLER) add_definitions(-DOS_CPUTIME_FREQ) add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64 -DNRF52_PAN_12 -DNRF52_PAN_58 -DNRF52_PAN_54 -DNRF52_PAN_31 -DNRF52_PAN_51 -DNRF52_PAN_36 -DNRF52_PAN_15 -DNRF52_PAN_20 -DNRF52_PAN_55 -DBOARD_PCA10040) add_definitions(-DFREERTOS) -add_definitions(-DDEBUG_NRF_USER) add_definitions(-D__STACK_SIZE=8192) add_definitions(-D__HEAP_SIZE=8192) +# NOTE : Add the following defines to enable debug mode of the NRF SDK: +#add_definitions(-DDEBUG) +#add_definitions(-DDEBUG_NRF_USER) + if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif () diff --git a/src/FreeRTOS/port_cmsis.c b/src/FreeRTOS/port_cmsis.c index d8850b52..0ccf2e27 100644 --- a/src/FreeRTOS/port_cmsis.c +++ b/src/FreeRTOS/port_cmsis.c @@ -294,6 +294,25 @@ static void vPortEnableVFP( void ) } /*-----------------------------------------------------------*/ +uint32_t ulSetInterruptMaskFromISR( void ) +{ + __asm volatile ( + " mrs r0, PRIMASK \n" + " cpsid i \n" + " bx lr " + ::: "memory" + ); +} + +void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) +{ + __asm volatile ( + " msr PRIMASK, r0 \n" + " bx lr " + ::: "memory" + ); +} + #if ( configASSERT_DEFINED == 1 ) void vPortValidateInterruptPriority( void ) @@ -354,24 +373,4 @@ static void vPortEnableVFP( void ) configASSERT( NVIC_GetPriorityGrouping() <= ulMaxPRIGROUPValue ); } -uint32_t ulSetInterruptMaskFromISR( void ) -{ - __asm volatile ( - " mrs r0, PRIMASK \n" - " cpsid i \n" - " bx lr " - ::: "memory" - ); -} -/*-----------------------------------------------------------*/ - -void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask ) -{ - __asm volatile ( - " msr PRIMASK, r0 \n" - " bx lr " - ::: "memory" - ); -} - #endif /* configASSERT_DEFINED */ From 1b6acdedc2ae892bece04479a64ad28120eced8c Mon Sep 17 00:00:00 2001 From: JF002 Date: Tue, 1 Jun 2021 21:03:01 +0200 Subject: [PATCH 3/4] Enable various compilation flags to reduce the binary size (#401) * Add the following compilation flags: * -fno-exceptions and -fno-non-call-exceptions : disable exception handling * -fno-rtti : disable run time type information (needed by dynamic_cast, for example) These flags reduce the binary size by about 100KB! Also, -fstack-usage generate debug info (not in final binary) to allow tools like Puncover to do a stack analysis. * Remove unused CMake variables in CMake_nRF5x.cmake (duplicated in src/CMakeLists.txt). Replace -O0 by -Og in DEBUG builds. This generates a smaller binary (small enough for the internal memory) that is debugger friendly. --- cmake-nRF5x/CMake_nRF5x.cmake | 15 ------- src/CMakeLists.txt | 74 +++++++++++++++++------------------ src/displayapp/DisplayApp.cpp | 2 +- 3 files changed, 38 insertions(+), 53 deletions(-) diff --git a/cmake-nRF5x/CMake_nRF5x.cmake b/cmake-nRF5x/CMake_nRF5x.cmake index ead7b9f6..c7d0a68b 100755 --- a/cmake-nRF5x/CMake_nRF5x.cmake +++ b/cmake-nRF5x/CMake_nRF5x.cmake @@ -74,21 +74,6 @@ macro(nRF5x_setup) ) endif () - set(COMMON_FLAGS "-MP -MD -mthumb -mabi=aapcs -Wall -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums ${CPU_FLAGS} -Wreturn-type -Werror=return-type") - - # compiler/assambler/linker flags - set(CMAKE_C_FLAGS "${COMMON_FLAGS}") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3") - set(CMAKE_CXX_FLAGS "${COMMON_FLAGS}") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") - set(CMAKE_ASM_FLAGS "-MP -MD -x assembler-with-cpp") - set(CMAKE_EXE_LINKER_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} ${CPU_FLAGS} -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm") - # note: we must override the default cmake linker flags so that CMAKE_C_FLAGS are not added implicitly - set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_COMPILER} -o ") - set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_C_COMPILER} -lstdc++ -o ") - # basic board definitions and drivers include_directories( "${NRF5_SDK_PATH}/components" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43608568..cd729921 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -744,7 +744,7 @@ link_directories( ) -set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wno-unknown-pragmas -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type) +set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wno-unknown-pragmas -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type -fstack-usage -fno-exceptions -fno-non-call-exceptions) add_definitions(-DCONFIG_GPIO_AS_PINRESET) add_definitions(-DNIMBLE_CFG_CONTROLLER) add_definitions(-DOS_CPUTIME_FREQ) @@ -766,10 +766,10 @@ add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES}) target_include_directories(nrf-sdk SYSTEM PUBLIC . ../) target_include_directories(nrf-sdk SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(nrf-sdk PRIVATE - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> - $<$,$>: ${COMMON_FLAGS} -O0> - $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -Og -g3> + $<$,$>: ${COMMON_FLAGS} -Os> + $<$,$>: ${COMMON_FLAGS} -Og -fno-rtti> + $<$,$>: ${COMMON_FLAGS} -Os -fno-rtti> $<$: -MP -MD -x assembler-with-cpp> ) @@ -778,10 +778,10 @@ add_library(nimble STATIC ${NIMBLE_SRC} ${TINYCRYPT_SRC}) target_include_directories(nimble SYSTEM PUBLIC . ../) target_include_directories(nimble SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(nimble PRIVATE - $<$,$>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> - $<$,$>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> - $<$,$>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> - $<$,$>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$,$>: ${COMMON_FLAGS} -Og -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$,$>: ${COMMON_FLAGS} -Os -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$,$>: ${COMMON_FLAGS} -Og -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-rtti> + $<$,$>: ${COMMON_FLAGS} -Os -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-rtti> $<$: -MP -MD -x assembler-with-cpp> ) @@ -790,10 +790,10 @@ add_library(lvgl STATIC ${LVGL_SRC}) target_include_directories(lvgl SYSTEM PUBLIC . ../) target_include_directories(lvgl SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(lvgl PRIVATE - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -Og -g3> + $<$,$>: ${COMMON_FLAGS} -Os> + $<$,$>: ${COMMON_FLAGS} -Og -g3 -fno-rtti> + $<$,$>: ${COMMON_FLAGS} -Os -fno-rtti> $<$: -MP -MD -x assembler-with-cpp> ) @@ -805,10 +805,10 @@ add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES}) set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME}) target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl) target_compile_options(${EXECUTABLE_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -Og -g3> + $<$,$>: ${COMMON_FLAGS} -Os> + $<$,$>: ${COMMON_FLAGS} -Og -g3 -fno-rtti> + $<$,$>: ${COMMON_FLAGS} -Os -fno-rtti> $<$: -MP -MD -x assembler-with-cpp> ) @@ -835,10 +835,10 @@ add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES}) target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl) set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME}) target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -Og -g3> + $<$,$>: ${COMMON_FLAGS} -Os> + $<$,$>: ${COMMON_FLAGS} -Og -g3 -fno-rtti> + $<$,$>: ${COMMON_FLAGS} -Os -fno-rtti> $<$: -MP -MD -x assembler-with-cpp> ) @@ -872,10 +872,10 @@ target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk) set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_FILE_NAME}) target_compile_definitions(${EXECUTABLE_RECOVERY_NAME} PUBLIC "PINETIME_IS_RECOVERY") target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -Og -g3> + $<$,$>: ${COMMON_FLAGS} -Os> + $<$,$>: ${COMMON_FLAGS} -Og -g3 -fno-rtti> + $<$,$>: ${COMMON_FLAGS} -Os -fno-rtti> $<$: -MP -MD -x assembler-with-cpp> ) @@ -902,10 +902,10 @@ target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk) set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}) target_compile_definitions(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC "PINETIME_IS_RECOVERY") target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -Og -g3> + $<$,$>: ${COMMON_FLAGS} -Os> + $<$,$>: ${COMMON_FLAGS} -Og -g3 -fno-rtti> + $<$,$>: ${COMMON_FLAGS} -Os -fno-rtti> $<$: -MP -MD -x assembler-with-cpp> ) @@ -939,10 +939,10 @@ add_executable(${EXECUTABLE_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE_FILES}) target_link_libraries(${EXECUTABLE_RECOVERYLOADER_NAME} nrf-sdk) set_target_properties(${EXECUTABLE_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERYLOADER_FILE_NAME}) target_compile_options(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -Og -g3> + $<$,$>: ${COMMON_FLAGS} -Os> + $<$,$>: ${COMMON_FLAGS} -Og -g3 -fno-rtti> + $<$,$>: ${COMMON_FLAGS} -Os -fno-rtti> $<$: -MP -MD -x assembler-with-cpp> ) target_include_directories(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC @@ -972,10 +972,10 @@ add_executable(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE target_link_libraries(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} nrf-sdk) set_target_properties(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}) target_compile_options(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> - $<$,$>: ${COMMON_FLAGS} -O0 -g3> - $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -Og -g3> + $<$,$>: ${COMMON_FLAGS} -Os> + $<$,$>: ${COMMON_FLAGS} -Og -g3 -fno-rtti> + $<$,$>: ${COMMON_FLAGS} -Os -fno-rtti> $<$: -MP -MD -x assembler-with-cpp> ) target_include_directories(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 419b9f6f..7b03d569 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -153,7 +153,7 @@ void DisplayApp::Refresh() { break; case Messages::TimerDone: if (currentApp == Apps::Timer) { - auto *timer = dynamic_cast(currentScreen.get()); + auto *timer = static_cast(currentScreen.get()); timer->setDone(); } else { LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down); From 79f0fcb07aa80eb70385223272e29f2ba5657bc8 Mon Sep 17 00:00:00 2001 From: JF002 Date: Tue, 1 Jun 2021 21:03:29 +0200 Subject: [PATCH 4/4] Add the maximum memory used by LVGL in SystemInfo app. This will help the developers to size the memory buffer allocated to lvgl. (#408) --- src/displayapp/screens/SystemInfo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index e4ef6911..f61d2ff1 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -175,8 +175,9 @@ std::unique_ptr SystemInfo::CreateScreen3() { "#444444 BLE MAC#\n" " %02x:%02x:%02x:%02x:%02x:%02x" "\n" - "#444444 Memory#\n" + "#444444 LVGL Memory#\n" " #444444 used# %d (%d%%)\n" + " #444444 max used# %d\n" " #444444 frag# %d%%\n" " #444444 free# %d" "\n" @@ -189,6 +190,7 @@ std::unique_ptr SystemInfo::CreateScreen3() { bleAddr[0], (int) mon.total_size - mon.free_size, mon.used_pct, + mon.max_used, mon.frag_pct, (int) mon.free_biggest_size, 0);