Skip to content

iparaskev/python_bit_handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-bit-handler

A small python module for handling bits in registers with hardware interfaces communication libraries.

  • Free software: MIT license

Overview

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.

Features

  • 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)

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages