From 287d398b13290599e0ff788a749b7c9ab62fa9e9 Mon Sep 17 00:00:00 2001 From: mikeller Date: Sat, 13 Aug 2016 21:24:16 +1200 Subject: [PATCH] Added 'CLI_MINIMAL_VERBOSITY' option for reduced image size. Reenabled LED_STRIP for CC3D. --- src/main/io/serial_cli.c | 71 ++++++++++++++++++++++++++++++----- src/main/target/CC3D/target.h | 5 ++- src/main/target/NAZE/target.h | 1 - 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 4164f4e14a..7792322286 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -146,7 +146,7 @@ static void cliTasks(char *cmdline); #endif static void cliVersion(char *cmdline); static void cliRxRange(char *cmdline); -#if (FLASH_SIZE > 64) +#if (FLASH_SIZE > 64) && !defined(CLI_MINIMAL_VERBOSITY) static void cliResource(char *cmdline); #endif #ifdef GPS @@ -231,7 +231,7 @@ static const rxFailsafeChannelMode_e rxFailsafeModesTable[RX_FAILSAFE_TYPE_COUNT { RX_FAILSAFE_MODE_INVALID, RX_FAILSAFE_MODE_HOLD, RX_FAILSAFE_MODE_SET } }; -#if (FLASH_SIZE > 64) +#if (FLASH_SIZE > 64) && !defined(CLI_MINIMAL_VERBOSITY) // sync this with sensors_e static const char * const sensorTypeNames[] = { "GYRO", "ACC", "BARO", "MAG", "SONAR", "GPS", "GPS+MAG", NULL @@ -322,7 +322,7 @@ const clicmd_t cmdTable[] = { CLI_COMMAND_DEF("profile", "change profile", "[]", cliProfile), CLI_COMMAND_DEF("rateprofile", "change rate profile", "[]", cliRateProfile), -#if (FLASH_SIZE > 64) +#if (FLASH_SIZE > 64) && !defined(CLI_MINIMAL_VERBOSITY) CLI_COMMAND_DEF("resource", "view currently used resources", NULL, cliResource), #endif CLI_COMMAND_DEF("rxrange", "configure rx channel ranges", NULL, cliRxRange), @@ -1446,7 +1446,9 @@ static void cliMotorMix(char *cmdline) char *ptr; if (isEmpty(cmdline)) { +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("Motor\tThr\tRoll\tPitch\tYaw\r\n"); +#endif for (i = 0; i < MAX_SUPPORTED_MOTORS; i++) { if (masterConfig.customMotorMixer[i].throttle == 0.0f) break; @@ -1831,7 +1833,9 @@ static void cliServoMix(char *cmdline) if (len == 0) { +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("Rule\tServo\tSource\tRate\tSpeed\tMin\tMax\tBox\r\n"); +#endif for (i = 0; i < MAX_SERVO_RULES; i++) { if (masterConfig.customServoMixer[i].rate == 0) @@ -2320,18 +2324,24 @@ static void printConfig(char *cmdline, bool doDiff) } if ((dumpMask & DUMP_MASTER) || (dumpMask & DUMP_ALL)) { +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# version\r\n"); +#endif cliVersion(NULL); +#ifndef CLI_MINIMAL_VERBOSITY if ((dumpMask & (DUMP_ALL | DO_DIFF)) == (DUMP_ALL | DO_DIFF)) { cliPrint("\r\n# reset configuration to default settings\r\ndefaults\r\n"); } cliPrint("\r\n# name\r\n"); +#endif printName(dumpMask); - cliPrint("\r\n# mixer\r\n"); #ifndef USE_QUAD_MIXER_ONLY +#ifndef CLI_MINIMAL_VERBOSITY + cliPrint("\r\n# mixer\r\n"); +#endif cliDumpPrintf(dumpMask, COMPARE_CONFIG(mixerMode), "mixer %s\r\n", mixerNames[masterConfig.mixerMode - 1]); cliDumpPrintf(dumpMask, masterConfig.customMotorMixer[0].throttle == 0.0f, "mmix reset\r\n"); @@ -2396,7 +2406,9 @@ static void printConfig(char *cmdline, bool doDiff) #endif #endif +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# feature\r\n"); +#endif mask = featureMask(); defaultMask = defaultConfig.enabledFeatures; @@ -2413,7 +2425,9 @@ static void printConfig(char *cmdline, bool doDiff) } #ifdef BEEPER +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# beeper\r\n"); +#endif uint8_t beeperCount = beeperTableEntryCount(); mask = getBeeperOffMask(); defaultMask = defaultConfig.beeper_off_flags; @@ -2425,7 +2439,9 @@ static void printConfig(char *cmdline, bool doDiff) } #endif +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# map\r\n"); +#endif equalsDefault = true; for (i = 0; i < MAX_MAPPABLE_RX_INPUTS; i++) { buf[masterConfig.rxConfig.rcmap[i]] = rcChannelLetters[i]; @@ -2434,43 +2450,65 @@ static void printConfig(char *cmdline, bool doDiff) buf[i] = '\0'; cliDumpPrintf(dumpMask, equalsDefault, "map %s\r\n", buf); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# serial\r\n"); +#endif printSerial(dumpMask, &defaultConfig); #ifdef LED_STRIP +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# led\r\n"); +#endif printLed(dumpMask, &defaultConfig); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# color\r\n"); +#endif printColor(dumpMask, &defaultConfig); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# mode_color\r\n"); +#endif printModeColor(dumpMask, &defaultConfig); #endif +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# aux\r\n"); +#endif printAux(dumpMask, &defaultConfig); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# adjrange\r\n"); +#endif printAdjustmentRange(dumpMask, &defaultConfig); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# rxrange\r\n"); +#endif printRxRange(dumpMask, &defaultConfig); #ifdef USE_SERVOS +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# servo\r\n"); +#endif printServo(dumpMask, &defaultConfig); #endif #ifdef VTX +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# vtx\r\n"); +#endif printVtx(dumpMask, &defaultConfig); #endif +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# rxfail\r\n"); +#endif printRxFail(dumpMask, &defaultConfig); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# master\r\n"); +#endif dumpValues(MASTER_VALUE, dumpMask, &defaultConfig); if (dumpMask & DUMP_ALL) { @@ -2484,16 +2522,20 @@ static void printConfig(char *cmdline, bool doDiff) for (rateCount=0; rateCountactiveRateProfile, dumpMask, &defaultConfig); @@ -2514,7 +2556,9 @@ static void cliDumpProfile(uint8_t profileIndex, uint8_t dumpMask, master_t *def if (profileIndex >= MAX_PROFILE_COUNT) // Faulty values return; changeProfile(profileIndex); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# profile\r\n"); +#endif cliProfile(""); dumpValues(PROFILE_VALUE, dumpMask, defaultConfig); } @@ -2524,7 +2568,9 @@ static void cliDumpRateProfile(uint8_t rateProfileIndex, uint8_t dumpMask, maste if (rateProfileIndex >= MAX_RATEPROFILES) // Faulty values return; changeControlRateProfile(rateProfileIndex); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\n# rateprofile\r\n"); +#endif cliRateProfile(""); dumpValues(PROFILE_RATE_VALUE, dumpMask, defaultConfig); } @@ -2537,7 +2583,9 @@ void cliEnter(serialPort_t *serialPort) cliWriter = bufWriterInit(cliWriteBuffer, sizeof(cliWriteBuffer), (bufWrite_t)serialWriteBufShim, serialPort); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\nEntering CLI Mode, type 'exit' to return, or 'help'\r\n"); +#endif cliPrompt(); ENABLE_ARMING_FLAG(PREVENT_ARMING); } @@ -2546,7 +2594,9 @@ static void cliExit(char *cmdline) { UNUSED(cmdline); +#ifndef CLI_MINIMAL_VERBOSITY cliPrint("\r\nLeaving CLI mode, unsaved changes lost.\r\n"); +#endif bufWriterFlush(cliWriter); *cliBuffer = '\0'; @@ -2842,7 +2892,7 @@ static void cliMotor(char *cmdline) static void cliPlaySound(char *cmdline) { -#if FLASH_SIZE <= 64 +#if (FLASH_SIZE <= 64) && !defined(CLI_MINIMAL_VERBOSITY) UNUSED(cmdline); #else int i; @@ -2934,7 +2984,6 @@ static void cliSave(char *cmdline) UNUSED(cmdline); cliPrint("Saving"); - //copyCurrentProfileToProfileSlot(masterConfig.current_profile_index); writeEEPROM(); cliReboot(); } @@ -3241,7 +3290,7 @@ static void cliStatus(char *cmdline) cliPrintf("CPU Clock=%dMHz", (SystemCoreClock / 1000000)); -#if (FLASH_SIZE > 64) +#if (FLASH_SIZE > 64) && !defined(CLI_MINIMAL_VERBOSITY) uint8_t i; uint32_t mask; uint32_t detectedSensorsMask = sensorsMask(); @@ -3287,7 +3336,9 @@ static void cliTasks(char *cmdline) int maxLoadSum = 0; int averageLoadSum = 0; +#ifndef CLI_MINIMAL_VERBOSITY cliPrintf("Task list rate/hz max/us avg/us maxload avgload total/ms\r\n"); +#endif for (cfTaskId_e taskId = 0; taskId < TASK_COUNT; taskId++) { cfTaskInfo_t taskInfo; getTaskInfo(taskId, &taskInfo); @@ -3448,7 +3499,7 @@ void cliProcess(void) } } -#if (FLASH_SIZE > 64) +#if (FLASH_SIZE > 64) && !defined(CLI_MINIMAL_VERBOSITY) static void cliResource(char *cmdline) { UNUSED(cmdline); diff --git a/src/main/target/CC3D/target.h b/src/main/target/CC3D/target.h index 342e4c0692..cfcc9b6831 100644 --- a/src/main/target/CC3D/target.h +++ b/src/main/target/CC3D/target.h @@ -91,7 +91,7 @@ #define VBAT_ADC_PIN PA0 #define RSSI_ADC_PIN PB0 -//#define LED_STRIP +#define LED_STRIP #define WS2811_PIN PB4 #define WS2811_TIMER TIM3 #define WS2811_DMA_TC_FLAG DMA1_FLAG_TC6 @@ -108,15 +108,16 @@ //#define SONAR_TRIGGER_PIN PB5 #undef GPS +#define CLI_MINIMAL_VERBOSITY #ifdef CC3D_OPBL -#undef LED_STRIP #define SKIP_CLI_COMMAND_HELP #define SKIP_PID_FLOAT #undef BARO #undef MAG #undef SONAR #undef USE_SOFTSERIAL1 +#undef LED_STRIP #endif #define DEFAULT_RX_FEATURE FEATURE_RX_PPM diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index 212ea2c83f..a3b2bb1f34 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -143,7 +143,6 @@ #define RSSI_ADC_PIN PA1 #define EXTERNAL1_ADC_PIN PA5 - #define LED_STRIP #define WS2811_TIMER TIM3 #define WS2811_PIN PA6