adafruit_ht16k33.ht16k33

  • Authors: Radomir Dopieralski, Tony DiCola, and Melissa LeBlanc-Williams for Adafruit Industries

class adafruit_ht16k33.ht16k33.HT16K33(i2c: I2C, address: int | List[int] | Tuple[int, ...] = 112, auto_write: bool = True, brightness: float = 1.0)[source]

The base class for all displays. Contains common methods.

Parameters:
  • i2c (I2C) – The I2C bus object

  • address (int|list|tuple) – The I2C addess(es) of the HT16K33.

  • auto_write (bool) – True if the display should immediately change when set. If False, show must be called explicitly.

  • brightness (float) – 0.0 - 1.0 default brightness level.

property auto_write: bool

Auto write updates to the display.

The blink rate. Range 0-3.

property brightness: float

The brightness. Range 0.0-1.0

fill(color: bool) None[source]

Fill the whole display with the given color.

Parameters:

color (bool) – Whether to fill the display

show() None[source]

Refresh the display and show the changes.

adafruit_ht16k33.bargraph

  • Authors: Carter Nelson for Adafruit Industries

class adafruit_ht16k33.bargraph.Bicolor24(i2c: I2C, address: int | List[int] | Tuple[int, ...] = 112, auto_write: bool = True, brightness: float = 1.0)[source]

Bi-color 24-bar bargraph display.

fill(color: int) None[source]

Fill the whole display with the given color.

Parameters:

color (int) – Whether to fill the display, where 0 is no color, 1 is red, 2 is green, and 3 is yellow (red + green)

adafruit_ht16k33.matrix

class adafruit_ht16k33.matrix.Matrix16x8(i2c: I2C, address: int | List[int] | Tuple[int, ...] = 112, auto_write: bool = True, brightness: float = 1.0)[source]

The matrix wing.

pixel(x: int, y: int, color: bool | None = None) bool | None[source]

Get or set the color of a given pixel.

Parameters:
  • x (int) – The x coordinate of the pixel

  • y (int) – The y coordinate of the pixel

  • color (bool) – (Optional) The state to set the pixel

Returns:

If color was not set, this returns the state of the pixel

Return type:

bool

class adafruit_ht16k33.matrix.Matrix8x8(i2c: I2C, address: int | List[int] | Tuple[int, ...] = 112, auto_write: bool = True, brightness: float = 1.0)[source]

A single matrix.

property columns: int

Read-only property for number of columns

image(img: Image) None[source]

Set buffer to value of Python Imaging Library image. The image should be in 1 bit mode and a size equal to the display size.

Parameters:

img (Image) – The image to show

pixel(x: int, y: int, color: bool | None = None) bool | None[source]

Get or set the color of a given pixel.

Parameters:
  • x (int) – The x coordinate of the pixel

  • y (int) – The y coordinate of the pixel

  • color (bool) – (Optional) The state to set the pixel

Returns:

If color was not set, this returns the state of the pixel

Return type:

bool

property rows: int

Read-only property for number of rows

shift(x: int, y: int, rotate: bool = False) None[source]

Shift pixels by x and y

Parameters:
  • x (int) – The x coordinate of the pixel

  • y (int) – The y coordinate of the pixel

  • rotate (bool) – (Optional) Rotate the shifted pixels to the left side (default=False)

shift_down(rotate: bool = False) None[source]

Shift all pixels down

Parameters:

rotate – (Optional) Rotate the shifted pixels to top (default=False)

shift_left(rotate: bool = False) None[source]

Shift all pixels left

Parameters:

rotate – (Optional) Rotate the shifted pixels to the right side (default=False)

shift_right(rotate: bool = False) None[source]

Shift all pixels right

Parameters:

rotate – (Optional) Rotate the shifted pixels to the left side (default=False)

shift_up(rotate: bool = False) None[source]

Shift all pixels up

Parameters:

rotate – (Optional) Rotate the shifted pixels to bottom (default=False)

class adafruit_ht16k33.matrix.Matrix8x8x2(i2c: I2C, address: int | List[int] | Tuple[int, ...] = 112, auto_write: bool = True, brightness: float = 1.0)[source]

A bi-color matrix.

fill(color: int) None[source]

Fill the whole display with the given color.

Parameters:

color (int) – The color to fill the display

image(img: Image) None[source]

Set buffer to value of Python Imaging Library image. The image should be a size equal to the display size.

Parameters:

img (Image) – The image to show

pixel(x: int, y: int, color: int | None = None) int | None[source]

Get or set the color of a given pixel.

Parameters:
  • x (int) – The x coordinate of the pixel

  • y (int) – The y coordinate of the pixel

  • color (int) – (Optional) The color to set the pixel

Returns:

If color was not set, this returns the state of the pixel

Return type:

int

class adafruit_ht16k33.matrix.MatrixBackpack16x8(i2c: I2C, address: int | List[int] | Tuple[int, ...] = 112, auto_write: bool = True, brightness: float = 1.0)[source]

A double matrix backpack.

pixel(x: int, y: int, color: bool | None = None) bool | None[source]

Get or set the color of a given pixel.

Parameters:
  • x (int) – The x coordinate of the pixel

  • y (int) – The y coordinate of the pixel

  • color (bool) – (Optional) The state to set the pixel

Returns:

If color was not set, this returns the state of the pixel

Return type:

bool

adafruit_ht16k33.segments

class adafruit_ht16k33.segments.BigSeg7x4(i2c: I2C, address: int | List[int] | Tuple[int, ...] = 112, auto_write: bool = True, char_dict: Dict[str, int] | None = None)[source]

