mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 05:15:25 +03:00
Rename 'display_name' to 'pilot_name'; rename 'name' to 'craft_name'; Add the 'MSP2_GET_TEXT' and 'MSP2_SET_TEXT' MSP commands
- add the 'MSP2_GET_TEXT' and 'MSP2_SET_TEXT' MSP2 commands - Support getting/setting the 'MSP2TEXT_PILOT_DISPLAY_NAME' config prop ('pilotConfigMutable()->displayName') - rename 'display_name' to 'pilot_name' - Add the new 'OSD_PILOT_NAME' OSD element in place of the 'OSD_DISPLAY_NAME' one (as they are semantically identical) - Add the 'osd_pilot_name_pos' cli prop in place of 'osd_display_name_pos' - rename 'pilotConfigMutable()'s 'name' to 'craftName' - remove the legacy 'GET_NAME' / 'SET_NAME' MSP commands - replace the 'name' CLI prop for 'craft_name' - add the 'MSP2TEXT_CRAFT_NAME' constant for 'MSP2_GET_TEXT' and 'MSP2_SET_TEXT'
This commit is contained in:
parent
aafcd26fb5
commit
e7df32f020
12 changed files with 99 additions and 49 deletions
|
@ -1140,15 +1140,6 @@ static bool mspProcessOutCommand(mspDescriptor_t srcDesc, int16_t cmdMSP, sbuf_t
|
|||
}
|
||||
break;
|
||||
|
||||
case MSP_NAME:
|
||||
{
|
||||
const int nameLen = strlen(pilotConfig()->name);
|
||||
for (int i = 0; i < nameLen; i++) {
|
||||
sbufWriteU8(dst, pilotConfig()->name[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
case MSP_SERVO:
|
||||
sbufWriteData(dst, &servo, MAX_SUPPORTED_SERVOS * 2);
|
||||
|
@ -2487,6 +2478,38 @@ static mspResult_e mspFcProcessOutCommandWithArg(mspDescriptor_t srcDesc, int16_
|
|||
}
|
||||
|
||||
break;
|
||||
|
||||
case MSP2_GET_TEXT:
|
||||
{
|
||||
// type byte, then length byte followed by the actual characters
|
||||
const uint8_t textType = sbufBytesRemaining(src) ? sbufReadU8(src) : 0;
|
||||
|
||||
char* textVar;
|
||||
|
||||
switch (textType) {
|
||||
case MSP2TEXT_PILOT_NAME:
|
||||
textVar = pilotConfigMutable()->pilotName;
|
||||
break;
|
||||
|
||||
case MSP2TEXT_CRAFT_NAME:
|
||||
textVar = pilotConfigMutable()->craftName;
|
||||
break;
|
||||
|
||||
default:
|
||||
return MSP_RESULT_ERROR;
|
||||
}
|
||||
|
||||
const uint8_t textLength = strlen(textVar);
|
||||
|
||||
// type byte, then length byte followed by the actual characters
|
||||
sbufWriteU8(dst, textType);
|
||||
sbufWriteU8(dst, textLength);
|
||||
for (unsigned int i = 0; i < textLength; i++) {
|
||||
sbufWriteU8(dst, textVar[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return MSP_RESULT_CMD_UNKNOWN;
|
||||
}
|
||||
|
@ -3760,16 +3783,6 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
|
|||
break;
|
||||
#endif
|
||||
|
||||
case MSP_SET_NAME:
|
||||
memset(pilotConfigMutable()->name, 0, ARRAYLEN(pilotConfig()->name));
|
||||
for (unsigned int i = 0; i < MIN(MAX_NAME_LENGTH, dataSize); i++) {
|
||||
pilotConfigMutable()->name[i] = sbufReadU8(src);
|
||||
}
|
||||
#ifdef USE_OSD
|
||||
osdAnalyzeActiveElements();
|
||||
#endif
|
||||
break;
|
||||
|
||||
#ifdef USE_RTC_TIME
|
||||
case MSP_SET_RTC:
|
||||
{
|
||||
|
@ -3840,6 +3853,40 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
|
|||
|
||||
break;
|
||||
#endif
|
||||
|
||||
case MSP2_SET_TEXT:
|
||||
{
|
||||
// type byte, then length byte followed by the actual characters
|
||||
const uint8_t textType = sbufReadU8(src);
|
||||
|
||||
char* textVar;
|
||||
const uint8_t textLength = MIN(MAX_NAME_LENGTH, sbufReadU8(src));
|
||||
switch (textType) {
|
||||
case MSP2TEXT_PILOT_NAME:
|
||||
textVar = pilotConfigMutable()->pilotName;
|
||||
break;
|
||||
|
||||
case MSP2TEXT_CRAFT_NAME:
|
||||
textVar = pilotConfigMutable()->craftName;
|
||||
break;
|
||||
|
||||
default:
|
||||
return MSP_RESULT_ERROR;
|
||||
}
|
||||
|
||||
memset(textVar, 0, strlen(textVar));
|
||||
for (unsigned int i = 0; i < textLength; i++) {
|
||||
textVar[i] = sbufReadU8(src);
|
||||
}
|
||||
|
||||
#ifdef USE_OSD
|
||||
if (textType == MSP2TEXT_PILOT_NAME || textType == MSP2TEXT_CRAFT_NAME) {
|
||||
osdAnalyzeActiveElements();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// we do not know how to handle the (valid) message, indicate error MSP $M!
|
||||
return MSP_RESULT_ERROR;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue