Skip to content
This repository was archived by the owner on Dec 20, 2018. It is now read-only.

ADS1x15_CONFIG_GAIN gain=2/3 gives unexpected results #8

Closed
scruss opened this issue Jan 18, 2018 · 1 comment
Closed

ADS1x15_CONFIG_GAIN gain=2/3 gives unexpected results #8

scruss opened this issue Jan 18, 2018 · 1 comment

Comments

@scruss
Copy link

scruss commented Jan 18, 2018

In line 34 of Adafruit_Python_ADS1x15/ADS1x15.py at 733d179bfca9aff1a8357dea3a2b12108e3801e9 · adafruit/Adafruit_Python_ADS1x15, dictionary keys are suspect:

ADS1x15_CONFIG_GAIN = {
    2/3: 0x0000,
    1:   0x0200,
    2:   0x0400,
    4:   0x0600,
    8:   0x0800,
    16:  0x0A00
}

This gives unexpected values of the ‘2/3’ key no matter what python version is used.

Python 2:

>>> ADS1x15_CONFIG_GAIN
{0: 0, 1: 512, 2: 1024, 4: 1536, 8: 2048, 16: 2560}

Python 3:

>>> ADS1x15_CONFIG_GAIN
{0.6666666666666666: 0, 1: 512, 2: 1024, 4: 1536, 8: 2048, 16: 2560}

Maybe make the keys strings?

  • Platform/operating system (i.e. Raspberry Pi with Raspbian operating system,
    Windows 32-bit, Windows 64-bit, Mac OSX 64-bit, etc.): Raspbian GNU/Linux 9 (stretch)

  • Python version (run python -version or python3 -version): Python 3.5.3

  • Error message you are receiving, including any Python exception traces: divide by zero error

  • List the steps to reproduce the problem below (if possible attach code or commands
    to run): related to using gain=2/3

@caternuson
Copy link
Contributor

Hi! We are deprecating this library. This issue is either fixed or may need updating for the new library:
https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15

Please see issue summary here:
#13

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

No branches or pull requests

2 participants