-
-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'Pilot name' to the Configurator UI; rename 'Display name' to 'Pilot name'; rename 'name' to 'craft_name' #2798
Add 'Pilot name' to the Configurator UI; rename 'Display name' to 'Pilot name'; rename 'name' to 'craft_name' #2798
Conversation
@@ -4920,7 +4920,7 @@ | |||
"description": "One of the elements of the OSD" | |||
}, | |||
"osdDescElementCraftName": { | |||
"message": "Craft name as set in Configuration tab" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question to the reviewers:
Given that I changed some of the current en
texts - should I do anything extra for all other translations?
Looking at #2791 I suspect I might have to manually remove them for now from all language files (so they can be re-translated in the future).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this will be done automatically. Crowdin will delete the translations in the next language files update.
3473a6f
to
89cf105
Compare
89cf105
to
26c9e75
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This comment has been minimized.
This comment has been minimized.
I really like this |
AUTOMERGE: (FAIL)
|
c4d26c0
26c9e75
to
c4d26c0
Compare
This comment has been minimized.
This comment has been minimized.
d380495
to
6389c70
Compare
This comment has been minimized.
This comment has been minimized.
@krasiyan... |
Thank you very much for testing @ctzsnooze @haslinghuis ! And sorry for the omissions on my side! As for:
Before the current MR (thus MSP v1.45) we didn't have an input field for As for it missing in the OSD tab - I will try to reproduce this issue since I can see it on an older 4.2.6 firmware running MSP v1.43:
Do you recall which MSP/Betaflight version you used? @haslinghuis As for the backwards compatibility around However I agree that if we keep |
@krasiyan @haslinghuis I thought I was testing 4.3 firmware, but by mistake the quad had an early 4.4 flashed. When testing with 'real' 4.3 firmware, it seems perfectly OK; I see 'Craft Name' in OSD and Configuration tab, the correct name appears, and it all works properly. My bad. I can't find a problem now I'm testing properly. It seems to me that nothing needs to be changed, other than for readability or ease of maintenance. Apologies. |
@krasiyan @haslinghuis = please post a note here when you're happy it's good to go. |
6389c70
to
1032f57
Compare
@ctzsnooze No worries - I also confused myself at least several times while trying to set the right names everywhere 😅 @haslinghuis I pushed the latest changes as per your recommendations and re-tested locally with a current and an older firmware - so far I also couldn't find any regressions :) Nevertless - don't hesitate to let me know if you notice anything off ^^ |
…lot name'; rename 'name' to 'craft_name' - add pilot name (display_name) to the Configuration tab - add handling for the 'MSP2_GET_TEXT' and 'MSP2_SET_TEXT' commands - with support for the 'MSP2TEXT_PILOT_DISPLAY_NAME' ('displayName') config prop - backup handling of the 'displayName' config prop - add a text field to configure the pilot name in the 'Configuration/Personalization' box - using the 'display_name' FC config prop and the 'MSP2_GET_TEXT' / 'MSP2_SET_TEXT' MSP commands - add tooltips for both the 'Craft name' and 'Pilot name' fileds - rename the 'Display name' OSD element to 'Display name (Pilot name)' - expand the tooltip descriptions of 'Craft name' and 'Display name (Pilot name)' - change the default 'DISPLAY_NAME' OSD element preview to 'PILOT_NAME' - remove the default 'JOE PILOT' string value of the 'displayName' FC initial config - backwards compatibility handling for 'display_name' pre MSP v1.45 - rename 'display name' to 'pilot name' - add 'FC.CONFIG.pilotName' in place of 'FC.CONFIG.displayName' - add the 'PILOT_NAME' OSD element and keep backwards compatibility for the 'DISPLAY_NAME' OSD element (depending on the MSP version) - rename 'FC.CONFIG.name' to 'FC.CONFIG.craftName' - add the 'MSP2TEXT_CRAFT_NAME' const for 'MSP2_GET_TEXT' / 'MSP2_SET_TEXT' - use 'MSP2_GET_TEXT' / 'MSP2_SET_TEXT' to get/set 'FC.CONFIG.craftName' - keep full backwards compatibility pre MSP v1.45 (using the legacy 'MSP_NAME' / 'MSP_SET_NAME')
1032f57
to
3873f82
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@haslinghuis I loooked into this. Dunno much about sonar, but when I looked into these kind of things, often they are caused by having quite a few helper functions declared in the scope of the parent function. So solution would be to move them out to make them pure functions. When doing massive changes these are pain in the bum... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for nice explanation @krasiyan 😊
I just have some questions about code style, but those are minor things.
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { | ||
configuration.CRAFT_NAME = FC.CONFIG.craftName; | ||
configuration.PILOT_NAME = FC.CONFIG.pilotName; | ||
} else { | ||
configuration.CRAFT_NAME = FC.CONFIG.name; | ||
configuration.DISPLAY_NAME = FC.CONFIG.displayName; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno, might be a stupid suggestion. But given that we have different names for fields, we could avoid version check by doing something like:
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { | |
configuration.CRAFT_NAME = FC.CONFIG.craftName; | |
configuration.PILOT_NAME = FC.CONFIG.pilotName; | |
} else { | |
configuration.CRAFT_NAME = FC.CONFIG.name; | |
configuration.DISPLAY_NAME = FC.CONFIG.displayName; | |
} | |
configuration.CRAFT_NAME = FC.CONFIG.craftName ?? FC.CONFIG.name; | |
configuration.PILOT_NAME = FC.CONFIG.pilotName ?? ''; | |
configuration.DISPLAY_NAME = FC.CONFIG.displayName ?? ''; |
But this is up for discussion though.
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) | ||
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything returned from Promise
is automatically wrapped in promise. Hence resolve
is redundant.
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) | |
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); | |
return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) | |
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : true; |
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { | ||
FC.CONFIG.craftName = configuration.CRAFT_NAME; | ||
FC.CONFIG.pilotName = configuration.PILOT_NAME; | ||
} else { | ||
FC.CONFIG.name = configuration.CRAFT_NAME; | ||
FC.CONFIG.displayName = configuration.DISPLAY_NAME; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one could similary be refactored to use ??
and defaulting to things. Again up for discussion.
const craftName = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) | ||
? FC.CONFIG.craftName | ||
: FC.CONFIG.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar here, technically these two are mutually exclusive
const craftName = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) | |
? FC.CONFIG.craftName | |
: FC.CONFIG.name; | |
const craftName = FC.CONFIG.craftName ?? FC.CONFIG.name; |
MSP_NAME: 10, // DEPRECATED IN MSP 1.45 | ||
MSP_SET_NAME: 11, // DEPRECATED IN MSP 1.45 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno if it will work straight away, but we could use jsdoc to add some intelissense about these.
MSP_NAME: 10, // DEPRECATED IN MSP 1.45 | |
MSP_SET_NAME: 11, // DEPRECATED IN MSP 1.45 | |
/** | |
* @deprecated in MSP >= 1.45 | |
*/ | |
MSP_NAME: 10, | |
/** | |
* @deprecated in MSP >= 1.45 | |
*/ | |
MSP_SET_NAME: 11, |
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.20.0") ? MSP.promise(MSPCodes.MSP_NAME) : true; }) | ||
.then(() => { return semver.gte(FC.CONFIG.apiVersion, "1.20.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45) | ||
? MSP.promise(MSPCodes.MSP_NAME) | ||
: Promise.resolve(true); }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: Promise.resolve(true); }) | |
: true; }) |
: Promise.resolve(true); }) | ||
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) | ||
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME)) | ||
: Promise.resolve(true); }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: Promise.resolve(true); }) | |
: true; }) |
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31) ? MSP.promise(MSPCodes.MSP_RX_CONFIG) : true; }) | ||
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) | ||
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); }) | |
? MSP.promise(MSPCodes.MSP2_GET_TEXT, mspHelper.crunch(MSPCodes.MSP2_GET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : true; }) |
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { | ||
$('input[name="craftName"]').val(FC.CONFIG.craftName); | ||
$('input[name="pilotName"]').val(FC.CONFIG.pilotName); | ||
} else { | ||
$('input[name="craftName"]').val(FC.CONFIG.name); | ||
$('.pilotName').hide(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { | |
$('input[name="craftName"]').val(FC.CONFIG.craftName); | |
$('input[name="pilotName"]').val(FC.CONFIG.pilotName); | |
} else { | |
$('input[name="craftName"]').val(FC.CONFIG.name); | |
$('.pilotName').hide(); | |
} | |
$('input[name="craftName"]').val(FC.CONFIG.craftName ?? FC.CONFIG.name); | |
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { | |
$('input[name="pilotName"]').val(FC.CONFIG.pilotName); | |
} else { | |
$('.pilotName').hide(); | |
} |
? MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_CRAFT_NAME)) | ||
: MSP.promise(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME)); }) | ||
.then(() => { return semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) ? | ||
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : Promise.resolve(true); }) | |
MSP.promise(MSPCodes.MSP2_SET_TEXT, mspHelper.crunch(MSPCodes.MSP2_SET_TEXT, MSPCodes.MSP2TEXT_PILOT_NAME)) : true; }) |
Do you want to test this code? Here you have an automated build: |
Fixes #1877
Related firmware changes @ betaflight/betaflight#11391
scope
This PR renames:
Display name
OSD / configuration element (and the internalFC.CONFIG.displayName
) toPilot name
(henceFC.CONFIG.pilotName
).FC.CONFIG.name
toFC.CONFIG.craftName
(with no functional impact)It also adds the option to set the
pilot name
through the configurator UI. The value can be show in the OSD (independently of the current craft name which can already be managed through the configurator UI).See the commit messages for further details around the changes.
backwards compatibility
The configurator should still be backwards compatible with firmwares running MSP older than
v1.45
:DISPLAY_NAME
andPILOT_NAME
OSD elements have the same position within the elements list and are also semantically identicalDisplay name
element is still shown only on MSP versions beforev1.45
(and the newPilot name
element is not visible) - e.g:display_name
value - however it cannot be previewed nor managed through the UI.Pilot name
element is shown only on MSP versions greater or equal tov1.45
(and the oldDisplay name
element is not visible) - e.g:pilot_name
value - which can both be previewed and managed through the UI.In addition, the
craftName
(ex.name
) property will be retrieved set via:MSP_NAME
/MSP_SET_NAME
for MSP versions beforev1.45
MSP2_GET_TEXT
/MSP_SET_TEXT
for MSPv1.45
or greaterTesting:
Virtual Mode
. However that will not let you persist any changes.yarn start
(I can also try to provide a build for a specific platform but I might not be able to test it myself)Configuration
andOSD
tabs.Screenshots: