Skip to content
Open
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ target_compile_options(daisy PRIVATE
)

set_target_properties(daisy PROPERTIES
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED
C_STANDARD 11
C_STANDARD_REQUIRED
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ CPPFLAGS += \
-fno-rtti

C_STANDARD = -std=gnu11
CPP_STANDARD += -std=gnu++14
CPP_STANDARD += -std=gnu++17

# default action: build all
all: $(BUILD_DIR)/$(TARGET).a
Expand Down
2 changes: 1 addition & 1 deletion cmake/DaisyProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ target_link_libraries(${FIRMWARE_NAME}
)

set_target_properties(${FIRMWARE_NAME} PROPERTIES
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
SUFFIX ".elf"
LINK_DEPENDS ${LINKER_SCRIPT}
Expand Down
2 changes: 1 addition & 1 deletion core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ CPPFLAGS += \
-Wno-register

C_STANDARD = -std=gnu11
CPP_STANDARD ?= -std=gnu++14
CPP_STANDARD ?= -std=gnu++17


#######################################
Expand Down
12 changes: 3 additions & 9 deletions src/dev/leddriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifdef __cplusplus

#include <stdint.h>
#include <algorithm>
#include "per/i2c.h"
#include "per/gpio.h"

Expand Down Expand Up @@ -87,7 +88,7 @@ class LedDriverPca9685
void SetAllTo(float brightness)
{
const uint8_t intBrightness
= (uint8_t)(clamp(brightness * 255.0f, 0.0f, 255.0f));
= (uint8_t)(std::clamp(brightness * 255.0f, 0.0f, 255.0f));
SetAllTo(intBrightness);
}

Expand All @@ -109,7 +110,7 @@ class LedDriverPca9685
void SetLed(int ledIndex, float brightness)
{
const uint8_t intBrightness
= (uint8_t)(clamp(brightness * 255.0f, 0.0f, 255.0f));
= (uint8_t)(std::clamp(brightness * 255.0f, 0.0f, 255.0f));
SetLed(ledIndex, intBrightness);
}

Expand Down Expand Up @@ -252,13 +253,6 @@ class LedDriverPca9685
}
}

// no std::clamp available in C++14.... remove this when C++17 is available
template <typename T>
T clamp(T in, T low, T high)
{
return (in < low) ? low : (high < in) ? high : in;
}

// an internal function to handle i2c callbacks
// called when an I2C transmission completes and the next driver must be updated
static void TxCpltCallback(void* context, I2CHandle::Result result)
Expand Down
37 changes: 10 additions & 27 deletions src/hid/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,35 +150,18 @@ class Logger
/** member variables
*/

static char tx_buff_[LOGGER_BUFFER]; /**< buffer for log data */
static size_t tx_ptr_; /**< current position in the buffer */
static size_t pc_sync_; /**< terminal synchronization state */
static LoggerImpl<dest> impl_; /**< underlying trasnfer implementation */
/** this needs to remain in SRAM to support startup-time printouts
*/
inline static char tx_buff_[LOGGER_BUFFER]; /**< buffer for log data */
inline static size_t tx_ptr_ = 0; /**< current position in the buffer */
/** start with non-blocking transfers to support startup-time printouts
*/
inline static size_t pc_sync_
= LOGGER_SYNC_OUT; /**< terminal synchronization state */
inline static LoggerImpl<dest>
impl_; /**< underlying trasnfer implementation */
};

/** @addtogroup logger_statics LoggerStaticMembers
* @brief member variable definition (could switch to inline statics in C++17)
* @{
*/

/** this needs to remain in SRAM to support startup-time printouts
*/
template <LoggerDestination dest>
char Logger<dest>::tx_buff_[LOGGER_BUFFER];

/** start with non-blocking transfers to support startup-time printouts
*/
template <LoggerDestination dest>
size_t Logger<dest>::pc_sync_ = LOGGER_SYNC_OUT;

template <LoggerDestination dest>
size_t Logger<dest>::tx_ptr_ = 0;

template <LoggerDestination dest>
LoggerImpl<dest> Logger<dest>::impl_;

/** @} */ // end logger_statics

/** Specialization for a muted log
*/
template <>
Expand Down
9 changes: 2 additions & 7 deletions src/util/FixedCapStr.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ class FixedCapStrBase

constexpr void ReverseSection(std::size_t firstIdx, std::size_t lastIdx)
{
firstIdx = clamp(firstIdx, 0, size_ - 1);
lastIdx = clamp(lastIdx, 0, size_ - 1);
firstIdx = std::clamp<std::size_t>(firstIdx, 0, size_ - 1);
lastIdx = std::clamp<std::size_t>(lastIdx, 0, size_ - 1);
while(firstIdx < lastIdx)
{
CharType tmp = buffer_[lastIdx];
Expand Down Expand Up @@ -468,11 +468,6 @@ class FixedCapStrBase
}
}

std::size_t clamp(std::size_t val, std::size_t min, std::size_t max)
{
return (val < min) ? min : ((val > max) ? max : val);
}

std::size_t size_{0};
const size_t capacity_;
CharType* buffer_;
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function(add_gtest source_file)

# Set the properties
set_target_properties(${test_name} PROPERTIES
CXX_STANDARD 14
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
C_STANDARD 11
C_STANDARD_REQUIRED YES
Expand Down
4 changes: 2 additions & 2 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ OBJECTS = $(SOURCES:$(SRC_PATH)/%.$(SRC_EXT)=$(BUILD_PATH)/%.o)
DEPS = $(OBJECTS:.o=.d)

# flags #
COMPILE_FLAGS = -std=gnu++14 -Wall -Wextra -g -Werror -pthread -DUNIT_TEST=1
COMPILE_FLAGS = -std=gnu++17 -Wall -Wextra -g -Werror -pthread -DUNIT_TEST=1
INCLUDES = -I /usr/local/include/ \
-I googletest/ \
-I googletest/googletest/ \
Expand Down Expand Up @@ -92,4 +92,4 @@ $(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_EXT)

$(BUILD_PATH)/%.o: $(SRC_PATH)/%.cc
@echo "Compiling: $< -> $@"
$(CXX) $(CXXFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@
$(CXX) $(CXXFLAGS) $(INCLUDES) -MP -MMD -c $< -o $@
Loading