From 35aa4bb8d6ef86c50fda9891e93cc2c51d585ef9 Mon Sep 17 00:00:00 2001 From: Niall Cooling Date: Wed, 3 Mar 2021 15:27:32 +0000 Subject: [PATCH 1/3] Refactored src/CMakelist to support C++14 and cleanup up redundant/incorrect -std= directives --- src/CMakeLists.txt | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d21a805..2cf570be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,17 @@ cmake_minimum_required(VERSION 3.10) project(pinetime-app C CXX ASM) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_CXX_STANDARD 14) + +# set(CMAKE_GENERATOR "Unix Makefiles") +set(CMAKE_C_EXTENSIONS OFF) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + # define some variables just for this example to determine file locations set(NRF_PROJECT_NAME pinetime-app) set(NRF_BOARD pca10040) @@ -749,7 +760,7 @@ target_compile_options(nrf-sdk PRIVATE $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0> $<$,$>: ${COMMON_FLAGS} -O3> - $<$: -MP -MD -std=c99 -x assembler-with-cpp> + $<$: -MP -MD -x assembler-with-cpp> ) # NimBLE @@ -761,7 +772,7 @@ target_compile_options(nimble PRIVATE $<$,$>: ${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> - $<$: -MP -MD -std=c99 -x assembler-with-cpp> + $<$: -MP -MD -x assembler-with-cpp> ) # lvgl @@ -773,7 +784,7 @@ target_compile_options(lvgl PRIVATE $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> - $<$: -MP -MD -std=c99 -x assembler-with-cpp> + $<$: -MP -MD -x assembler-with-cpp> ) # Build autonomous binary (without support for bootloader) @@ -788,12 +799,12 @@ target_compile_options(${EXECUTABLE_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> - $<$: -MP -MD -std=c99 -x assembler-with-cpp> + $<$: -MP -MD -x assembler-with-cpp> ) set_target_properties(${EXECUTABLE_NAME} PROPERTIES SUFFIX ".out" - LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_FILE_NAME}.map" + LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_FILE_NAME}.map" CXX_STANDARD 11 C_STANDARD 99 ) @@ -820,12 +831,12 @@ target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> - $<$: -MP -MD -std=c99 -x assembler-with-cpp> + $<$: -MP -MD -x assembler-with-cpp> ) set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES SUFFIX ".out" - LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_MCUBOOT_FILE_NAME}.map" + LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_MCUBOOT_FILE_NAME}.map" CXX_STANDARD 11 C_STANDARD 99 ) @@ -849,12 +860,12 @@ target_compile_options(${EXECUTABLE_GRAPHICS_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O3> $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> - $<$: -MP -MD -std=c99 -x assembler-with-cpp> + $<$: -MP -MD -x assembler-with-cpp> ) set_target_properties(${EXECUTABLE_GRAPHICS_NAME} PROPERTIES SUFFIX ".out" - LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map" + LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map" CXX_STANDARD 11 C_STANDARD 99 ) From d34a5101584bfca81a1f00ca57e32d55b50d55e5 Mon Sep 17 00:00:00 2001 From: Niall Cooling Date: Wed, 3 Mar 2021 17:07:05 +0000 Subject: [PATCH 2/3] Moved private statics into unnamed namespace in cpp file to reduce coupling and uncessar in header --- src/displayapp/screens/Clock.cpp | 73 +++++++++++++++++--------------- src/displayapp/screens/Clock.h | 5 --- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 4b280adb..eb0e37be 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -15,6 +15,45 @@ using namespace Pinetime::Applications::Screens; +namespace { + +char const *DaysString[] = { + "", + "MONDAY", + "TUESDAY", + "WEDNESDAY", + "THURSDAY", + "FRIDAY", + "SATURDAY", + "SUNDAY" +}; + +char const *MonthsString[] = { + "", + "JAN", + "FEB", + "MAR", + "APR", + "MAY", + "JUN", + "JUL", + "AUG", + "SEP", + "OCT", + "NOV", + "DEC" +}; + +const char *MonthToString(Pinetime::Controllers::DateTime::Months month) { + return MonthsString[static_cast(month)]; +} + +const char *DayOfWeekToString(Pinetime::Controllers::DateTime::Days dayOfWeek) { + return DaysString[static_cast(dayOfWeek)]; +} + +} + static void event_handler(lv_obj_t * obj, lv_event_t event) { Clock* screen = static_cast(obj->user_data); screen->OnObjectEvent(obj, event); @@ -200,40 +239,6 @@ bool Clock::Refresh() { return running; } -const char *Clock::MonthToString(Pinetime::Controllers::DateTime::Months month) { - return Clock::MonthsString[static_cast(month)]; -} - -const char *Clock::DayOfWeekToString(Pinetime::Controllers::DateTime::Days dayOfWeek) { - return Clock::DaysString[static_cast(dayOfWeek)]; -} - -char const *Clock::DaysString[] = { - "", - "MONDAY", - "TUESDAY", - "WEDNESDAY", - "THURSDAY", - "FRIDAY", - "SATURDAY", - "SUNDAY" -}; - -char const *Clock::MonthsString[] = { - "", - "JAN", - "FEB", - "MAR", - "APR", - "MAY", - "JUN", - "JUL", - "AUG", - "SEP", - "OCT", - "NOV", - "DEC" -}; void Clock::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { if(obj == backgroundLabel) { diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index 18d70532..5e9cfeaa 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -52,11 +52,6 @@ namespace Pinetime { void OnObjectEvent(lv_obj_t *pObj, lv_event_t i); private: - static const char* MonthToString(Pinetime::Controllers::DateTime::Months month); - static const char* DayOfWeekToString(Pinetime::Controllers::DateTime::Days dayOfWeek); - static char const *DaysString[]; - static char const *MonthsString[]; - char displayedChar[5]; uint16_t currentYear = 1970; From 66e2092357d08c495e2f55763b77d8ada490ff9f Mon Sep 17 00:00:00 2001 From: Martin Hub Date: Thu, 4 Mar 2021 17:11:06 +0100 Subject: [PATCH 3/3] Add WebBLEWatch option to update time --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f0f8992d..3f89ec7d 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ As of now, here is the list of achievements of this project: - Supported by 2 companion apps (development is in progress): * [Gadgetbridge](https://codeberg.org/Freeyourgadget/Gadgetbridge/) (on Android) * [Amazfish](https://openrepos.net/content/piggz/amazfish) (on SailfishOS and Linux) + * **[Experimental]** [WebBLEWatch](https://hubmartin.github.io/WebBLEWatch/) Synchronize time directly from your web browser. [video](https://youtu.be/IakiuhVDdrY) - **[Experimental]** OTA (Over-the-air) update via BLE - **[Experimental]** Bootloader based on [MCUBoot](https://juullabs-oss.github.io/mcuboot/)