From 31ae2b66643aee9e7efa67a4000a9254961389ef Mon Sep 17 00:00:00 2001 From: Robin Dietzel Date: Fri, 13 Jan 2023 14:58:47 +0100 Subject: [PATCH] FEATURE: Added format lib --- CMakeLists.txt | 6 +++++- Core/Inc/git_rev.h | 2 +- Core/Src/main.cpp | 4 +++- Lib/fmt | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) create mode 160000 Lib/fmt diff --git a/CMakeLists.txt b/CMakeLists.txt index 66980c4..78e80c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.2) # specify cross-compilers and tools set(CMAKE_C_COMPILER arm-none-eabi-gcc) set(CMAKE_CXX_COMPILER arm-none-eabi-g++) -set(CMAKE_ASM_COMPILER arm-none-eabi-gcc) +set(CMAKE_ASM_COMPILER arm-none-eabi-gcc) set(CMAKE_AR arm-none-eabi-ar) set(CMAKE_OBJCOPY arm-none-eabi-objcopy) set(CMAKE_OBJDUMP arm-none-eabi-objdump) @@ -59,6 +59,8 @@ else () add_compile_options(-Og -g) endif () +add_subdirectory(Lib/fmt) + include_directories(USB_DEVICE/App USB_DEVICE/Target Core/Inc Drivers/STM32F4xx_HAL_Driver/Inc Drivers/STM32F4xx_HAL_Driver/Inc/Legacy Middlewares/ST/STM32_USB_Device_Library/Core/Inc Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc Drivers/CMSIS/Device/ST/STM32F4xx/Include Drivers/CMSIS/Include Middlewares/floatpump/Inc) add_definitions(-DDEBUG -DUSE_HAL_DRIVER -DSTM32F411xE) @@ -73,6 +75,8 @@ add_link_options(-T ${LINKER_SCRIPT}) add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT}) +target_link_libraries(${PROJECT_NAME}.elf fmt::fmt-header-only) + set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex) set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin) diff --git a/Core/Inc/git_rev.h b/Core/Inc/git_rev.h index e41d05a..8918131 100644 --- a/Core/Inc/git_rev.h +++ b/Core/Inc/git_rev.h @@ -7,6 +7,6 @@ // Auto generated header file containing the last git revision -#define GIT_HASH "ed9a66b" +#define GIT_HASH "e0a068f" #endif //FLOATPUMP_GIT_REVISION_TEMPLATE_H \ No newline at end of file diff --git a/Core/Src/main.cpp b/Core/Src/main.cpp index f839016..a641658 100644 --- a/Core/Src/main.cpp +++ b/Core/Src/main.cpp @@ -2,6 +2,8 @@ #include "usb_device.h" #include "usbd_cdc_if.h" +#include "fmt/core.h" + #include "LCD_I2C_Driver.h" #include "InitSequence.h" @@ -288,7 +290,7 @@ int main(void) { display.LCDSetCursor(0, 3); if (S_refillcooldown > 0) { - display.LCDSendCString(const_cast(std::string("Cooldown: " + std::to_string(S_refillcooldown / 60) + "min").c_str())); + display.LCDSendCString(const_cast(fmt::format("Nsp. wartet: {:3} min", S_refillcooldown / 60).c_str())); } else if (S_refillempty) { display.LCDSendCString(const_cast(std::string("Nachspeisung mangel ").c_str())); HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET); diff --git a/Lib/fmt b/Lib/fmt new file mode 160000 index 0000000..676c2a1 --- /dev/null +++ b/Lib/fmt @@ -0,0 +1 @@ +Subproject commit 676c2a107e9575663f79095d9b2c9d15168e1285