diff --git a/.clang-format b/.clang-format index b13e998..0db55cb 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,6 @@ --- Language: Cpp -# BasedOnStyle: LLVM +# BasedOnStyle: terser LLVM AccessModifierOffset: -2 AlignAfterOpenBracket: Align AlignArrayOfStructures: None diff --git a/CHANGELOG.md b/CHANGELOG.md index e0a959c..8b133c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## - Limit number of preamble bits of RMT encoder to 30 - Rename dcc_encoder_config_t::cutoutbit_duration to bidibit_duration +- Remove optional mduEntry ## 0.32.0 - Individual timings for namespace dcc::rx and dcc::tx diff --git a/CMakeLists.txt b/CMakeLists.txt index 60417bc..bd8f1cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,13 +87,18 @@ endif() target_link_libraries(DCC INTERFACE static_math ZTL::ZTL) -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) +if(PROJECT_IS_TOP_LEVEL) include(CTest) + add_subdirectory(examples) + file( + DOWNLOAD + https://raw.githubusercontent.com/ZIMO-Elektronik/.clang-format/master/.clang-format + ${CMAKE_CURRENT_LIST_DIR}/.clang-format) + file(GLOB_RECURSE SRC examples/*.[ch]pp include/*.[ch]pp src/*.[ch]pp + tests/*.[ch]pp) + add_clang_format_target(DCCFormat OPTIONS -i FILES ${SRC}) endif() -if(BUILD_TESTING - AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME - AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME) - add_subdirectory(examples) +if(BUILD_TESTING) add_subdirectory(tests) endif() diff --git a/README.md b/README.md index 982adba..e00bef1 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,7 @@ Implementing the [Decoder](include/dcc/rx/decoder.hpp) concept alone is not enou ``` #### Optional -There are various optional methods that can be implemented if required. One of them are asynchronous CV methods that contain a callback as the last parameter. These methods allow to return immediately and execute the callback at a later point in time. Another addition can enable or disable high-current BiDi if the corresponding bit is set in CV29. Further extensions are things specific to [ZIMO](http://zimo.at/), such as east-west direction or the entry into the [MDU protocol](https://github.com/ZIMO-Elektronik/MDU). +There are various optional methods that can be implemented if required. One of them are asynchronous CV methods that contain a callback as the last parameter. These methods allow to return immediately and execute the callback at a later point in time. Another addition can enable or disable high-current BiDi if the corresponding bit is set in CV29. Further extensions are things specific to [ZIMO](http://zimo.at/), e.g. east-west direction. ```cpp // Read CV asynchronously void readCv(uint32_t cv_addr, uint8_t byte, std::function cb); @@ -277,9 +277,6 @@ There are various optional methods that can be implemented if required. One of t // Set east-west MAN void eastWestMan(uint32_t cv_addr, std::optional dir); - - // MDU entry with CV verify - void mduEntry(uint32_t cv_addr, uint8_t byte); ``` ### Transmitter diff --git a/include/dcc/rx/crtp_base.hpp b/include/dcc/rx/crtp_base.hpp index ad317f8..9bdb192 100644 --- a/include/dcc/rx/crtp_base.hpp +++ b/include/dcc/rx/crtp_base.hpp @@ -22,7 +22,6 @@ #include "bidi/crtp_base.hpp" #include "decoder.hpp" #include "east_west_man.hpp" -#include "mdu_entry.hpp" #include "timing.hpp" namespace dcc::rx { @@ -313,7 +312,7 @@ struct CrtpBase : bidi::CrtpBase { case Instruction::SpeedDirection: speedAndDirection(addr, bytes); break; case Instruction::FunctionGroup: functionGroup(addr, bytes); break; case Instruction::FeatureExpansion: featureExpansion(addr, bytes); break; - case Instruction::CvLong: cvLong(bytes, broadcast); break; + case Instruction::CvLong: cvLong(bytes); break; case Instruction::CvShort: cvShort(bytes); break; default: break; } @@ -559,20 +558,15 @@ struct CrtpBase : bidi::CrtpBase { /// Execute configuration variable access - long form /// - /// \param bytes Raw bytes - /// \param broadcast Indicate whether packet is broadcast - void cvLong(std::span bytes, bool broadcast = false) { + /// \param bytes Raw bytes + void cvLong(std::span bytes) { switch (uint32_t const cv_addr{(bytes[0uz] & 0b11u) << 8u | bytes[1uz]}; static_cast(bytes[0uz]) >> 2u & 0b11u) { // Reserved case 0b00u: break; // Verify byte - case 0b01u: - if constexpr (MduEntry) - if (broadcast) impl().mduEntry(cv_addr, bytes[2uz]); - verify(cv_addr, bytes[2uz]); - break; + case 0b01u: verify(cv_addr, bytes[2uz]); break; // Write byte case 0b11u: diff --git a/include/dcc/rx/mdu_entry.hpp b/include/dcc/rx/mdu_entry.hpp deleted file mode 100644 index 3427043..0000000 --- a/include/dcc/rx/mdu_entry.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at https://mozilla.org/MPL/2.0/. - -/// MDU entry -/// -/// \file dcc/rx/mdu_entry.hpp -/// \author Vincent Hamp -/// \date 29/11/2022 - -#pragma once - -#include -#include - -namespace dcc::rx { - -template -concept MduEntry = requires(T t, uint32_t addr, uint8_t byte) { - { t.mduEntry(addr, byte) } -> std::same_as; -}; - -} // namespace dcc::rx \ No newline at end of file