...cosmetics

This commit is contained in:
Wastl Kraus 2025-09-05 23:28:08 +02:00
parent 31b3dbdf56
commit cfca2de4e9
2 changed files with 25 additions and 20 deletions

View File

@ -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);
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);
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};

View File

@ -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("*******************************************");
USB_SERIAL.println(" DShotRMT Demo ");
USB_SERIAL.println("******************************************");
USB_SERIAL.println("*******************************************");
USB_SERIAL.println(" <value> - Set throttle (48 2047)");
USB_SERIAL.println(" 0 - Stop motor");
USB_SERIAL.println("******************************************");
USB_SERIAL.println("*******************************************");
USB_SERIAL.println(" cmd <number> - 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
{