diff --git a/DShotRMT.cpp b/DShotRMT.cpp index 823e67e..3998ae6 100644 --- a/DShotRMT.cpp +++ b/DShotRMT.cpp @@ -60,30 +60,34 @@ DShotRMT::DShotRMT(uint16_t pin_nr, dshot_mode_t mode, bool is_bidirectional) // Destructor for "better" code DShotRMT::~DShotRMT() { - // ...kill them all + // ...TX if (_rmt_tx_channel) { - rmt_disable(_rmt_tx_channel); - rmt_del_channel(_rmt_tx_channel); - _rmt_tx_channel = nullptr; + if (rmt_disable(_rmt_tx_channel) == DSHOT_OK) + { + rmt_del_channel(_rmt_tx_channel); + _rmt_tx_channel = nullptr; + } } - // + // ...RX if (_rmt_rx_channel) { - rmt_disable(_rmt_rx_channel); - rmt_del_channel(_rmt_rx_channel); - _rmt_rx_channel = nullptr; + if (rmt_disable(_rmt_rx_channel) == DSHOT_OK) + { + rmt_del_channel(_rmt_rx_channel); + _rmt_rx_channel = nullptr; + } } - // + // ...Encoder if (_dshot_encoder) { rmt_del_encoder(_dshot_encoder); _dshot_encoder = nullptr; } - // + // ...Buffer if (_rx_queue) { vQueueDelete(_rx_queue); @@ -91,7 +95,7 @@ DShotRMT::~DShotRMT() } } -// Initialize DShotRMT +// Init DShotRMT dshot_result_t DShotRMT::begin() { dshot_result_t result = {false, UNKNOWN_ERROR}; diff --git a/examples/dshot300/dshot300.ino b/examples/dshot300/dshot300.ino index 21f68a8..bc6524b 100644 --- a/examples/dshot300/dshot300.ino +++ b/examples/dshot300/dshot300.ino @@ -78,6 +78,9 @@ void loop() { motor01.printDShotInfo(); + USB_SERIAL.println(" "); + USB_SERIAL.println("Type 'help' to show Menu"); + // Get Motor RPM if bidirectional if (IS_BIDIRECTIONAL) { @@ -94,21 +97,21 @@ void loop() void printMenu() { USB_SERIAL.println(" "); - USB_SERIAL.println("******************************************"); - USB_SERIAL.println(" DShotRMT Demo "); - USB_SERIAL.println("******************************************"); + USB_SERIAL.println("*******************************************"); + USB_SERIAL.println(" DShotRMT Demo "); + USB_SERIAL.println("*******************************************"); USB_SERIAL.println(" - Set throttle (48 – 2047)"); USB_SERIAL.println(" 0 - Stop motor"); - USB_SERIAL.println("******************************************"); - USB_SERIAL.println(" cmd - Send DShot command (0-47)"); + USB_SERIAL.println("*******************************************"); + USB_SERIAL.println(" cmd - Send DShot command (0 - 47)"); USB_SERIAL.println(" info - Show motor info"); if (IS_BIDIRECTIONAL) { USB_SERIAL.println(" rpm - Get telemetry data"); } - USB_SERIAL.println("******************************************"); + USB_SERIAL.println("*******************************************"); USB_SERIAL.println(" h / help - Show this Menu"); - USB_SERIAL.println("******************************************"); + USB_SERIAL.println("*******************************************"); } // Helper to print command results @@ -191,8 +194,6 @@ void handleSerialInput(const String &input, uint16_t &throttle, bool &continuous dshot_result_t result = motor01.sendThrottle(throttle); printCommandResult(result, "Set Throttle " + String(throttle)); - - USB_SERIAL.println("Continuous throttle mode enabled. Send '0' to stop."); } else {