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

Add more configuration options #5

Open
thedevleon opened this issue Jun 26, 2023 · 3 comments
Open

Add more configuration options #5

thedevleon opened this issue Jun 26, 2023 · 3 comments
Labels
good first issue Good for newcomers

Comments

@thedevleon
Copy link

thedevleon commented Jun 26, 2023

Coming from Zephyr (and it's BMI160 library), there are two features that seem to be missing that would be really nice to have:

@eldruin
Copy link
Owner

eldruin commented Jun 27, 2023

Sounds like a nice project. I would welcome this in a PR.

@eldruin eldruin added the good first issue Good for newcomers label Jun 27, 2023
rland93 added a commit to rland93/bmi160-rs that referenced this issue Jan 20, 2024
rland93 added a commit to rland93/bmi160-rs that referenced this issue Jan 20, 2024
rland93 added a commit to rland93/bmi160-rs that referenced this issue Jan 20, 2024
rland93 added a commit to rland93/bmi160-rs that referenced this issue Feb 8, 2024
eldruin pushed a commit that referenced this issue May 2, 2024
* /issues/5 Add accel, gyro range and types

* /issues/5 Changelog and README with range types and methods

* Add function get scaled output values

* Adress review comments

* Update changelog

* Address review comments from #8

* Add tests for setting gyro and acc range

* Add integration test

---------

Co-authored-by: Mike <[email protected]>
@avsaase
Copy link
Contributor

avsaase commented May 2, 2024

#9 added functions to set the gyro and acc scales and read the scaled sensor values.

I'm now looking into setting the ACC_CONF and GYR_CONF values and I'm looking for ideas for a good API.

The ACC_CONF register has one bit for the undersampling mode, three bits for the bandwidth parameter and four for the ODR. The challenge is that the setting of the undersampling mode affects the meaning of the the bandwidth parameter. When undersampling is disabled, the bandwidth parameter controls the filter mode (normal, OSR2, OSR4). When undersampling is enabled, the bandwidth parameter controls how many samples are averaged (twelve possible values).

I was thinking this relationship could be captured with enums:

struct AccelerometerConfig {
    undersampling_mode: AccelerometerUndersamplingMode,
    output_data_rate: AccelerometerOutputDataRate
}

enum AccelerometerUndersamplingMode {
    Disabled(FilterMode),
    Enabled(AveragedSamples),
}

enum FilterMode {
    Normal,
    OSR2,
    OSR4,
}

enum AveragedSamples {
    One,
    Two,
    Four,
    // etc
}

enum AccelerometerOutputDataRate {
    Odr25Hz,
    Odr50Hz,
    // etc.
}

This feels a little clunky so I'm open to alternatives.

The GYR_CONF register is a bit simpler because it does not have an undersampling mode.

@eldruin
Copy link
Owner

eldruin commented May 5, 2024

That is also what I thought of. I could not immediately think of something simpler that does not lead to returning InvalidInputData errors just for the sake of a "simpler" interface. Also, maybe the user code does not feel as clunky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants