Word
busylight_core.word
¶
Bitwise operations on a word of bits.
Classes¶
busylight_core.word.Word
¶
Binary data structure for device state management with BitField support.
Provides bit-level manipulation of binary data with named field access through BitField descriptors. Use this as a base class for device state objects that need to pack/unpack complex binary protocols into structured, named fields.
Create a Word instance for binary data manipulation.
Initializes a binary word with the specified bit length and initial value. The length must be a multiple of 8 to align with byte boundaries. Use this to create state objects for devices that use binary communication protocols.
:param value: Initial integer value to store in the word :param length: Total bit length, must be multiple of 8 :raises ValueError: If length is not a positive multiple of 8
Source code in src/busylight_core/word.py
busylight_core.word.ReadOnlyBitField
¶
Descriptor for read-only named bit fields within Word instances.
Creates a named field that provides read-only access to specific bit ranges within a Word. Use this for device state fields that should not be modified by user code, such as status indicators or hardware-controlled values.
Create a read-only bit field descriptor.
Defines a named field that maps to specific bit positions within a Word. The field will be accessible as a regular attribute on Word instances but will raise AttributeError on assignment attempts.
:param offset: Starting bit position within the word (0-based from LSB) :param width: Number of consecutive bits to include in the field
Source code in src/busylight_core/word.py
busylight_core.word.BitField
¶
Bases: ReadOnlyBitField
Descriptor for mutable named bit fields within Word instances.
Creates a named field that provides read/write access to specific bit ranges within a Word. Use this for device control fields that can be modified by user code, such as color values, effect settings, or device configuration.
Create a read-only bit field descriptor.
Defines a named field that maps to specific bit positions within a Word. The field will be accessible as a regular attribute on Word instances but will raise AttributeError on assignment attempts.
:param offset: Starting bit position within the word (0-based from LSB) :param width: Number of consecutive bits to include in the field