From 51bdeeedc4a19aad26549d863d2b56393b73774e Mon Sep 17 00:00:00 2001 From: Wastl Kraus Date: Tue, 5 Aug 2025 22:01:00 +0200 Subject: [PATCH] ...readablility update --- DShotRMT.cpp | 34 ++++++++++++++-------------------- DShotRMT.h | 2 ++ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/DShotRMT.cpp b/DShotRMT.cpp index 3f7a4cc..86b7fa7 100644 --- a/DShotRMT.cpp +++ b/DShotRMT.cpp @@ -64,6 +64,7 @@ bool DShotRMT::begin() return DSHOT_ERROR; } + // All good, ready return DSHOT_OK; } @@ -75,7 +76,7 @@ bool DShotRMT::setThrottle(uint16_t throttle) { return DSHOT_ERROR; } - + // dshot_packet_t packet = _buildDShotPacket(throttle); @@ -90,7 +91,7 @@ bool DShotRMT::sendDShotCommand(uint16_t command) { return DSHOT_ERROR; } - + // dshot_packet_t packet = _buildDShotPacket(command); @@ -185,27 +186,20 @@ bool DShotRMT::_initDShotEncoder() bool DShotRMT::_sendDShotFrame(const dshot_packet_t &packet) { // - if (!_timer_signal()) + if (_timer_signal()) { - return DSHOT_ERROR; + // Encodes packet directly into RMT Buffer + rmt_symbol_word_t tx_symbols[DSHOT_BITS_PER_FRAME]; + _encodeDShotFrame(packet, tx_symbols); + + // Trigger RMT Transmit + rmt_transmit(_rmt_tx_channel, _dshot_encoder, tx_symbols, DSHOT_SYMBOLS_SIZE, &_transmit_config); + + // Time Stamp + return _timer_reset(); } - // Encodes packet directly into RMT Buffer - rmt_symbol_word_t tx_symbols[DSHOT_BITS_PER_FRAME]; - _encodeDShotFrame(packet, tx_symbols); - - // Trigger RMT Transmit - if (rmt_transmit(_rmt_tx_channel, _dshot_encoder, tx_symbols, DSHOT_SYMBOLS_SIZE, &_transmit_config) != 0) - { - Serial.println("Failed to transmit DShot packet"); - return DSHOT_ERROR; - } - - // Time Stamp - _timer_reset(); - - // - return DSHOT_OK; + return DSHOT_ERROR; } // Calculates checksum for given package diff --git a/DShotRMT.h b/DShotRMT.h index 812544a..1bac776 100644 --- a/DShotRMT.h +++ b/DShotRMT.h @@ -134,4 +134,6 @@ private: bool _timer_signal(); bool _timer_reset(); + + // };