Skip to content

Conversation

@sensei-hacker
Copy link
Collaborator

@sensei-hacker sensei-hacker commented Jul 26, 2025

User description

Uses the external (compass) i2c bus if UG2864_I2C_BUS isn't defined. Otherwise, the default i2c bus.
Rather than i2c1.


PR Type

Enhancement


Description

This description is generated by an AI tool. It may have inaccuracies

  • Improved default I2C bus selection for UG2864 OLED display

  • Uses magnetometer I2C bus when available, falls back to default I2C bus

  • Replaces hardcoded BUS_I2C1 with more flexible bus selection logic


Diagram Walkthrough

flowchart LR
  A["UG2864_I2C_BUS undefined"] --> B["Check MAG_I2C_BUS"]
  B --> C["MAG_I2C_BUS available?"]
  C -->|Yes| D["Use MAG_I2C_BUS"]
  C -->|No| E["Use DEFAULT_I2C_BUS"]
  D --> F["Configure UG2864 display"]
  E --> F
Loading

File Walkthrough

Relevant files
Enhancement
common_hardware.c
Enhanced I2C bus selection logic                                                 

src/main/target/common_hardware.c

  • Replaced hardcoded BUS_I2C1 with conditional logic
  • Added fallback hierarchy: MAG_I2C_BUSDEFAULT_I2C_BUS
  • Improved I2C bus selection for UG2864 OLED display configuration
+6/-1     

@sensei-hacker sensei-hacker marked this pull request as ready for review October 11, 2025 16:40
@qodo-merge-pro
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Build-time config conflict

Description: The macro-based fallback may redefine UG2864_I2C_BUS differently across compilation units
if headers also define it, potentially causing inconsistent hardware bus selection at
build time.
common_hardware.c [428-435]

Referred Code
#if !defined(UG2864_I2C_BUS)
    #ifdef MAG_I2C_BUS
        #define UG2864_I2C_BUS MAG_I2C_BUS
   #else
        #define UG2864_I2C_BUS DEFAULT_I2C_BUS
   #endif

#endif
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
No custom compliance provided

Follow the guide to enable custom compliance check.

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

@qodo-merge-pro
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add fallback to prevent build failures

Add a fallback to BUS_I2C1 for the UG2864_I2C_BUS definition to prevent
potential build failures when neither MAG_I2C_BUS nor DEFAULT_I2C_BUS are
defined.

src/main/target/common_hardware.c [429-430]

-#ifdef MAG_I2C_BUS
+#if defined(MAG_I2C_BUS)
     #define UG2864_I2C_BUS MAG_I2C_BUS
+#elif defined(DEFAULT_I2C_BUS)
+    #define UG2864_I2C_BUS DEFAULT_I2C_BUS
+#else
+    #define UG2864_I2C_BUS BUS_I2C1
+#endif
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential build failure if DEFAULT_I2C_BUS is undefined and provides a more robust fallback mechanism, improving the reliability of the configuration.

Medium
  • More

@sensei-hacker sensei-hacker merged commit 2ad2f49 into iNavFlight:maintenance-8.x.x Oct 12, 2025
21 checks passed
@MrD-RC MrD-RC added this to the 9.0 milestone Oct 26, 2025
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