Module Reference

I2C

i2c_bit - Single bit registers

adafruit_register.i2c_bit

Single bit registers

  • Author(s): Scott Shawcroft
class adafruit_register.i2c_bit.ROBit(register_address, bit, register_width=1, lsb_first=True)[source]

Single bit register that is read only. Subclass of RWBit.

Values are bool

Parameters:
  • register_address (int) – The register address to read the bit from
  • bit (type) – The bit index within the byte at register_address
  • register_width (int) – The number of bytes in the register. Defaults to 1.
class adafruit_register.i2c_bit.RWBit(register_address, bit, register_width=1, lsb_first=True)[source]

Single bit register that is readable and writeable.

Values are bool

Parameters:
  • register_address (int) – The register address to read the bit from
  • bit (type) – The bit index within the byte at register_address
  • register_width (int) – The number of bytes in the register. Defaults to 1.
  • lsb_first (bool) – Is the first byte we read from I2C the LSB? Defaults to true

i2c_bits - Multi bit registers

adafruit_register.i2c_bits

Multi bit registers

  • Author(s): Scott Shawcroft
class adafruit_register.i2c_bits.ROBits(num_bits, register_address, lowest_bit, register_width=1, lsb_first=True, signed=False)[source]

Multibit register (less than a full byte) that is read-only. This must be within a byte register.

Values are int between 0 and 2 ** num_bits - 1.

Parameters:
  • num_bits (int) – The number of bits in the field.
  • register_address (int) – The register address to read the bit from
  • lowest_bit (type) – The lowest bits index within the byte at register_address
  • register_width (int) – The number of bytes in the register. Defaults to 1.
class adafruit_register.i2c_bits.RWBits(num_bits, register_address, lowest_bit, register_width=1, lsb_first=True, signed=False)[source]

Multibit register (less than a full byte) that is readable and writeable. This must be within a byte register.

Values are int between 0 and 2 ** num_bits - 1.

Parameters:
  • num_bits (int) – The number of bits in the field.
  • register_address (int) – The register address to read the bit from
  • lowest_bit (type) – The lowest bits index within the byte at register_address
  • register_width (int) – The number of bytes in the register. Defaults to 1.
  • lsb_first (bool) – Is the first byte we read from I2C the LSB? Defaults to true
  • signed (bool) – If True, the value is a “two’s complement” signed value. If False, it is unsigned.

i2c_struct - Generic structured registers based on struct

adafruit_register.i2c_struct

Generic structured registers based on struct

  • Author(s): Scott Shawcroft
class adafruit_register.i2c_struct.ROUnaryStruct(register_address, struct_format)[source]

Arbitrary single value structure register that is read-only.

Values map to the first value in the defined struct. See struct module documentation for struct format string and its possible value types.

Parameters:
  • register_address (int) – The register address to read the bit from
  • struct_format (type) – The struct format string for this register.
class adafruit_register.i2c_struct.Struct(register_address, struct_format)[source]

Arbitrary structure register that is readable and writeable.

Values are tuples that map to the values in the defined struct. See struct module documentation for struct format string and its possible value types.

Parameters:
  • register_address (int) – The register address to read the bit from
  • struct_format (type) – The struct format string for this register.
class adafruit_register.i2c_struct.UnaryStruct(register_address, struct_format)[source]

Arbitrary single value structure register that is readable and writeable.

Values map to the first value in the defined struct. See struct module documentation for struct format string and its possible value types.

Parameters:
  • register_address (int) – The register address to read the bit from
  • struct_format (type) – The struct format string for this register.

i2c_bcd_datetime - Binary Coded Decimal date and time register

adafruit_register.i2c_bcd_datetime

Binary Coded Decimal date and time register

  • Author(s): Scott Shawcroft
class adafruit_register.i2c_bcd_datetime.BCDDateTimeRegister(register_address, weekday_first=True, weekday_start=1)[source]

Date and time register using binary coded decimal structure.

The byte order of the register must* be: second, minute, hour, weekday, day (1-31), month, year (in years after 2000).

  • Setting weekday_first=False will flip the weekday/day order so that day comes first.

Values are time.struct_time

Parameters:
  • register_address (int) – The register address to start the read
  • weekday_first (bool) – True if weekday is in a lower register than the day of the month (1-31)
  • weekday_start (int) – 0 or 1 depending on the RTC’s representation of the first day of the week

i2c_bcd_alarm - Binary Coded Decimal alarm register

adafruit_register.i2c_bcd_alarm

Binary Coded Decimal alarm register

  • Author(s): Scott Shawcroft
class adafruit_register.i2c_bcd_alarm.BCDAlarmTimeRegister(register_address, has_seconds=True, weekday_shared=True, weekday_start=1)[source]

Alarm date and time register using binary coded decimal structure.

The byte order of the registers must* be: [second], minute, hour, day, weekday. Each byte must also have a high enable bit where 1 is disabled and 0 is enabled.

  • If weekday_shared is True, then weekday and day share a register.
  • If has_seconds is True, then there is a seconds register.

Values are a tuple of (time.struct_time, str) where the struct represents a date and time that would alarm. The string is the frequency:

  • “secondly”, once a second (only if alarm has_seconds)
  • “minutely”, once a minute when seconds match (if alarm doesn’t seconds then when seconds = 0)
  • “hourly”, once an hour when tm_min and tm_sec match
  • “daily”, once a day when tm_hour, tm_min and tm_sec match
  • “weekly”, once a week when tm_wday, tm_hour, tm_min, tm_sec match
  • “monthly”, once a month when tm_mday, tm_hour, tm_min, tm_sec match
Parameters:
  • register_address (int) – The register address to start the read
  • has_seconds (bool) – True if the alarm can happen minutely.
  • weekday_shared (bool) – True if weekday and day share the same register
  • weekday_start (int) – 0 or 1 depending on the RTC’s representation of the first day of the week (Monday)

SPI

Coming soon!