mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
Merge pull request #747 from KiteAnton/name
Quad "name" as requested in #724
This commit is contained in:
commit
2fb3ee0192
6 changed files with 69 additions and 17 deletions
|
@ -441,6 +441,7 @@ static void resetConf(void)
|
|||
featureSet(FEATURE_VBAT);
|
||||
#endif
|
||||
|
||||
|
||||
masterConfig.version = EEPROM_CONF_VERSION;
|
||||
masterConfig.mixerMode = MIXER_QUADX;
|
||||
|
||||
|
@ -657,6 +658,7 @@ static void resetConf(void)
|
|||
targetConfiguration();
|
||||
#endif
|
||||
|
||||
|
||||
// copy first profile into remaining profile
|
||||
for (int i = 1; i < MAX_PROFILE_COUNT; i++) {
|
||||
memcpy(&masterConfig.profile[i], currentProfile, sizeof(profile_t));
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#endif
|
||||
#define MAX_RATEPROFILES 3
|
||||
#define ONESHOT_FEATURE_CHANGED_DELAY_ON_BOOT_MS 1500
|
||||
#define MAX_NAME_LENGTH 16
|
||||
|
||||
|
||||
typedef enum {
|
||||
FEATURE_RX_PPM = 1 << 0,
|
||||
|
|
|
@ -161,6 +161,9 @@ typedef struct master_t {
|
|||
|
||||
uint8_t magic_ef; // magic number, should be 0xEF
|
||||
uint8_t chk; // XOR checksum
|
||||
|
||||
char name[MAX_NAME_LENGTH+1];
|
||||
|
||||
} master_t;
|
||||
|
||||
extern master_t masterConfig;
|
||||
|
|
|
@ -119,6 +119,7 @@ void cliDumpRateProfile(uint8_t rateProfileIndex) ;
|
|||
static void cliExit(char *cmdline);
|
||||
static void cliFeature(char *cmdline);
|
||||
static void cliMotor(char *cmdline);
|
||||
static void cliName(char *cmdline);
|
||||
static void cliPlaySound(char *cmdline);
|
||||
static void cliProfile(char *cmdline);
|
||||
static void cliRateProfile(char *cmdline);
|
||||
|
@ -340,6 +341,7 @@ const clicmd_t cmdTable[] = {
|
|||
#ifdef VTX
|
||||
CLI_COMMAND_DEF("vtx", "vtx channels on switch", NULL, cliVtx),
|
||||
#endif
|
||||
CLI_COMMAND_DEF("name", "Name of craft", NULL, cliName),
|
||||
};
|
||||
#define CMD_COUNT (sizeof(cmdTable) / sizeof(clicmd_t))
|
||||
|
||||
|
@ -1953,6 +1955,8 @@ static void cliDump(char *cmdline)
|
|||
cliPrint("\r\n# version\r\n");
|
||||
cliVersion(NULL);
|
||||
|
||||
cliPrint("\r\n# name\r\n");
|
||||
cliName(NULL);
|
||||
cliPrint("\r\n# dump master\r\n");
|
||||
cliPrint("\r\n# mixer\r\n");
|
||||
|
||||
|
@ -2494,6 +2498,24 @@ static void cliMotor(char *cmdline)
|
|||
cliPrintf("motor %d: %d\r\n", motor_index, motor_disarmed[motor_index]);
|
||||
}
|
||||
|
||||
static void cliName(char *cmdline)
|
||||
{
|
||||
|
||||
uint32_t len = strlen(cmdline);
|
||||
if (len == 0) {
|
||||
cliPrintf("name %s\r\n", masterConfig.name);
|
||||
} else if ('-' == cmdline[0]) {
|
||||
memset(masterConfig.name, '\0', MAX_NAME_LENGTH);
|
||||
cliPrintf("name removed\r\n");
|
||||
} else {
|
||||
memset(masterConfig.name, '\0', MAX_NAME_LENGTH);
|
||||
strncpy(masterConfig.name, cmdline, MIN(len, MAX_NAME_LENGTH));
|
||||
cliPrintf("name %s\r\n", masterConfig.name);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void cliPlaySound(char *cmdline)
|
||||
{
|
||||
#if FLASH_SIZE <= 64
|
||||
|
|
|
@ -659,7 +659,7 @@ static uint32_t packFlightModeFlags(void)
|
|||
static bool processOutCommand(uint8_t cmdMSP)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
uint8_t len;
|
||||
#ifdef GPS
|
||||
uint8_t wp_no;
|
||||
int32_t lat = 0, lon = 0;
|
||||
|
@ -750,6 +750,14 @@ static bool processOutCommand(uint8_t cmdMSP)
|
|||
serialize16(constrain(averageSystemLoadPercent, 0, 100));
|
||||
break;
|
||||
|
||||
case MSP_NAME:
|
||||
len = strlen(masterConfig.name);
|
||||
headSerialReply(len);
|
||||
for (uint8_t i=0; i<len; i++) {
|
||||
serialize8(masterConfig.name[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case MSP_STATUS:
|
||||
headSerialReply(11);
|
||||
serialize16(cycleTime);
|
||||
|
@ -1868,6 +1876,16 @@ static bool processInCommand(void)
|
|||
masterConfig.baro_hardware = read8();
|
||||
masterConfig.mag_hardware = read8();
|
||||
break;
|
||||
|
||||
case MSP_SET_NAME:
|
||||
memset(masterConfig.name, 0, MAX_NAME_LENGTH+1);
|
||||
for (i = 0; i < MIN(MAX_NAME_LENGTH, currentPort->dataSize); i++) {
|
||||
masterConfig.name[i] = read8();
|
||||
}
|
||||
if (masterConfig.name[0] == '-') {
|
||||
memset(masterConfig.name, '\0', MAX_NAME_LENGTH);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// we do not know how to handle the (valid) message, indicate error MSP $M!
|
||||
return false;
|
||||
|
|
|
@ -99,6 +99,10 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
|||
#define MSP_BOARD_INFO 4 //out message
|
||||
#define MSP_BUILD_INFO 5 //out message
|
||||
|
||||
#define MSP_NAME 10
|
||||
#define MSP_SET_NAME 11
|
||||
|
||||
|
||||
//
|
||||
// MSP commands for Cleanflight original features
|
||||
//
|
||||
|
@ -147,6 +151,23 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
|||
#define MSP_ARMING_CONFIG 61 //out message Returns auto_disarm_delay and disarm_kill_switch parameters
|
||||
#define MSP_SET_ARMING_CONFIG 62 //in message Sets auto_disarm_delay and disarm_kill_switch parameters
|
||||
|
||||
//
|
||||
// Baseflight MSP commands (if enabled they exist in Cleanflight)
|
||||
//
|
||||
#define MSP_RX_MAP 64 //out message get channel map (also returns number of channels total)
|
||||
#define MSP_SET_RX_MAP 65 //in message set rx map, numchannels to set comes from MSP_RX_MAP
|
||||
|
||||
// FIXME - Provided for backwards compatibility with configurator code until configurator is updated.
|
||||
// DEPRECATED - DO NOT USE "MSP_BF_CONFIG" and MSP_SET_BF_CONFIG. In Cleanflight, isolated commands already exist and should be used instead.
|
||||
#define MSP_BF_CONFIG 66 //out message baseflight-specific settings that aren't covered elsewhere
|
||||
#define MSP_SET_BF_CONFIG 67 //in message baseflight-specific settings save
|
||||
|
||||
#define MSP_REBOOT 68 //in message reboot settings
|
||||
|
||||
// DEPRECATED - Use MSP_BUILD_INFO instead
|
||||
#define MSP_BF_BUILD_INFO 69 //out message build date as well as some space for future expansion
|
||||
|
||||
|
||||
#define MSP_DATAFLASH_SUMMARY 70 //out message - get description of dataflash chip
|
||||
#define MSP_DATAFLASH_READ 71 //out message - get content of dataflash chip
|
||||
#define MSP_DATAFLASH_ERASE 72 //in message - erase dataflash chip
|
||||
|
@ -177,22 +198,6 @@ static const char * const boardIdentifier = TARGET_BOARD_IDENTIFIER;
|
|||
#define MSP_VTX_CONFIG 88 //in message Get vtx settings
|
||||
#define MSP_SET_VTX_CONFIG 89 //out message Set vtx settings
|
||||
|
||||
//
|
||||
// Baseflight MSP commands (if enabled they exist in Cleanflight)
|
||||
//
|
||||
#define MSP_RX_MAP 64 //out message get channel map (also returns number of channels total)
|
||||
#define MSP_SET_RX_MAP 65 //in message set rx map, numchannels to set comes from MSP_RX_MAP
|
||||
|
||||
// FIXME - Provided for backwards compatibility with configurator code until configurator is updated.
|
||||
// DEPRECATED - DO NOT USE "MSP_BF_CONFIG" and MSP_SET_BF_CONFIG. In Cleanflight, isolated commands already exist and should be used instead.
|
||||
#define MSP_BF_CONFIG 66 //out message baseflight-specific settings that aren't covered elsewhere
|
||||
#define MSP_SET_BF_CONFIG 67 //in message baseflight-specific settings save
|
||||
|
||||
#define MSP_REBOOT 68 //in message reboot settings
|
||||
|
||||
// DEPRECATED - Use MSP_BUILD_INFO instead
|
||||
#define MSP_BF_BUILD_INFO 69 //out message build date as well as some space for future expansion
|
||||
|
||||
// Betaflight Additional Commands
|
||||
#define MSP_PID_ADVANCED_CONFIG 90
|
||||
#define MSP_SET_PID_ADVANCED_CONFIG 91
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue