fix throttle
This commit is contained in:
parent
cca82f5e57
commit
78bc06344c
|
|
@ -23,7 +23,7 @@ constexpr auto DSHOT_THROTTLE_MAX = 2047;
|
|||
constexpr auto DSHOT_NULL_PACKET = 0b0000000000000000;
|
||||
constexpr auto DSHOT_PAUSE = 21; // 21-bit is recommended
|
||||
constexpr auto DSHOT_PAUSE_BIT = 16;
|
||||
constexpr auto F_CPU_RMT = ( 80*1000000 ); //unit: Hz
|
||||
constexpr auto F_CPU_RMT = (80 * 1000 * 1000); // unit: Hz
|
||||
constexpr auto RMT_CYCLES_PER_SEC = (F_CPU_RMT / DSHOT_CLK_DIVIDER);
|
||||
constexpr auto RMT_CYCLES_PER_ESP_CYCLE = (F_CPU / RMT_CYCLES_PER_SEC);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const auto USB_SERIAL_BAUD = 115200;
|
|||
#define USB_Serial Serial
|
||||
|
||||
// Define the GPIO pin connected to the motor and the DShot protocol used
|
||||
const auto MOTOR01_PIN = GPIO_NUM_4;
|
||||
const auto MOTOR01_PIN = GPIO_NUM_17;
|
||||
const auto DSHOT_MODE = DSHOT300;
|
||||
|
||||
// Define the failsafe and initial throttle values
|
||||
|
|
@ -31,6 +31,9 @@ void setup()
|
|||
|
||||
// Start generating DShot signal for the motor
|
||||
motor01.begin(DSHOT_MODE);
|
||||
|
||||
Serial.println("DShotRMT Demo started.");
|
||||
Serial.println("Enter a throttle value (0–2047):");
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
|
@ -46,13 +49,16 @@ void loop()
|
|||
// Read the throttle value from the USB serial input
|
||||
int read_SerialThrottle()
|
||||
{
|
||||
static int last_throttle = INITIAL_THROTTLE;
|
||||
|
||||
if (USB_Serial.available() > 0)
|
||||
{
|
||||
auto throttle_input = (USB_Serial.readStringUntil('\n')).toInt();
|
||||
return throttle_input;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FAILSAFE_THROTTLE;
|
||||
last_throttle = throttle_input;
|
||||
Serial.print("Throttle set to: ");
|
||||
Serial.println(last_throttle);
|
||||
Serial.println(" ");
|
||||
Serial.println("Enter a throttle value (0–2047):");
|
||||
}
|
||||
return last_throttle;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue