Skip to content
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

[Electron] Power management #1412

Merged
merged 9 commits into from
Nov 6, 2017

Conversation

avtolstoy
Copy link
Member

submission notes
**Important:** Please sanitize/remove any confidential info like usernames, passwords, org names, product names/ids, access tokens, client ids/secrets, or anything else you don't wish to share.

Please Read and Sign the Contributor License Agreement ([Info here](https://github.com/spark/firmware/blob/develop/CONTRIBUTING.md)).

You may also delete this submission notes header if you'd like. Thank you for contributing!

Solution

This PR:

  • Adds DIAG_ID_SYSTEM_POWER_SOURCE diagnostics data source:
    • POWER_SOURCE_UNKNOWN = 0
      • Default value
    • POWER_SOURCE_VIN = 1
      • The device is being powered by VIN pin or a non-compliant USB-charger
    • POWER_SOURCE_USB_HOST = 2
      • The device is being powered by a USB Host
    • POWER_SOURCE_USB_ADAPTER = 3
      • The device is being powered by a compliant USB-charger
    • POWER_SOURCE_USB_OTG = 4
      • The device is being powered by an USB-OTG device (e.g. phone, tablet etc)
    • POWER_SOURCE_BATTERY = 5
      • The device is being powered from battery (battery state diagnostic should indicate BATTERY_STATE_DISCHARGING)
  • Introduces a number of changes to Electron's power management (TODO: write documentation explaining new behavior and peculiarities)
  • Adds new battery state BATTERY_STATE_DISCONNECTED
  • Adds two new system events that replicate battery state and power source diagnostic data sources:
    • battery_state
    • power_source
  • Modifies battery state of charge diagnostic to report logical value based on termination voltage (upper bound) and fixed (physical 20% of charge) lower bound (see https://github.com/spark/firmware/compare/feature/diagnostics-merge...feature/power-management?expand=1#diff-1138d49e8c7669f2b798c130b6a61046R89)

Steps to Test

N/A

Example App

N/A

References


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

- Implements getInputCurrentLimit()
- Adds getChargeVoltageValue() returning voltage
- Adds getRechargeThreshold()/setRechargeThreshold()
charge value based on termination voltage (upper bound) and 20% of
physcial charge (lower bound).
- Adds DISCONNECTED state to battery_state_t
- Adds power_source_t definition
- Adds particle::SimpleEnumDiagnosticData<particle::power::power_source_t> diagnostic source
- Fixes DISCONNECTED battery state detection
- Adds DIAG_ID_SYSTEM_POWER_SOURCE diagnostic source implementation
…ark_Idle_Events or listening mode event loop
Copy link
Member

@technobly technobly left a comment

Choose a reason for hiding this comment

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

There is a lot going on here :) Most everything looks good to me, but I fear that staring at it will not be enough to know how well everything works. This one screams for some on-device tests to be added. I would love to see some of the conversion functions validated via unit tests as well, like getNormalizedSoC() and getChargeVoltageValue(). Also a comment about what the default setRechargeThreshold() is be welcome. We'll also need Documentation straight away for this as it's a fairly big change. We also switched from power.disableDPDM(); to power.enableDPDM(); and I would like to know how this has been tested and what effects it will have on USB power sources and also USB power banks / USB wall adapters.

@m-mcgowan m-mcgowan added this to the 0.8.0 milestone Nov 6, 2017
@m-mcgowan m-mcgowan merged commit e36f33b into feature/diagnostics-merge Nov 6, 2017
@mrlambchop mrlambchop deleted the feature/power-management branch October 26, 2023 23:58
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.

3 participants