Skip to content

feat: update PowerManagement voltage calculation logic#74

Merged
Jshepherd06 merged 10 commits intomainfrom
voltageReader
Feb 7, 2026
Merged

feat: update PowerManagement voltage calculation logic#74
Jshepherd06 merged 10 commits intomainfrom
voltageReader

Conversation

@Jshepherd06
Copy link
Contributor

@Jshepherd06 Jshepherd06 commented Feb 6, 2026

Description

Summary of Changes

  • Update the voltage calculation logic for PowerManegement.h

Motivation

  • Allows for accurate voltage readings during launch

Testing

Check all that apply:

  • I have added or modified tests to cover these changes.
  • [ x ] I have manually tested the changes on the target device(s) or environment(s).
  • Existing tests were reviewed to ensure they still work as expected.
  • If tests were not added or modified, explain why:

    (Provide reasoning here)


Building

  • This change successfully builds in at least one of the following environments:
    • Native repo
    • [ x ] Target device(s) (e.g., MARTHA)
  • If the build fails in any environment, explain why:

    (Provide reasoning here)


Checklist

  • [ x ] My code follows the style guidelines of this project.
  • [ x ] I have performed a self-review of my own code.
  • [ x ] I have commented my code where necessary for clarity.
  • [ x ] I have made corresponding updates to documentation (if applicable).

@Jshepherd06 Jshepherd06 requested a review from Elan456 February 6, 2026 15:16
Copy link
Contributor

@Elan456 Elan456 Feb 6, 2026

Choose a reason for hiding this comment

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

We can't include Arduino.h or pins.h within Avionics because it breaks Native compatibility and assumes the fight computer has a pins.h . We don't need pins.h because the pin is passed in.

You should always use ArduinoHAL.h instead of Arduino.h within Avionics

If you add a test in Native, you'll see that analogReadResolution doesn't exists in ArduinoHAL.h yet, so it'll needed to be added. Basically, you just need to put a mock version of the function analogReadResolution in HAL. The same problem will be there for analogRead(pin) and you can have that just return a hard coded value in HAL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have made changes to ArduinoHAL and tested powermanagement in native. Im not sure if i understand this right, but the functions in arduinoHAL are just to simulate arduino for testing, right? Does the normal version of Arduino.h get used when running avionics on martha?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also ive pushed some tests for powermanagement to native, if you want to check them. not sure what else to test

Copy link
Contributor

@Elan456 Elan456 Feb 7, 2026

Choose a reason for hiding this comment

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

You're correct, ArduinoHAL checks if you are actually on an Arduino or not. If you are on a real Arduino, it uses the real functions, otherwise it redirects to the mocks.

@Elan456 Elan456 self-requested a review February 7, 2026 19:25
Copy link
Contributor

@Elan456 Elan456 left a comment

Choose a reason for hiding this comment

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

Looks good. Awesome work!

Merge whenever

@Jshepherd06 Jshepherd06 merged commit 12e9db6 into main Feb 7, 2026
4 of 5 checks passed
@Elan456 Elan456 deleted the voltageReader branch February 11, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants