From 3d4b2affa4ace1facd65945c4772153d197c4545 Mon Sep 17 00:00:00 2001 From: Brian White Date: Thu, 9 Mar 2023 22:39:40 -0500 Subject: [PATCH] Debug 8 columns (#12445) --- src/main/blackbox/blackbox.c | 6 +++++- src/main/build/debug.h | 2 +- src/main/drivers/dshot.c | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 4b1b42ecafb..7f6085ab88e 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -231,6 +231,10 @@ static const blackboxDeltaFieldDefinition_t blackboxMainFields[] = { {"debug", 1, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(DEBUG_LOG)}, {"debug", 2, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(DEBUG_LOG)}, {"debug", 3, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(DEBUG_LOG)}, + {"debug", 4, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(DEBUG_LOG)}, + {"debug", 5, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(DEBUG_LOG)}, + {"debug", 6, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(DEBUG_LOG)}, + {"debug", 7, SIGNED, .Ipredict = PREDICT(0), .Iencode = ENCODING(SIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(DEBUG_LOG)}, /* Motors only rarely drops under minthrottle (when stick falls below mincommand), so predict minthrottle for it and use *unsigned* encoding (which is large for negative numbers but more compact for positive ones): */ {"motor", 0, UNSIGNED, .Ipredict = PREDICT(MINMOTOR), .Iencode = ENCODING(UNSIGNED_VB), .Ppredict = PREDICT(AVERAGE_2), .Pencode = ENCODING(SIGNED_VB), CONDITION(AT_LEAST_MOTORS_1)}, /* Subsequent motors base their I-frame values on the first one, P-frame values on the average of last two frames: */ @@ -1558,7 +1562,7 @@ static bool blackboxWriteSysinfo(void) BLACKBOX_PRINT_HEADER_LINE(PARAM_NAME_GPS_RESCUE_VELOCITY_D, "%d", gpsRescueConfig()->velD) BLACKBOX_PRINT_HEADER_LINE(PARAM_NAME_GPS_RESCUE_YAW_P, "%d", gpsRescueConfig()->yawP) - + #ifdef USE_MAG BLACKBOX_PRINT_HEADER_LINE(PARAM_NAME_GPS_RESCUE_USE_MAG, "%d", gpsRescueConfig()->useMag) #endif diff --git a/src/main/build/debug.h b/src/main/build/debug.h index bf196aeca61..2905d518cb8 100644 --- a/src/main/build/debug.h +++ b/src/main/build/debug.h @@ -20,7 +20,7 @@ #pragma once -#define DEBUG16_VALUE_COUNT 4 +#define DEBUG16_VALUE_COUNT 8 extern int16_t debug[DEBUG16_VALUE_COUNT]; extern uint8_t debugMode; diff --git a/src/main/drivers/dshot.c b/src/main/drivers/dshot.c index 2c3105f0af4..65d4a319334 100644 --- a/src/main/drivers/dshot.c +++ b/src/main/drivers/dshot.c @@ -155,13 +155,14 @@ static uint32_t dshot_decode_eRPM_telemetry_value(uint16_t value) static void dshot_decode_telemetry_value(uint8_t motorIndex, uint32_t *pDecoded, dshotTelemetryType_t *pType) { uint16_t value = dshotTelemetryState.motorState[motorIndex].rawValue; + const unsigned motorCount = motorDeviceCount(); if (dshotTelemetryState.motorState[motorIndex].telemetryTypes == DSHOT_NORMAL_TELEMETRY_MASK) { /* Check DSHOT_TELEMETRY_TYPE_eRPM mask */ // Decode eRPM telemetry *pDecoded = dshot_decode_eRPM_telemetry_value(value); // Update debug buffer - if (motorIndex < 4) { + if (motorIndex < motorCount && motorIndex < DEBUG16_VALUE_COUNT) { DEBUG_SET(DEBUG_DSHOT_RPM_TELEMETRY, motorIndex, *pDecoded); } @@ -232,7 +233,7 @@ static void dshot_decode_telemetry_value(uint8_t motorIndex, uint32_t *pDecoded, *pDecoded = dshot_decode_eRPM_telemetry_value(value); // Update debug buffer - if (motorIndex < 4) { + if (motorIndex < motorCount && motorIndex < DEBUG16_VALUE_COUNT) { DEBUG_SET(DEBUG_DSHOT_RPM_TELEMETRY, motorIndex, *pDecoded); }