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 LIS3DH sensor #1954

Merged
merged 3 commits into from Oct 7, 2022
Merged

Add LIS3DH sensor #1954

merged 3 commits into from Oct 7, 2022

Conversation

krwq
Copy link
Member

@krwq krwq commented Oct 6, 2022

Add binding for LIS3DH accelerometer.

Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Oct 6, 2022
Comment on lines +165 to +169
// Note: While we theoretically should divide by 16 here,
// according to my measurements the actual divisor is around 24:
// When 24 is used measurements match other scales and 1G is closer to 1G rather than 0.64G.
// I was not able to find section in datasheet explaining why this is 24 (exactly 50% more).
AccelerationScale.Scale16G => Max / 24,
Copy link
Member Author

@krwq krwq Oct 6, 2022

Choose a reason for hiding this comment

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

v-beer for anyone who can find something about this in the spec

Copy link
Member

@Ellerbach Ellerbach 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 all up, few comments

/// <inheritdoc/>
public override void Dispose()
{
_i2c?.Dispose();
Copy link
Member

Choose a reason for hiding this comment

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

We are not supposed to dispose I2cDevice.

Copy link
Member Author

@krwq krwq Oct 6, 2022

Choose a reason for hiding this comment

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

don't we do that in other bindings? I've copy & pasted the template for this binding including this specific line of code. I2cDevice is not much reusable

Copy link
Member Author

Choose a reason for hiding this comment

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

_i2c?.Dispose();

_i2c?.Dispose();

_i2CDevice.Dispose();

_i2CDevice.Dispose();

4 random I2C devices I opened

Copy link
Member

Choose a reason for hiding this comment

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

well, we should not because we don't create those!

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe intent is that you do - the device takes ownership of that object since it's useless without the device binding - it's bound to a specific address (as oposed to I2cBus i.e.)

Copy link
Member

Choose a reason for hiding this comment

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

Still. And we have to then make things clear about this.

src/devices/Lis3Dh/Lis3Dh.cs Show resolved Hide resolved
src/devices/Lis3Dh/Lis3Dh.cs Outdated Show resolved Hide resolved
@krwq krwq merged commit 5809972 into dotnet:main Oct 7, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants