Esempio n. 1
0
import board
from PIL import Image
from adafruit_ht16k33 import matrix
# regular setup/imports
matrix = matrix.Matrix8x8(board.I2C())

image = Image.open("heart_example.png")
matrix.image(image)

### Summary ###
# using a black/white png, you can simply load in the 
# 8x8 map you want. 
# this makes it easier to create images, sites like
# pixilart.com/draw can allow you to create these 8x8's with ease
# note that a black pixel corresponds to an ON led, while white is 
# an OFF led
# Any other will just be on/off, without any way to tell which beforehand
###
import time
import board
import adafruit_lsm6ds
from adafruit_ht16k33 import matrix
import matrixsand

DELAY = 0.00 # add some delay if you want

# the accelo
accelo = adafruit_lsm6ds.LSM6DS33(board.I2C())

# the matrix
matrix1 = matrix.Matrix8x8(board.I2C(), 0x70)
matrix2 = matrix.Matrix8x8(board.I2C(), 0x71)

# the sand
sand = matrixsand.MatrixSand(8, 16)

# simple helper
def update_matrix():
    for x in range(8):
        for y in range(16):
            if y < 8:
                matrix1[x, y] = sand[x, y]
            else:
                matrix2[x, y-8] = sand[x, y]

# add some initial sand
for sx in range(4):
    for sy in range(4):
        sand[sx, sy] = 1
Esempio n. 3
0
import board
import busio
from adafruit_ht16k33 import matrix
import bitmapfont
import time

i2c = busio.I2C(board.SCL, board.SDA)
mx = matrix.Matrix8x8(i2c, auto_write=False)
bf = bitmapfont.BitmapFont(8, 8, mx.pixel)

mx.fill(0)
mx.show()
bf.init()

while True:
    for i in range(15, -30, -1):
        mx.fill(0)
        bf.text('IKEA', i, 0, 100)
        mx.show()
        time.sleep(0.025)
Esempio n. 4
0
#
# SPDX-License-Identifier: MIT

import time
import board
import adafruit_lsm6ds.lsm6ds33
from adafruit_ht16k33 import matrix
import matrixsand

DELAY = 0.00  # add some delay if you want

# the accelo
accelo = adafruit_lsm6ds.lsm6ds33.LSM6DS33(board.I2C())

# the matrix
matrix = matrix.Matrix8x8(board.I2C(), 0x70)

# the sand
sand = matrixsand.MatrixSand(8, 8)


# simple helper
def update_matrix():
    for x in range(8):
        for y in range(8):
            matrix[x, y] = sand[x, y]


# add some initial sand
for sx in range(4):
    for sy in range(4):
Esempio n. 5
0
# Import all board pins.
import time
import board
import busio
from adafruit_ht16k33 import matrix

# Create the I2C interface.
i2c = busio.I2C(board.SCL, board.SDA)

# creates a 8x8 matrix:
matrix = matrix.Matrix8x8(i2c)

# edges of an 8x8 matrix
col_max = 8
row_max = 8

# Clear the matrix.
matrix.fill(0)
col = 0
row = 0

while True:

    # illuminate a column one LED at a time
    while col < col_max:
        matrix[row, col] = 2
        col += 1
        time.sleep(.2)

    # next row when previous column is full
    if row < row_max:
Esempio n. 6
0
 def __init__(self, address1, address2):
     self.left = matrix.Matrix8x8(i2c, address1)
     self.right = matrix.Matrix8x8(i2c, address2)
Esempio n. 7
0
# demo to show Weather icons on 8*8 ledmatrix
# 2017-0721 PePo, https://hackaday.io/project/20839-weather-pal
import busio
import board
import time
from adafruit_ht16k33 import matrix

# ICON images
from weathericons import ICONS

# specify matrices 'lefteye' and 'righteye'
i2c = busio.I2C(board.SCL, board.SDA)
lefteye = matrix.Matrix8x8(i2c, address=0x70)
righteye = matrix.Matrix8x8(i2c, address=0x71)


# show 'image' on 'matrix' starting (0,0)
def show(matrix, image, dx=0, dy=0):
    ''' show(matrix, image, dx=0, dy=0)'''
    for y, row in enumerate(image):
        bit = 1
        for x in range(8):
            matrix.pixel(dx + x, dy + y, row & bit)
            bit <<= 1
    matrix.show()


# clear matrix
def clear(matrix):
    matrix.fill(0)
    matrix.show()
# Create I2C interface
i2c = busio.I2C(board.SCL, board.SDA)

# Create matrix class
# !!! These default to I2C address 0x70
#  16x8 matrix
# matrix = matrix.Matrix16x8(i2c)
#  16x8 matrix backpack
# matrix = matrix.MatrixBackpack16x8(i2c)
#  8x8 matrix
# matrix = matrix.Matrix8x8(i2c)
#  8x8 bicolor matrix
# matrix = matrix.Matrix8x8x2(i2c)

# Specify I2C HT16K33 address
matrix = matrix.Matrix8x8(i2c, address=0x71)

# Clear matrix
matrix.fill(0)

# Set pixel at origin (0, 0)
matrix[0, 0] = 1
# Set pixels in middle
matrix[3, 3] = 1
matrix[3, 4] = 1
matrix[4, 3] = 1
matrix[4, 4] = 1
# Set pixel in far corner
matrix[7, 7] = 1

time.sleep(2)