Skip to content

Conversation

@etracer65
Copy link
Member

Also change the element preview to use the default PIDs for the firmware version (as defined in the Configurator) so that the display is more representative of the actual values (and not display 20 for D on yaw!).

Related to betaflight/betaflight#10257

const i = pidDefaults[axis * 5 + 1].toString().padStart(3);
const d = pidDefaults[axis * 5 + 2].toString().padStart(3);
const f = pidDefaults[axis * 5 + 4].toString().padStart(3);
if (semver.lt(FC.CONFIG.apiVersion, "1.44.0")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (semver.lt(FC.CONFIG.apiVersion, "1.44.0")) {
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure how that's an improvement. There are 54 occurrences of a version check in just this file alone and only 6 of them use the suggested constant style. It seems to me that this adds unnecessary fragmentation. If a follow-on PR wants to address this and change to a consistent style throughout the code then that's fine with me, but out of scope for this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant was introduced with API_VERSION_1_43

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are adding the constants to any new code. I can do later a PR to change all of the old occurrences, but if we are adding new code is better to add the constant at this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just avoidance of magic numbers - in general they are bad coding style.

@etracer65 etracer65 force-pushed the update_osd_pid_element_preview branch from b02f629 to 9c48acb Compare October 7, 2020 19:06
Also change the element preview to use the default PIDs for the firmware version (as defined in the Configurator) so that the display is more representative of the actual values (and not display 20 for D on yaw!).
@etracer65 etracer65 force-pushed the update_osd_pid_element_preview branch from 9c48acb to ed292a9 Compare October 7, 2020 19:06
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 7, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mikeller mikeller merged commit b6d90c1 into betaflight:master Oct 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants