Bad example

...just to make it work
This commit is contained in:
Wastl Kraus 2025-05-14 15:19:38 +02:00
parent 09ca43568c
commit b0b97da2d0
1 changed files with 15 additions and 17 deletions

View File

@ -27,32 +27,30 @@ DShotRMT motor01(MOTOR01_PIN, RMT_CHANNEL_0);
void setup() void setup()
{ {
USB_Serial.begin(USB_SERIAL_BAUD); USB_Serial.begin(USB_SERIAL_BAUD);
// Start generating DShot signal for the motor // Start generating DShot signal for the motor
motor01.begin(DSHOT_MODE); motor01.begin(DSHOT_MODE);
} }
void loop() void loop()
{ {
// Read the throttle value from the USB serial input // Read the throttle value from the USB serial input
auto throttle_input = readSerialThrottle(); int throttle_input = read_SerialThrottle();
// Set the throttle value to either the value received from the serial input or the failsafe throttle value // Set the throttle value to either the value received from the serial input or the failsafe throttle value
auto throttle_value = (throttle_input > 0) ? throttle_input : FAILSAFE_THROTTLE; auto throttle_value = (throttle_input > 0) ? throttle_input : FAILSAFE_THROTTLE;
// Send the throttle value to the motor // Send the throttle value to the motor
motor01.sendThrottleValue(throttle_value); motor01.sendThrottleValue(throttle_value);
} }
// Read the throttle value from the USB serial input // Read the throttle value from the USB serial input
uint16_t readSerialThrottle() int read_SerialThrottle()
{ {
if (USB_Serial.available() > 0) if (USB_Serial.available() > 0)
{ {
return USB_Serial.readStringUntil('\n').toInt(); auto throttle_input = (USB_Serial.readStringUntil('\n')).toInt();
} else return throttle_input;
{ }
return FAILSAFE_THROTTLE;
}
} }