Merge pull request #8 from derdoktor667/dev

...DShot mode selection reworked and more
This commit is contained in:
Wastl Kraus 2025-07-30 14:49:25 +02:00 committed by GitHub
commit 2a34960e02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 134 additions and 141 deletions

View File

@ -12,8 +12,18 @@
// This class provides an abstraction for sending and optionally receiving DShot frames. // This class provides an abstraction for sending and optionally receiving DShot frames.
// It uses ESP32's RMT peripheral for precise timing control, including BiDirectional RX. // It uses ESP32's RMT peripheral for precise timing control, including BiDirectional RX.
DShotRMT::DShotRMT(gpio_num_t gpio, dshot_mode_t mode, bool isBidirectional, uint8_t pauseDuration) DShotRMT::DShotRMT(gpio_num_t gpio, dshot_mode_t mode, bool isBidirectional)
: _gpio(gpio), _mode(mode), _isBidirectional(isBidirectional), _pauseDuration(pauseDuration) {} : _gpio(gpio), _mode(mode), _isBidirectional(isBidirectional)
{
// Fixed Timings for compatibility
_frame_time = dshot_times.frameLength + DSHOT_SWITCH_TIME;
// DShot Frame answer padding
if (_isBidirectional)
{
_frame_time += _frame_time;
}
}
// Initializes RMT TX and RX channels and encoder configuration // Initializes RMT TX and RX channels and encoder configuration
void DShotRMT::begin() void DShotRMT::begin()
@ -25,7 +35,7 @@ void DShotRMT::begin()
.gpio_num = _gpio, .gpio_num = _gpio,
.clk_src = DSHOT_CLOCK_SRC_DEFAULT, .clk_src = DSHOT_CLOCK_SRC_DEFAULT,
.resolution_hz = DSHOT_RMT_RESOLUTION, .resolution_hz = DSHOT_RMT_RESOLUTION,
.mem_block_symbols = 64, .mem_block_symbols = DSHOT_SYMBOLS_SIZE,
}; };
if (rmt_new_rx_channel(&_rmt_rx_channel_config, &_rmt_rx_channel) != 0) if (rmt_new_rx_channel(&_rmt_rx_channel_config, &_rmt_rx_channel) != 0)
@ -33,6 +43,7 @@ void DShotRMT::begin()
Serial.println("Failed to create RX channel"); Serial.println("Failed to create RX channel");
return; return;
} }
if (rmt_enable(_rmt_rx_channel) != 0) if (rmt_enable(_rmt_rx_channel) != 0)
{ {
Serial.println("Failed to enable RX channel"); Serial.println("Failed to enable RX channel");
@ -48,12 +59,11 @@ void DShotRMT::begin()
.gpio_num = _gpio, .gpio_num = _gpio,
.clk_src = DSHOT_CLOCK_SRC_DEFAULT, .clk_src = DSHOT_CLOCK_SRC_DEFAULT,
.resolution_hz = DSHOT_RMT_RESOLUTION, .resolution_hz = DSHOT_RMT_RESOLUTION,
.mem_block_symbols = 64, .mem_block_symbols = DSHOT_SYMBOLS_SIZE,
.trans_queue_depth = 10, .trans_queue_depth = TX_BUFFER_SIZE};
};
// Transmission configuration // Transmission configuration
_transmit_config.loop_count = 0; _transmit_config.loop_count = NULL;
_transmit_config.flags.eot_level = _isBidirectional; _transmit_config.flags.eot_level = _isBidirectional;
if (rmt_new_tx_channel(&_rmt_tx_channel_config, &_rmt_tx_channel) != 0) if (rmt_new_tx_channel(&_rmt_tx_channel_config, &_rmt_tx_channel) != 0)
@ -61,6 +71,7 @@ void DShotRMT::begin()
Serial.println("Failed to create TX channel"); Serial.println("Failed to create TX channel");
return; return;
} }
if (rmt_enable(_rmt_tx_channel) != 0) if (rmt_enable(_rmt_tx_channel) != 0)
{ {
Serial.println("Failed to enable TX channel"); Serial.println("Failed to enable TX channel");
@ -82,27 +93,33 @@ void DShotRMT::begin()
// Encodes and transmits a valid DShot throttle value (48 - 2047) // Encodes and transmits a valid DShot throttle value (48 - 2047)
void DShotRMT::setThrottle(uint16_t throttle) void DShotRMT::setThrottle(uint16_t throttle)
{ {
// Clamp input range and mask to 11 bits // Simple timer
throttle = constrain(throttle, DSHOT_THROTTLE_MIN, DSHOT_THROTTLE_MAX) & 0x7FF; static unsigned long last_time = NULL;
_lastThrottle = throttle; //
dshot_packet_t packet = {};
// Convert throttle value to DShot packet format packet.throttle_value = (constrain(throttle, DSHOT_THROTTLE_MIN, DSHOT_THROTTLE_MAX) & 0b0000011111111111);
_tx_packet = assambleDShotPaket(_lastThrottle); packet.telemetric_request = _isBidirectional;
packet.checksum = calculateCRC(packet);
// Encode RMT symbols // DShot transcoding
size_t count = 0; rmt_symbol_word_t tx_symbols[DSHOT_BITS_PER_FRAME] = {};
encodeDShotTX(_tx_packet, _tx_symbols, count); encodeDShotTX(packet, tx_symbols);
// Transmit the packet // Ensure frame lenght for compatibility
if (rmt_transmit(_rmt_tx_channel, _dshot_encoder, _tx_symbols, count * sizeof(rmt_symbol_word_t), &_transmit_config) != 0) if (micros() - last_time >= _frame_time)
{ {
Serial.println("Failed to transmit DShot packet"); // Transmit the packet
return; if (rmt_transmit(_rmt_tx_channel, _dshot_encoder, tx_symbols, DSHOT_SYMBOLS_SIZE, &_transmit_config) != 0)
} {
Serial.println("Failed to transmit DShot packet");
return;
}
// Pause between frames // Timestamp
esp_rom_delay_us(_pauseDuration); last_time = micros();
}
} }
// Receives and decodes a response frame from ESC containing eRPM info // Receives and decodes a response frame from ESC containing eRPM info
@ -111,13 +128,17 @@ uint32_t DShotRMT::getERPM()
if (_isBidirectional) if (_isBidirectional)
{ {
if (_rmt_rx_channel == nullptr) if (_rmt_rx_channel == nullptr)
{
Serial.println("No bidirectional DShot support."); Serial.println("No bidirectional DShot support.");
return _last_erpm; return _last_erpm;
}
// Try to receive a new frame // Try to receive a new frame
if (!rmt_receive(_rmt_rx_channel, _rx_symbols, sizeof(_rx_symbols), &_receive_config)) if (!rmt_receive(_rmt_rx_channel, _rx_symbols, DSHOT_SYMBOLS_SIZE, &_receive_config))
{
Serial.println("No valid DShot frame received"); Serial.println("No valid DShot frame received");
return _last_erpm; return _last_erpm;
}
_last_erpm = decodeDShotRX(_rx_symbols, DSHOT_BITS_PER_FRAME); _last_erpm = decodeDShotRX(_rx_symbols, DSHOT_BITS_PER_FRAME);
return _last_erpm; return _last_erpm;
@ -138,100 +159,53 @@ uint32_t DShotRMT::getMotorRPM(uint8_t magnet_count)
} }
// Calculates CRC for DShot packet // Calculates CRC for DShot packet
uint16_t DShotRMT::calculateCRC(uint16_t dshot_packet) uint16_t DShotRMT::calculateCRC(dshot_packet_t dshot_packet)
{ {
uint16_t packet = (dshot_packet << 1) | (_isBidirectional ? 1 : 0); uint16_t crc = (dshot_packet.throttle_value << 1) | (dshot_packet.telemetric_request);
// Reset CRC container
_packet_crc = DSHOT_NULL_PACKET;
// CRC calculation for DShot (4 bits) // CRC calculation for DShot (4 bits)
_packet_crc = ((packet ^ (packet >> 4) ^ (packet >> 8)) & 0xF); dshot_packet.checksum = ((crc ^ (crc >> 4) ^ (crc >> 8)) & 0b0000000000001111);
// CRC is inverted for bidirectional DShot // CRC is inverted for bidirectional DShot
if (_isBidirectional) if (dshot_packet.telemetric_request)
_packet_crc = (~_packet_crc) & 0xF; dshot_packet.checksum = (~dshot_packet.checksum) & 0b0000000000001111;
return _packet_crc; return dshot_packet.checksum;
} }
// Assembles DShot packet (11 bit throttle + 1 bit telemetry request + 4 bit CRC) // Assembles DShot packet (11 bit throttle + 1 bit telemetry request + 4 bit CRC)
uint16_t DShotRMT::assambleDShotPaket(uint16_t value) uint16_t DShotRMT::parseDShotPacket(const dshot_packet_t dshot_packet)
{ {
uint16_t throttle = value & 0x7FF; uint16_t raw = (((dshot_packet.throttle_value << 1) | (dshot_packet.telemetric_request)) & 0b0000111111111111);
return (((raw << 4) | (dshot_packet.checksum)) & 0b1111111111111111);
// Reset packet container
_tx_packet = DSHOT_NULL_PACKET;
// Assemble raw DShot packet and add checksum
_packet_crc = calculateCRC(throttle);
_tx_packet = (throttle << 1) | (_isBidirectional ? 1 : 0);
_tx_packet = (_tx_packet << 4) | _packet_crc;
return _tx_packet;
} }
// Converts a 16-bit packet into a valid DShot frame for RMT // Converts a 16-bit packet into a valid DShot frame for RMT
void DShotRMT::encodeDShotTX(uint16_t dshot_packet, rmt_symbol_word_t *symbols, size_t &count) void DShotRMT::encodeDShotTX(dshot_packet_t dshot_packet, rmt_symbol_word_t *symbols)
{ {
count = 0; // Encoding to "raw" DShot Packet
uint16_t frame_bits = parseDShotPacket(dshot_packet);
uint32_t ticks_per_bit = 0; // Always start with the "first" bit
uint32_t ticks_zero_high = 0; size_t count = NULL;
uint32_t ticks_one_high = 0;
// Select timing based on DShot mode // Convert the parsed dshot frame to rmt_tx data
switch (_mode) for (int i = DSHOT_BITS_PER_FRAME - 1; i >= 0; i--)
{ {
case DSHOT150: bool bit = (frame_bits >> i) & 0b0000000000000001;
ticks_per_bit = 64;
ticks_zero_high = 24;
ticks_one_high = 48;
break;
case DSHOT300:
ticks_per_bit = 32;
ticks_zero_high = 12;
ticks_one_high = 24;
break;
case DSHOT600:
ticks_per_bit = 16;
ticks_zero_high = 6;
ticks_one_high = 12;
break;
case DSHOT1200:
ticks_per_bit = 8;
ticks_zero_high = 3;
ticks_one_high = 6;
break;
case DSHOT_OFF:
default:
ticks_per_bit = 0;
ticks_zero_high = 0;
ticks_one_high = 0;
break;
}
uint32_t ticks_zero_low = ticks_per_bit - ticks_zero_high;
uint32_t ticks_one_low = ticks_per_bit - ticks_one_high;
// Fill the 16 DShot bits array with selected timings
for (int i = 15; i >= 0; i--)
{
bool bit = (dshot_packet >> i) & 0x1;
if (_isBidirectional) if (_isBidirectional)
{ {
symbols[count].level0 = 0; symbols[count].level0 = 0;
symbols[count].duration0 = bit ? ticks_one_high : ticks_zero_high; symbols[count].duration0 = bit ? dshot_times.ticks_one_high : dshot_times.ticks_zero_high;
symbols[count].level1 = 1; symbols[count].level1 = 1;
symbols[count].duration1 = bit ? ticks_one_low : ticks_zero_low; symbols[count].duration1 = bit ? dshot_times.ticks_one_low : dshot_times.ticks_zero_low;
} }
else else
{ {
symbols[count].level0 = 1; symbols[count].level0 = 1;
symbols[count].duration0 = bit ? ticks_one_high : ticks_zero_high; symbols[count].duration0 = bit ? dshot_times.ticks_one_high : dshot_times.ticks_zero_high;
symbols[count].level1 = 0; symbols[count].level1 = 0;
symbols[count].duration1 = bit ? ticks_one_low : ticks_zero_low; symbols[count].duration1 = bit ? dshot_times.ticks_one_low : dshot_times.ticks_zero_low;
} }
count++; count++;
} }
@ -251,12 +225,12 @@ uint16_t DShotRMT::decodeDShotRX(const rmt_symbol_word_t *symbols, uint32_t coun
// Extract CRC and payload // Extract CRC and payload
uint16_t payload = received_frame >> 4; uint16_t payload = received_frame >> 4;
uint8_t crc_received = received_frame & 0xF; uint8_t crc_received = received_frame & 0b0000000000001111;
// Calculate CRC for received frame // Calculate CRC for received frame
uint8_t crc_calculated = (payload ^ (payload >> 4) ^ (payload >> 8)) & 0xF; uint8_t crc_calculated = (payload ^ (payload >> 4) ^ (payload >> 8)) & 0b0000000000001111;
if (_isBidirectional) if (_isBidirectional)
crc_calculated = (~crc_calculated) & 0xF; crc_calculated = (~crc_calculated) & 0b0000000000001111;
// Check CRC // Check CRC
if (crc_received != crc_calculated) if (crc_received != crc_calculated)
@ -265,8 +239,6 @@ uint16_t DShotRMT::decodeDShotRX(const rmt_symbol_word_t *symbols, uint32_t coun
return _last_erpm; return _last_erpm;
} }
// Remove telemetry bit, keep raw value // Remove telemetry bit
uint16_t raw = payload >> 1; return _last_erpm = payload >> 1;
return _last_erpm = raw;
} }

View File

@ -14,25 +14,16 @@
#include <driver/rmt_tx.h> #include <driver/rmt_tx.h>
#include <driver/rmt_rx.h> #include <driver/rmt_rx.h>
static constexpr bool DSHOT_OK = 0;
static constexpr bool DSHOT_FAILED = 1;
// --- DShot Protocol Constants --- // --- DShot Protocol Constants ---
static constexpr uint16_t DSHOT_THROTTLE_FAILSAVE = 0; static constexpr uint16_t DSHOT_THROTTLE_FAILSAVE = 0;
static constexpr uint16_t DSHOT_THROTTLE_MIN = 48; static constexpr uint16_t DSHOT_THROTTLE_MIN = 48;
static constexpr uint16_t DSHOT_THROTTLE_MAX = 2047; static constexpr uint16_t DSHOT_THROTTLE_MAX = 2047;
static constexpr uint8_t DSHOT_BITS_PER_FRAME = 16;
static constexpr uint16_t DSHOT_NULL_PACKET = 0x0000;
static constexpr uint16_t DSHOT_FULL_PACKET = 0xFFFF;
static constexpr uint16_t NO_ERPM_SIGNAL = 0;
// RMT configuration parameters
static constexpr rmt_clock_source_t DSHOT_CLOCK_SRC_DEFAULT = RMT_CLK_SRC_DEFAULT;
static constexpr uint32_t DSHOT_RMT_RESOLUTION = 10 * 1000 * 1000; // 10 MHz Clock
static constexpr size_t TX_BUFFER_SIZE = DSHOT_BITS_PER_FRAME;
static constexpr size_t RX_BUFFER_SIZE = 32; // Padding for RX decoding
// DShot Packet structure // DShot Packet structure
typedef struct typedef struct dshot_packet_s
{ {
uint16_t throttle_value : 11; uint16_t throttle_value : 11;
bool telemetric_request : 1; bool telemetric_request : 1;
@ -40,7 +31,7 @@ typedef struct
} dshot_packet_t; } dshot_packet_t;
// --- DShot Mode Selection --- // --- DShot Mode Selection ---
typedef enum typedef enum dshot_mode_s
{ {
DSHOT_OFF, DSHOT_OFF,
DSHOT150, DSHOT150,
@ -49,12 +40,33 @@ typedef enum
DSHOT1200 DSHOT1200
} dshot_mode_t; } dshot_mode_t;
// --- DShot Timings ---
typedef struct dshot_timing_s
{
uint16_t frameLength;
uint16_t ticks_per_bit;
uint16_t ticks_one_high;
uint16_t ticks_zero_high;
uint16_t ticks_zero_low;
uint16_t ticks_one_low;
} dshot_timing_t;
// DShot Pulse Length Settings
const dshot_timing_t dshot_timings[] = {
{0, 0, 0, 0, 0, 0}, // DSHOT_OFF
{128, 64, 48, 24, 40, 16}, // DSHOT150
{64, 32, 24, 12, 20, 8}, // DSHOT300
{32, 16, 12, 6, 10, 4}, // DSHOT600
{16, 8, 6, 3, 5, 2} // DSHOT1200
};
//
// --- DShotRMT Class --- // --- DShotRMT Class ---
class DShotRMT class DShotRMT
{ {
public: public:
// Constructor: initializes configuration state // Constructor: initializes configuration state
DShotRMT(gpio_num_t gpio, dshot_mode_t mode = DSHOT300, bool isBidirectional = false, uint8_t pauseDuration = 120); DShotRMT(gpio_num_t gpio, dshot_mode_t mode = DSHOT300, bool isBidirectional = false);
// Initializes the RMT TX and RX channels // Initializes the RMT TX and RX channels
void begin(); void begin();
@ -69,33 +81,44 @@ public:
// Accessors for GPIO and DShot settings // Accessors for GPIO and DShot settings
gpio_num_t getGPIO() const { return _gpio; } gpio_num_t getGPIO() const { return _gpio; }
dshot_mode_t getDShotMode() const { return _mode; } dshot_mode_t getDShotMode() const { return _mode; }
uint8_t getPauseDuration() const { return _pauseDuration; }
void setPauseDuration(uint8_t pauseDuration) { _pauseDuration = pauseDuration; } // --- Configuration Parameters ---
gpio_num_t _gpio = GPIO_NUM_NC;
dshot_mode_t _mode = DSHOT_OFF;
bool _isBidirectional = false;
uint16_t _frame_time;
const dshot_timing_t &dshot_times = dshot_timings[_mode];
private: private:
// Calculates the checksum for a DShot packet static constexpr uint8_t DSHOT_BITS_PER_FRAME = 16;
uint16_t calculateCRC(uint16_t dshot_packet); static constexpr uint8_t DSHOT_SWITCH_TIME = 42;
// Assembles DShot packet (11 bit throttle + 1 bit telemetry request + 4 bit CRC) static constexpr uint16_t DSHOT_NULL_PACKET = 0b000000000000000;
uint16_t assambleDShotPaket(uint16_t value); static constexpr uint16_t DSHOT_FULL_PACKET = 0b111111111111111;
static constexpr uint16_t NO_ERPM_SIGNAL = 0;
// RMT configuration parameters
static constexpr rmt_clock_source_t DSHOT_CLOCK_SRC_DEFAULT = RMT_CLK_SRC_DEFAULT;
static constexpr uint32_t DSHOT_RMT_RESOLUTION = 10 * 1000 * 1000; // 10 MHz Clock
static constexpr size_t TX_BUFFER_SIZE = DSHOT_BITS_PER_FRAME;
static constexpr size_t RX_BUFFER_SIZE = 32;
static constexpr size_t DSHOT_SYMBOLS_SIZE = 64;
// Calculates the checksum for a DShot packet
uint16_t calculateCRC(dshot_packet_t dshot_packet);
// Parses the DShot packet (11 bit throttle + 1 bit telemetry request + 4 bit CRC)
uint16_t parseDShotPacket(const dshot_packet_t dshot_packet);
// Converts a 16-bit DShot packet into RMT symbols // Converts a 16-bit DShot packet into RMT symbols
void encodeDShotTX(uint16_t dshot_packet, rmt_symbol_word_t *symbols, size_t &count); void encodeDShotTX(dshot_packet_t dshot_packet, rmt_symbol_word_t *symbols);
// Decodes the ESC answer // Decodes the ESC answer
uint16_t decodeDShotRX(const rmt_symbol_word_t *symbols, uint32_t count); uint16_t decodeDShotRX(const rmt_symbol_word_t *symbols, uint32_t count);
// --- Configuration Parameters ---
gpio_num_t _gpio;
dshot_mode_t _mode;
bool _isBidirectional;
uint8_t _pauseDuration;
// --- DShot Packets Container --- // --- DShot Packets Container ---
uint16_t _lastThrottle = DSHOT_NULL_PACKET;
uint16_t _rx_packet = DSHOT_NULL_PACKET; uint16_t _rx_packet = DSHOT_NULL_PACKET;
uint16_t _tx_packet = DSHOT_NULL_PACKET;
uint8_t _packet_crc = 0;
// --- RMT Channel Handles --- // --- RMT Channel Handles ---
rmt_channel_handle_t _rmt_rx_channel = nullptr; rmt_channel_handle_t _rmt_rx_channel = nullptr;
@ -112,8 +135,7 @@ private:
// --- RMT Symbol Buffers --- // --- RMT Symbol Buffers ---
rmt_symbol_word_t _rx_symbols[RX_BUFFER_SIZE] = {}; rmt_symbol_word_t _rx_symbols[RX_BUFFER_SIZE] = {};
rmt_symbol_word_t _tx_symbols[TX_BUFFER_SIZE] = {};
// Stores the last valid eRPM received from the ESC // Stores the last valid eRPM received from the ESC
uint16_t _last_erpm = 0; uint16_t _last_erpm = NULL;
}; };

View File

@ -114,7 +114,7 @@ Perfect for DShot:
## 📝 API Reference ## 📝 API Reference
- `DShotRMT(gpio_num_t gpio, dshot_mode_t mode, bool isBidirectional, uint8_t pauseDuration = 120)` - `DShotRMT(gpio_num_t gpio, dshot_mode_t mode, bool isBidirectional)`
- `void begin()` - `void begin()`
- `void setThrottle(uint16_t throttle)` - `void setThrottle(uint16_t throttle)`
- `uint32_t getERPM()` - `uint32_t getERPM()`

View File

@ -32,6 +32,7 @@ void printRPMPeriodically(uint16_t throttle);
// Reads throttle value from serial input // Reads throttle value from serial input
uint16_t readSerialThrottle(); uint16_t readSerialThrottle();
//
void setup() void setup()
{ {
// Start the USB Serial Port // Start the USB Serial Port
@ -45,9 +46,10 @@ void setup()
USB_SERIAL.println("**********************"); USB_SERIAL.println("**********************");
USB_SERIAL.println("DShotRMT Demo started."); USB_SERIAL.println("DShotRMT Demo started.");
USB_SERIAL.println("Enter a throttle value (482047):"); USB_SERIAL.println("Enter a throttle value (48 2047):");
} }
//
void loop() void loop()
{ {
// Read value input from Serial // Read value input from Serial
@ -73,12 +75,10 @@ uint16_t readSerialThrottle()
String input = USB_SERIAL.readStringUntil('\n'); String input = USB_SERIAL.readStringUntil('\n');
int throttle_input = input.toInt(); int throttle_input = input.toInt();
// Clamp the value to the DShot range
throttle_input = constrain(throttle_input, DSHOT_THROTTLE_MIN, DSHOT_THROTTLE_MAX);
if (throttle_input < DSHOT_THROTTLE_MIN || throttle_input > DSHOT_THROTTLE_MAX) if (throttle_input < DSHOT_THROTTLE_MIN || throttle_input > DSHOT_THROTTLE_MAX)
{ {
USB_SERIAL.println("Invalid input. Please enter a value between 48 and 2047."); USB_SERIAL.println("Invalid input. Please enter a value between 48 and 2047.");
return last_throttle;
} }
else else
{ {
@ -88,7 +88,7 @@ uint16_t readSerialThrottle()
} }
USB_SERIAL.println("*********************************"); USB_SERIAL.println("*********************************");
USB_SERIAL.println("Enter a throttle value (482047):"); USB_SERIAL.println("Enter a throttle value (48 2047):");
} }
return last_throttle; return last_throttle;
@ -98,17 +98,16 @@ uint16_t readSerialThrottle()
void printRPMPeriodically(uint16_t throttle) void printRPMPeriodically(uint16_t throttle)
{ {
static unsigned long last_print_time = 0; static unsigned long last_print_time = 0;
unsigned long now = millis();
if (now - last_print_time >= 2000) if (millis() - last_print_time >= 2000)
{ {
last_print_time = now;
uint32_t rpm = motor01.getMotorRPM(MOTOR01_MAGNET_COUNT); uint32_t rpm = motor01.getMotorRPM(MOTOR01_MAGNET_COUNT);
USB_SERIAL.print("Throttle: "); USB_SERIAL.print("Throttle: ");
USB_SERIAL.print(throttle); USB_SERIAL.print(throttle);
USB_SERIAL.print(" | RPM: "); USB_SERIAL.print(" | RPM: ");
USB_SERIAL.println(rpm); USB_SERIAL.println(rpm);
last_print_time = millis();
} }
} }