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

Make AnalogIn.value return always 16 bit? #97

Open
caternuson opened this issue Mar 12, 2022 · 3 comments
Open

Make AnalogIn.value return always 16 bit? #97

caternuson opened this issue Mar 12, 2022 · 3 comments
Labels

Comments

@caternuson
Copy link
Contributor

The CP standard for AnalogIn.value is 16 bit:
https://docs.circuitpython.org/en/latest/shared-bindings/analogio/index.html#analogio.AnalogIn.value

This library wants to follow same convention:

"""The current analog value on the pin, as an integer from 0..65535 (inclusive)"""

NeoSlider (others?) return 10 bit:

Adafruit CircuitPython 7.1.1 on 2022-01-14; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import board
>>> from adafruit_seesaw.seesaw import Seesaw
>>> from adafruit_seesaw.analoginput import AnalogInput
>>> neoslider = Seesaw(board.I2C(), 0x30)
>>> potentiometer = AnalogInput(neoslider, 18)
>>> potentiometer.value
1023
>>> potentiometer.value
943
>>> potentiometer.value
451
>>> potentiometer.value
0
>>> 
@ladyada
Copy link
Member

ladyada commented Mar 13, 2022

it shooould yes! dox need updating too

@caternuson
Copy link
Contributor Author

OK, pretty easy fix, just a matter of scaling.

Which dox?

@adafruit-adabot adafruit-adabot added the Hacktoberfest DigitalOcean's Hacktoberfest label Sep 29, 2022
@dhalbert dhalbert removed the Hacktoberfest DigitalOcean's Hacktoberfest label Mar 25, 2024
@dhalbert
Copy link
Contributor

making it scale to 65535 as opposed to just 16 bit is a little trickier:
adafruit/circuitpython#6426. See the computational trick there to fill in the low-order bits properly.

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

No branches or pull requests

6 participants