Skip to content

Commit

Permalink
feat: remove optional MDU entry
Browse files Browse the repository at this point in the history
  • Loading branch information
higaski committed Mar 26, 2024
1 parent 2da5ae8 commit fb9c57d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Language: Cpp
# BasedOnStyle: LLVM
# BasedOnStyle: terser LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(uint8_t)> cb);
Expand All @@ -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<int32_t> dir);

// MDU entry with CV verify
void mduEntry(uint32_t cv_addr, uint8_t byte);
```
### Transmitter
Expand Down
14 changes: 4 additions & 10 deletions include/dcc/rx/crtp_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -313,7 +312,7 @@ struct CrtpBase : bidi::CrtpBase<T> {
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;
}
Expand Down Expand Up @@ -559,20 +558,15 @@ struct CrtpBase : bidi::CrtpBase<T> {

/// Execute configuration variable access - long form
///
/// \param bytes Raw bytes
/// \param broadcast Indicate whether packet is broadcast
void cvLong(std::span<uint8_t const> bytes, bool broadcast = false) {
/// \param bytes Raw bytes
void cvLong(std::span<uint8_t const> bytes) {
switch (uint32_t const cv_addr{(bytes[0uz] & 0b11u) << 8u | bytes[1uz]};
static_cast<uint32_t>(bytes[0uz]) >> 2u & 0b11u) {
// Reserved
case 0b00u: break;

// Verify byte
case 0b01u:
if constexpr (MduEntry<T>)
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:
Expand Down
23 changes: 0 additions & 23 deletions include/dcc/rx/mdu_entry.hpp

This file was deleted.

0 comments on commit fb9c57d

Please sign in to comment.