From 4e8930c8fc212b855e54d6acff67c32193efb828 Mon Sep 17 00:00:00 2001 From: Wastl Kraus Date: Wed, 18 Jun 2025 18:40:16 +0200 Subject: [PATCH] ...add dshot_commands Header File --- DShotRMT.h | 2 ++ dshot_commands.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 dshot_commands.h diff --git a/DShotRMT.h b/DShotRMT.h index 3e003c4..a278418 100644 --- a/DShotRMT.h +++ b/DShotRMT.h @@ -9,9 +9,11 @@ #pragma once #include +#include #include #include #include +#include // --- DShot Protocol Constants --- // Constants to define timing and encoding rules for DShot Protocol diff --git a/dshot_commands.h b/dshot_commands.h new file mode 100644 index 0000000..319aaba --- /dev/null +++ b/dshot_commands.h @@ -0,0 +1,70 @@ +/* + * This file is part of Cleanflight and Betaflight. + * + * Cleanflight and Betaflight are free software. You can redistribute + * this software and/or modify this software under the terms of the + * GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Cleanflight and Betaflight are distributed in the hope that they + * will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software. + * + * If not, see . + */ + +#pragma once + +#define DSHOT_MAX_COMMAND 47 + +/* + DshotSettingRequest (KISS24). Spin direction, 3d and save Settings require 10 requests.. and the TLM Byte must always be high if 1-47 are used to send settings + + 3D Mode: + 0 = stop + 48 (low) - 1047 (high) -> negative direction + 1048 (low) - 2047 (high) -> positive direction + */ + +typedef enum +{ + DSHOT_CMD_MOTOR_STOP = 0, + DSHOT_CMD_BEACON1, + DSHOT_CMD_BEACON2, + DSHOT_CMD_BEACON3, + DSHOT_CMD_BEACON4, + DSHOT_CMD_BEACON5, + DSHOT_CMD_ESC_INFO, // V2 includes settings + DSHOT_CMD_SPIN_DIRECTION_1, + DSHOT_CMD_SPIN_DIRECTION_2, + DSHOT_CMD_3D_MODE_OFF, + DSHOT_CMD_3D_MODE_ON, + DSHOT_CMD_SETTINGS_REQUEST, // Currently not implemented + DSHOT_CMD_SAVE_SETTINGS, + DSHOT_CMD_EXTENDED_TELEMETRY_ENABLE, + DSHOT_CMD_EXTENDED_TELEMETRY_DISABLE, + DSHOT_CMD_SPIN_DIRECTION_NORMAL = 20, + DSHOT_CMD_SPIN_DIRECTION_REVERSED = 21, + DSHOT_CMD_LED0_ON, // BLHeli32 only + DSHOT_CMD_LED1_ON, // BLHeli32 only + DSHOT_CMD_LED2_ON, // BLHeli32 only + DSHOT_CMD_LED3_ON, // BLHeli32 only + DSHOT_CMD_LED0_OFF, // BLHeli32 only + DSHOT_CMD_LED1_OFF, // BLHeli32 only + DSHOT_CMD_LED2_OFF, // BLHeli32 only + DSHOT_CMD_LED3_OFF, // BLHeli32 only + DSHOT_CMD_AUDIO_STREAM_MODE_ON_OFF = 30, // KISS audio Stream mode on/Off + DSHOT_CMD_SILENT_MODE_ON_OFF = 31, // KISS silent Mode on/Off + DSHOT_CMD_MAX = 47 +} dshotCommands_e; + +typedef enum +{ + DSHOT_CMD_TYPE_INLINE = 0, // dshot commands sent inline with motor signal (motors must be enabled) + DSHOT_CMD_TYPE_BLOCKING // dshot commands sent in blocking method (motors must be disabled) +} dshotCommandType_e;