Numeric 7-segment display. It has the same methods as the alphanumeric display, but only supports displaying a limited set of characters.

Parameters:
  • i2c (I2C) – The I2C bus object

  • address (int|list|tuple) – The I2C address(es) for the display

  • auto_write (bool) – True if the display should immediately change when set. If False, show must be called explicitly.

  • char_dict (dict) – An optional dictionary mapping strings to bit settings integers used for defining how to display custom letters

property ampm: bool

The AM/PM indicator.

property bottom_left_dot: bool

The bottom-left dot indicator.

property top_left_dot: bool

The top-left dot indicator.

class adafruit_ht16k33.segments.Colon(disp: _AbstractSeg7x4, num_of_colons: int = 1)[source]

Helper class for controlling the colons. Not intended for direct use.

class adafruit_ht16k33.segments.Seg14x4(i2c: I2C, address: int | List[int] | Tuple[int, ...] = 112, auto_write: bool = True, chars_per_display: int = 4)[source]

Alpha-Numeric 14-segment display.

Parameters:
  • i2c (I2C) – The I2C bus object

  • address (int|list|tuple) – The I2C address(es) for the display. Can be a tuple or list for multiple displays.

  • auto_write (bool) – True if the display should immediately change when set. If False, show must be called explicitly.

  • chars_per_display (int) – A number between 1-8 represesenting the number of characters on each display.

marquee(text: str, delay: float = 0.25, loop: bool = True, space_between=False) None[source]

Automatically scroll the text at the specified delay between characters

Parameters:
  • text (str) – The text to display

  • delay (float) – (optional) The delay in seconds to pause before scrolling to the next character (default=0.25)

  • loop (bool) – (optional) Whether to endlessly loop the text (default=True)

  • space_between (bool) – (optional) Whether to seperate the end and beginning of the text with a space. (default=False)

non_blocking_marquee(text: str, delay: float = 0.25, loop: bool = True, space_between: bool = False) bool[source]

Scroll the text at the specified delay between characters. Must be called repeatedly from main loop faster than delay time.

Parameters:
  • text (str) – The text to display

  • delay (float) – (optional) The delay in seconds to pause before scrolling to the next character (default=0.25)

  • loop (bool) – (optional) Whether to endlessly loop the text (default=True)

  • space_between (bool) – (optional) Whether to seperate the end and beginning of the text with a space. (default=False)

print(value: str | float, decimal: int = 0) None[source]

Print the value to the display.

Parameters:
  • value (str|float) – The value to print

  • decimal (int) – The number of decimal places for a floating point number if decimal is greater than zero, or the input number is an integer if decimal is zero.

print_hex(value: int | str) None[source]

Print the value as a hexidecimal string to the display.

Parameters:

value (int|str) – The number to print

scroll(count: int = 1) None[source]

Scroll the display by specified number of places.

Parameters:

count (int) – The number of places to scroll

set_digit_raw(index: int, bitmask: int | List[int] | Tuple[int, int]) None[source]

Set digit at position to raw bitmask value. Position should be a value of 0 to 3 with 0 being the left most character on the display.

Parameters:
  • index (int) – The index of the display to set

  • bitmask (int, or a list/tuple of int) – A 2 byte number corresponding to the segments to set

class adafruit_ht16k33.segments.Seg7x4(i2c: I2C, address: int | List[int] | Tuple[int, ...] = 112, auto_write: bool = True, char_dict: Dict[str, int] | None = None, chars_per_display: int = 4)[source]

Numeric 7-segment display. It has the same methods as the alphanumeric display, but only supports displaying a limited set of characters.

Parameters:
  • i2c (I2C) – The I2C bus object

  • address (int|list|tuple) – The I2C address for the display. Can be a tuple or list for multiple displays.

  • auto_write (bool) – True if the display should immediately change when set. If False, show must be called explicitly.

  • char_dict (dict) – An optional dictionary mapping strings to bit settings integers used for defining how to display custom letters

  • chars_per_display (int) – A number between 1-8 represesenting the number of characters on each display.

property colon: bool

Simplified colon accessor

adafruit_ht16k33.animations

  • Authors: ladyada

Test script for display animations on an HT16K33 with alphanumeric display

The display must be initialized with auto_write=False.

class adafruit_ht16k33.animations.Animation(display: Seg14x4)[source]

Animation class for the htk33 Main driver for all alphanumeric display animations (WIP!!!)

Parameters:

display – HTK33 Display object

animate(digits: List[int], bitmasks: List[int], delay: float = 0.2, auto_write: bool = True) None[source]

Animate function

Parameters:
  • digits – a list of the digits to write to, in order, like [0, 1, 3]. The digits are 0 to 3 starting at the left most digit.

  • bitmasks – a list of the bitmasks to write, in sequence, to the specified digits.

  • delay – The delay, in seconds (or fractions of), between writing bitmasks to a digit.

  • auto_write – Whether to actually write to the display immediately or not.

chase_forward_and_reverse(delay: float = 0.2, cycles: int = 5)[source]

Chase Forward and Reverse Animation

count_down() None[source]

Countdown Method

enclosed_spinners(delay: float = 0.2, cycles: int = 5) None[source]

Enclosed Spinner Animation

prelude_to_spinners(delay: float = 0.2, cycles: int = 5) None[source]

Prelude to Spinners Animation

spinners(delay: float = 0.2, cycles: int = 5) None[source]

Spinners Animation