Add debug mode to CMS menu

This commit is contained in:
Dan Nixon 2017-07-15 14:46:31 +01:00
parent a46936d040
commit cfb23ad0ac
4 changed files with 36 additions and 26 deletions

View File

@ -26,3 +26,28 @@ uint8_t debugMode;
#ifdef DEBUG_SECTION_TIMES
uint32_t sectionTimes[2][4];
#endif
const char * const debugModeNames[DEBUG_COUNT] = {
"NONE",
"CYCLETIME",
"BATTERY",
"GYRO",
"ACCELEROMETER",
"MIXER",
"AIRMODE",
"PIDLOOP",
"NOTCH",
"RC_INTERPOLATION",
"VELOCITY",
"DFILTER",
"ANGLERATE",
"ESC_SENSOR",
"SCHEDULER",
"STACK",
"ESC_SENSOR_RPM",
"ESC_SENSOR_TMP",
"ALTITUDE",
"FFT",
"FFT_TIME",
"FFT_FREQ"
};

View File

@ -70,3 +70,5 @@ typedef enum {
DEBUG_FFT_FREQ,
DEBUG_COUNT
} debugType_e;
extern const char * const debugModeNames[DEBUG_COUNT];

View File

@ -24,6 +24,7 @@
#ifdef CMS
#include "build/debug.h"
#include "build/version.h"
#include "drivers/time.h"
@ -38,6 +39,7 @@
#include "config/parameter_group.h"
#include "config/parameter_group_ids.h"
#include "fc/config.h"
#include "fc/rc_controls.h"
#include "flight/mixer.h"
@ -92,6 +94,7 @@ static uint16_t motorConfig_minthrottle;
static uint8_t motorConfig_digitalIdleOffsetValue;
static uint8_t voltageSensorADCConfig_vbatscale;
static uint8_t batteryConfig_vbatmaxcellvoltage;
static debugType_e systemConfig_debug_mode;
static long cmsx_menuMiscOnEnter(void)
{
@ -99,6 +102,8 @@ static long cmsx_menuMiscOnEnter(void)
motorConfig_digitalIdleOffsetValue = motorConfig()->digitalIdleOffsetValue / 10;
voltageSensorADCConfig_vbatscale = voltageSensorADCConfig(VOLTAGE_SENSOR_ADC_VBAT)->vbatscale;
batteryConfig_vbatmaxcellvoltage = batteryConfig()->vbatmaxcellvoltage;
systemConfig_debug_mode = systemConfig()->debug_mode;
return 0;
}
@ -110,6 +115,8 @@ static long cmsx_menuMiscOnExit(const OSD_Entry *self)
motorConfigMutable()->digitalIdleOffsetValue = 10 * motorConfig_digitalIdleOffsetValue;
voltageSensorADCConfigMutable(VOLTAGE_SENSOR_ADC_VBAT)->vbatscale = voltageSensorADCConfig_vbatscale;
batteryConfigMutable()->vbatmaxcellvoltage = batteryConfig_vbatmaxcellvoltage;
systemConfigMutable()->debug_mode = systemConfig_debug_mode;
return 0;
}
@ -121,6 +128,7 @@ static OSD_Entry menuMiscEntries[]=
{ "DIGITAL IDLE", OME_UINT8, NULL, &(OSD_UINT8_t) { &motorConfig_digitalIdleOffsetValue, 0, 200, 1 }, 0 },
{ "VBAT SCALE", OME_UINT8, NULL, &(OSD_UINT8_t) { &voltageSensorADCConfig_vbatscale, 1, 250, 1 }, 0 },
{ "VBAT CLMAX", OME_UINT8, NULL, &(OSD_UINT8_t) { &batteryConfig_vbatmaxcellvoltage, 10, 50, 1 }, 0 },
{ "DEBUG MODE", OME_TAB, NULL, &(OSD_TAB_t) { &systemConfig_debug_mode, DEBUG_COUNT - 1, debugModeNames }, 0 },
{ "RC PREV", OME_Submenu, cmsMenuChange, &cmsx_menuRcPreview, 0},
{ "BACK", OME_Back, NULL, NULL, 0},

View File

@ -195,31 +195,6 @@ static const char * const lookupTableGyroLpf[] = {
"EXPERIMENTAL"
};
static const char * const lookupTableDebug[DEBUG_COUNT] = {
"NONE",
"CYCLETIME",
"BATTERY",
"GYRO",
"ACCELEROMETER",
"MIXER",
"AIRMODE",
"PIDLOOP",
"NOTCH",
"RC_INTERPOLATION",
"VELOCITY",
"DFILTER",
"ANGLERATE",
"ESC_SENSOR",
"SCHEDULER",
"STACK",
"ESC_SENSOR_RPM",
"ESC_SENSOR_TMP",
"ALTITUDE",
"FFT",
"FFT_TIME",
"FFT_FREQ"
};
#ifdef OSD
static const char * const lookupTableOsdType[] = {
"AUTO",
@ -286,7 +261,7 @@ const lookupTableEntry_t lookupTables[] = {
#ifdef MAG
{ lookupTableMagHardware, sizeof(lookupTableMagHardware) / sizeof(char *) },
#endif
{ lookupTableDebug, sizeof(lookupTableDebug) / sizeof(char *) },
{ debugModeNames, sizeof(debugModeNames) / sizeof(char *) },
{ lookupTableSuperExpoYaw, sizeof(lookupTableSuperExpoYaw) / sizeof(char *) },
{ lookupTablePwmProtocol, sizeof(lookupTablePwmProtocol) / sizeof(char *) },
{ lookupTableRcInterpolation, sizeof(lookupTableRcInterpolation) / sizeof(char *) },