Skip to content

Add offsets, example, fix acceleration. #2

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

Merged
merged 4 commits into from
Feb 16, 2022
Merged

Conversation

kattni
Copy link
Contributor

@kattni kattni commented Feb 15, 2022

No description provided.

@kattni kattni requested a review from a team February 15, 2022 21:05
@kattni
Copy link
Contributor Author

kattni commented Feb 15, 2022

Calibration math updated as per change requested in adafruit/Adafruit_CircuitPython_ADXL34x#34.

Copy link
Member

@tekktrik tekktrik left a comment

Choose a reason for hiding this comment

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

Just a few questions!

from typing import Tuple, Optional

# This is only needed for typing
import busio # pylint: disable=unused-import
Copy link
Member

Choose a reason for hiding this comment

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

Is the pylint disable required? Looks like the library is used so it should be okay without it.

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 copied it from the other lib, I'll try running it without.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It passes without it! I'll remove it, let me know what to with the type hint so I can do a single commit.

return x, y, z

@property
def range(self) -> int:
Copy link
Member

Choose a reason for hiding this comment

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

I'm torn for what to do here. As is, it technically works, so the correct typing should be -> None. Is the intention to allow for silently ignoring the lack of implementation, as opposed to raising NotImplementedError?

Copy link
Contributor Author

@kattni kattni Feb 15, 2022

Choose a reason for hiding this comment

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

@tekktrik You're the expert here! I'll defer to you on this one. It throws the NotImplementedError when attempting to use it, because you can't set the range on this chip.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm.... if you want the behavior to be that it throws NotImplementedError on both getting and setting, then I'd say it's fine to leave the typing as is because there's never really going to be a case where someone is expecting to get int and actually gets anything at all, so the potentially future-safe implementation of returning int seems fine. If you want the get functionality of range to not fail but also not give anything useful, I would probably type this as returning None. Either implementation works so up to you!

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 think we can leave it as it is for now then, and if it comes up in the future as an issue, we'll look at updating it!

Copy link
Member

Choose a reason for hiding this comment

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

So is the decision to raise Not ImplementatedError from this property getter as well?

@kattni kattni requested a review from tekktrik February 15, 2022 22:19
Copy link
Member

@tekktrik tekktrik 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 to me!

@tekktrik tekktrik merged commit ecc3582 into adafruit:main Feb 16, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 17, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x to 1.12.0 from 1.11.12:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADXL34x#34 from kattni/offset

Updating https://github.com/adafruit/Adafruit_CircuitPython_ADXL37x to 1.1.0 from 1.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADXL37x#2 from kattni/offset

Updating https://github.com/adafruit/Adafruit_CircuitPython_BusDevice to 5.1.6 from 5.1.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_BusDevice#84 from dhalbert/circuitpython_typing

Updating https://github.com/adafruit/Adafruit_CircuitPython_Debug_I2C to 1.2.8 from 1.2.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_Debug_I2C#12 from dhalbert/circuitpython-typing
  > Fixed readthedocs build
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