1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Added USE_ESC_SENSOR_INFO define, cleaned up USE_ESC_SENSOR define. (#5580)

This commit is contained in:
Michael Keller 2018-04-01 11:33:07 +12:00 committed by GitHub
parent b8aa6ac915
commit b5c0076bc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 37 additions and 53 deletions

View file

@ -2372,7 +2372,8 @@ static int parseOutputIndex(char *pch, bool allowAllEscs) {
return outputIndex;
}
#ifdef USE_DSHOT
#if defined(USE_DSHOT)
#if defined(USE_ESC_SENSOR) && defined(USE_ESC_SENSOR_INFO)
#define ESC_INFO_KISS_V1_EXPECTED_FRAME_SIZE 15
#define ESC_INFO_KISS_V2_EXPECTED_FRAME_SIZE 21
@ -2558,6 +2559,7 @@ static void executeEscInfoCommand(uint8_t escIndex)
printEscInfo(escInfoBuffer, getNumberEscBytesRead());
}
#endif // USE_ESC_SENSOR && USE_ESC_SENSOR_INFO
static void cliDshotProg(char *cmdline)
{
@ -2600,12 +2602,19 @@ static void cliDshotProg(char *cmdline)
if (command != DSHOT_CMD_ESC_INFO) {
pwmWriteDshotCommand(escIndex, getMotorCount(), command);
} else {
if (escIndex != ALL_MOTORS) {
executeEscInfoCommand(escIndex);
} else {
for (uint8_t i = 0; i < getMotorCount(); i++) {
executeEscInfoCommand(i);
#if defined(USE_ESC_SENSOR) && defined(USE_ESC_SENSOR_INFO)
if (feature(FEATURE_ESC_SENSOR)) {
if (escIndex != ALL_MOTORS) {
executeEscInfoCommand(escIndex);
} else {
for (uint8_t i = 0; i < getMotorCount(); i++) {
executeEscInfoCommand(i);
}
}
} else
#endif
{
cliPrintLine("Not supported.");
}
}
@ -2628,7 +2637,7 @@ static void cliDshotProg(char *cmdline)
pwmEnableMotors();
}
#endif
#endif // USE_DSHOT
#ifdef USE_ESCSERIAL
static void cliEscPassthrough(char *cmdline)

View file

@ -741,6 +741,8 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
{
bool unsupportedCommand = false;
switch (cmdMSP) {
case MSP_STATUS_EX:
case MSP_STATUS:
@ -967,13 +969,19 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
break;
#endif
#ifdef USE_DSHOT
#if defined(USE_ESC_SENSOR)
case MSP_ESC_SENSOR_DATA:
sbufWriteU8(dst, getMotorCount());
for (int i = 0; i < getMotorCount(); i++) {
sbufWriteU8(dst, getEscSensorData(i)->temperature);
sbufWriteU16(dst, getEscSensorData(i)->rpm);
if (feature(FEATURE_ESC_SENSOR)) {
sbufWriteU8(dst, getMotorCount());
for (int i = 0; i < getMotorCount(); i++) {
const escSensorData_t *escData = getEscSensorData(i);
sbufWriteU8(dst, escData->temperature);
sbufWriteU16(dst, escData->rpm);
}
} else {
unsupportedCommand = true;
}
break;
#endif
@ -1276,9 +1284,9 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
break;
#endif
default:
return false;
unsupportedCommand = true;
}
return true;
return !unsupportedCommand;
}
static mspResult_e mspFcProcessOutCommandWithArg(uint8_t cmdMSP, sbuf_t *arg, sbuf_t *dst)