Skip to content

Commit

Permalink
Rename chunk to bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
higaski committed Nov 14, 2023
1 parent 65c3918 commit 0653fb5
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 122 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

##
- Changes to namespace dcc::tx
- Rename raw2timings to bytes2timings
- Rename CrtpBase::raw to CrtpBase::bytes

## 0.30.0
- Use 'speed' instead of 'notch'
- Update to ZTL 0.18.0
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ The DCC protocol is defined by various standards published by the [National Mode

### Transmitter
- Configurable preamble, bit durations and BiDi cutout
- Supports user-defined packets and transmission of raw data
- Supports user-defined packets and transmission of raw bytes

### ESP32 RMT encoder
- Configurable preamble, bit durations and BiDi cutout
- Only supports transmission of raw data
- Only supports transmission of raw bytes

## Getting started
### Prerequisites
Expand Down Expand Up @@ -191,7 +191,7 @@ private:
// Set direction (1 forward, -1 backward)
void direction(uint32_t addr, int32_t dir);

// Set speed (0-255)
// Set speed (regardless of CV settings scaled to 0-255)
void speed(uint32_t addr, int32_t speed);

// Emergency stop
Expand All @@ -207,7 +207,7 @@ private:
void serviceAck();

// Transmit BiDi
void transmitBiDi(std::span<uint8_t const> chunk);
void transmitBiDi(std::span<uint8_t const> bytes);

// Read CV
uint8_t readCv(uint32_t cv_addr, uint8_t byte = 0u);
Expand Down
4 changes: 2 additions & 2 deletions examples/repl/decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Decoder : dcc::rx::CrtpBase<Decoder> {
// Set direction (1 forward, -1 backward)
void direction(uint32_t addr, int32_t dir);

// Set speed (0-255)
// Set speed (regardless of CV settings scaled to 0-255)
void speed(uint32_t addr, int32_t speed);

// Emergency stop
Expand All @@ -28,7 +28,7 @@ struct Decoder : dcc::rx::CrtpBase<Decoder> {
void serviceAck();

// Transmit BiDi
void transmitBiDi(std::span<uint8_t const> chunk);
void transmitBiDi(std::span<uint8_t const> bytes);

// Read CV
uint8_t readCv(uint32_t cv_addr, uint8_t byte = 0u);
Expand Down
10 changes: 5 additions & 5 deletions include/dcc/crc8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ constexpr uint8_t crc8(uint8_t byte) { return detail::crc8_lut[byte]; }
/// This function calculates CRC8 (Dallas/Maxim). The polynomial representations
/// is 0x31.
///
/// \param chunk Chunk to calculate CRC8 for
/// \param bytes Bytes to calculate CRC8 for
/// \return CRC8
constexpr uint8_t crc8(std::span<uint8_t const> chunk) {
constexpr uint8_t crc8(std::span<uint8_t const> bytes) {
return std::accumulate(
cbegin(chunk),
cend(chunk),
cbegin(bytes),
cend(bytes),
static_cast<uint8_t>(0u),
[](uint8_t a, uint8_t b) { return crc8(static_cast<uint8_t>(a ^ b)); });
}

/// This function calculates CRC8 (Dallas/Maxim). The polynomial representations
/// is 0x31.
///
/// \param chunk Chunk to calculate CRC8 for
/// \param bytes Bytes to calculate CRC8 for
/// \return CRC8
constexpr uint8_t crc8(Packet const& packet) {
// Packet checksum is not part of CRC
Expand Down
8 changes: 4 additions & 4 deletions include/dcc/exor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ namespace dcc {

/// Exclusive disjunction (ex-or)
///
/// \param chunk Chunk to calculate ex-or for
/// \param bytes Bytes to calculate ex-or for
/// \return Ex-or
constexpr uint8_t exor(std::span<uint8_t const> chunk) {
return std::accumulate(cbegin(chunk),
cend(chunk),
constexpr uint8_t exor(std::span<uint8_t const> bytes) {
return std::accumulate(cbegin(bytes),
cend(bytes),
static_cast<uint8_t>(0u),
[](uint8_t a, uint8_t b) { return a ^ b; });
}
Expand Down
Loading

0 comments on commit 0653fb5

Please sign in to comment.