A small python module for handling bits in registers with hardware interfaces communication libraries.
- Free software: MIT license
python_bit_handler is a small module that can be added to any driver that is written for sensors/effectors that require handling of specific bits/bytes of registers through a hardware interface like spi or i2c.
Initialization of handler.
handler = BitHandler(resolution=8)
Set any bits to any variable
number = 0b10101100 number = handler.set_bits(number, 0b111, bits=3, shift=1)
Get any bits from a variable.
number = 0b10101100 bits = handler.get_bits(number, bits=3, shift=1)
Make a number from two or more registers
data = [0b10010101, 0b00100111, 0b11010000] number = handler.get_number(data, res=20, signed=True, rev=True)
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.