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

Ambient Light API #465

Merged
merged 7 commits into from
May 16, 2023
Merged

Ambient Light API #465

merged 7 commits into from
May 16, 2023

Conversation

DanutAldea
Copy link
Contributor

Pull Request Overview

This PR adds an Ambient Light API, which includes:

  • function for checking the existence of the driver
  • functions for initating readings of the luminance, registering and unregistering a listener
  • function for synchronous reading of values of luminance and 2 public functions for easier use of the API
  • unit tests

Alongside the API, this PR adds a fake driver (and unit tests for it) for testing the API.

Testing Strategy

This pull request was tested using unit tests made specifically for this API and fake driver.

TODO or Help Wanted

This pull request still needs feedback / code review.
Help is needed to test this on a board, as I do not have access to one which has a light sensor module
@hudson-ayers could you, please, test it on a imix

src/lib.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
@hudson-ayers
Copy link
Contributor

I tested this on Imix (using #466) and it appears to work correctly!

@alexandruradovici
Copy link
Contributor

Using cargo fmt should format this right next time.

apis/ambient_light/src/lib.rs Outdated Show resolved Hide resolved
apis/ambient_light/src/lib.rs Outdated Show resolved Hide resolved
apis/ambient_light/src/lib.rs Outdated Show resolved Hide resolved
@jrvanwhy jrvanwhy added the upkeep Indicates a PR is upkeep as defined by the code review policy. label May 2, 2023

/// Register an events listener
pub fn register_listener<'share>(
listener: &'share Cell<Option<(u32,)>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we did this wrong here. We need to be able to register a listener that the user can actually use outside this crate, meaning that the listener needs to have a function that is called when the upcall is fired.

Something similar to the ButtonListener should work.

Copy link
Collaborator

@jrvanwhy jrvanwhy left a comment

Choose a reason for hiding this comment

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

bors r+

@bors
Copy link
Contributor

bors bot commented May 16, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit be72de6 into tock:master May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upkeep Indicates a PR is upkeep as defined by the code review policy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants