|
| 1 | +# SPDX-FileCopyrightText: 2022 Kattni Rembor for Adafruit Industries |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +import time |
| 5 | +import board |
| 6 | +from adafruit_ht16k33 import segments |
| 7 | + |
| 8 | +# Create the display object. |
| 9 | +# Display connected to STEMMA QT connector. |
| 10 | +display = segments.Seg14x4(board.STEMMA_I2C()) |
| 11 | +# Display connected to I2C pins. |
| 12 | +# display = segments.Seg14x4(board.I2C()) |
| 13 | + |
| 14 | +# This section displays four 0's across the display. The code shows four |
| 15 | +# different ways to use the set_digit_raw function. Each is labeled below. |
| 16 | +# 16-bit Hexadecimal number |
| 17 | +display.set_digit_raw(0, 0x2D3F) |
| 18 | +time.sleep(0.2) |
| 19 | +# 16-bit Binary number |
| 20 | +display.set_digit_raw(1, 0b0010110100111111) |
| 21 | +time.sleep(0.2) |
| 22 | +# 8-bit Binary Tuple |
| 23 | +display.set_digit_raw(2, (0b00101101, 0b00111111)) |
| 24 | +time.sleep(0.2) |
| 25 | +# 8-bit Hexadecimal List |
| 26 | +display.set_digit_raw(3, [0x2D, 0x3F]) |
| 27 | +time.sleep(0.2) |
| 28 | + |
| 29 | +# Delay between. |
| 30 | +time.sleep(2) |
| 31 | + |
| 32 | +# Scroll "Hello, world!" across the display. Setting the loop parameter to false allows you to |
| 33 | +# tell the marquee function to run only once. By default, marquee loops indefinitely. |
| 34 | +display.marquee("Hello, world!", loop=False) |
| 35 | + |
| 36 | +# Delay between. |
| 37 | +time.sleep(2) |
| 38 | + |
| 39 | +# Scroll special characters, uppercase and lowercase letters, and numbers across |
| 40 | +# the display in a loop. This section will continue to run indefinitely. |
| 41 | +display.marquee("".join(chr(character) for character in range(ord("!"), ord("z") + 1))) |
0 commit comments