Skip to content

Read function #23

@robo32

Description

@robo32

There is a mistake in the read function. The following line is wrong:
self._adc_out = value / 128 # Restore to 24-bit signed integer value

It should be divided by 256 because it needs to be shifted with 8 bits not 7.

Also this method is not the ideal method to convert the raw data. It would be more efficient like this:

raw = (self._adc_out_2 << 16) | (self._adc_out_1 << 8) | self._adc_out_0
# Sign-extend 24-bit to Python int
if raw & 0x800000: # if sign bit set
raw -= 1 << 24
return raw

The original creater also told me that it is a mistake see screenshot

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions