Skip to content

Conversation

@MrD-RC
Copy link
Member

@MrD-RC MrD-RC commented Oct 27, 2025

User description

See Configurator PR for details


PR Type

Enhancement


Description

  • Rename OSD_VARIO_NUM enum to OSD_VERTICAL_SPEED_INDICATOR

  • Update all references across OSD menu, layout config, and DJI HD mapping

  • Add documentation comments for velocity calculation functions

  • Update OSD documentation to reflect new naming convention


Diagram Walkthrough

flowchart LR
  A["OSD_VARIO_NUM<br/>enum constant"] -->|rename| B["OSD_VERTICAL_SPEED_INDICATOR<br/>enum constant"]
  B --> C["Menu entries<br/>cms_menu_osd.c"]
  B --> D["Case handlers<br/>osd.c"]
  B --> E["Layout config<br/>osd.c"]
  B --> F["DJI mapping<br/>osd_dji_hd.c"]
  B --> G["Documentation<br/>OSD.md"]
Loading

File Walkthrough

Relevant files
Enhancement
cms_menu_osd.c
Update menu entry enum constant                                                   

src/main/cms/cms_menu_osd.c

  • Updated OSD menu entry from OSD_VARIO_NUM to
    OSD_VERTICAL_SPEED_INDICATOR
  • Menu label remains "VARIO NUM" for UI consistency
+1/-1     
osd.c
Update case handler and layout config                                       

src/main/io/osd.c

  • Renamed case statement from OSD_VARIO_NUM to
    OSD_VERTICAL_SPEED_INDICATOR
  • Updated layout configuration array index reference
  • Updated comment to reflect new naming
+3/-3     
osd.h
Rename enum constant definition                                                   

src/main/io/osd.h

  • Renamed enum member from OSD_VARIO_NUM to OSD_VERTICAL_SPEED_INDICATOR
  • Maintains same position in enum definition
+1/-1     
osd_dji_hd.c
Update DJI HD OSD mapping                                                               

src/main/io/osd_dji_hd.c

  • Updated DJI OSD mapping from OSD_VARIO_NUM to
    OSD_VERTICAL_SPEED_INDICATOR
  • Comment updated to reference OSD_NUMERICAL_VARIO
+1/-1     
Documentation
osd_common.c
Add velocity function documentation                                           

src/main/io/osd_common.c

  • Added documentation comment for osdGet3DSpeed() function
  • Clarifies that function returns 3D speed in cm/s
+3/-0     
pitotmeter.c
Add airspeed function documentation                                           

src/main/sensors/pitotmeter.c

  • Added documentation comment for getAirspeedEstimate() function
  • Clarifies that function returns airspeed estimate in cm/s
+3/-0     
OSD.md
Update documentation table                                                             

docs/OSD.md

  • Updated OSD element table entry from OSD_VARIO_NUM to
    OSD_VERTICAL_SPEED_INDICATOR
  • Maintains version and other metadata
+1/-1     

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Oct 27, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Oct 27, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Avoid premature type casting to float
Suggestion Impact:The commit changed both vert_speed and hor_speed to float, matching the suggestion (with an explicit cast for hor_speed), thus preserving precision before the calculation.

code diff:

-    int16_t vert_speed = getEstimatedActualVelocity(Z);
-    int16_t hor_speed = gpsSol.groundSpeed;
+    float vert_speed = getEstimatedActualVelocity(Z);
+    float hor_speed = (float)gpsSol.groundSpeed;
     return (int16_t)calc_length_pythagorean_2D(hor_speed, vert_speed);

In osdGet3DSpeed, declare vert_speed and hor_speed as float to prevent loss of
precision from premature casting before the Pythagorean calculation.

src/main/io/osd_common.c [202-207]

 int16_t osdGet3DSpeed(void)
 {
-    int16_t vert_speed = getEstimatedActualVelocity(Z);
-    int16_t hor_speed = gpsSol.groundSpeed;
+    float vert_speed = getEstimatedActualVelocity(Z);
+    float hor_speed = gpsSol.groundSpeed;
     return (int16_t)calc_length_pythagorean_2D(hor_speed, vert_speed);
 }

[Suggestion processed]

Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a loss of precision by prematurely casting a float return value to int16_t before a calculation, and the proposed change improves the accuracy of the result.

Medium
High-level
Re-evaluate the necessity of this rename

Consider reverting the rename of OSD_VARIO_NUM to OSD_VERTICAL_SPEED_INDICATOR.
The new name is overly verbose and creates inconsistencies with the UI label and
DJI OSD mapping, which both still refer to "vario".

Examples:

src/main/io/osd.h [200]
    OSD_VERTICAL_SPEED_INDICATOR,
src/main/cms/cms_menu_osd.c [229]
    OSD_ELEMENT_ENTRY("VARIO NUM", OSD_VERTICAL_SPEED_INDICATOR),

Solution Walkthrough:

Before:

// src/main/io/osd.h
typedef enum {
    ...
    OSD_VERTICAL_SPEED_INDICATOR,
    ...
} osd_items_e;

// src/main/cms/cms_menu_osd.c
...
OSD_ELEMENT_ENTRY("VARIO NUM", OSD_VERTICAL_SPEED_INDICATOR),
...

// src/main/io/osd_dji_hd.c
...
{ OSD_VERTICAL_SPEED_INDICATOR, 0 }, // DJI: OSD_NUMERICAL_VARIO
...

After:

// src/main/io/osd.h
typedef enum {
    ...
    OSD_VARIO_NUM,
    ...
} osd_items_e;

// src/main/cms/cms_menu_osd.c
...
OSD_ELEMENT_ENTRY("VARIO NUM", OSD_VARIO_NUM),
...

// src/main/io/osd_dji_hd.c
...
{ OSD_VARIO_NUM, 0 }, // DJI: OSD_NUMERICAL_VARIO
...
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies that the rename introduces inconsistencies between the internal enum name, the user-facing UI label ("VARIO NUM"), and the related DJI OSD element name, questioning the overall benefit of the change.

Low
  • Update

- Missed CMS menu text. That now reflects VSI
- Fixed bug highlighted by the AI bot on GitHub
@MrD-RC
Copy link
Member Author

MrD-RC commented Oct 27, 2025

Avoid premature type casting to float
Wasn't a bug caused by this PR. But I've fixed it anyway.

Re-evaluate the necessity of this rename
That's the whole point of this PR! The new name is more appropriate. AI thinks it's verbose. Human thinks it's easier to read and understand. There are no inconsistencies with the UI.

@MrD-RC MrD-RC merged commit f3ac525 into master Oct 27, 2025
22 checks passed
@MrD-RC MrD-RC deleted the MrD_Chang-Vario-to-Vertical-Speed-Indicator branch October 27, 2025 21:22
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.

2 participants