Toggle Navigation
Hatchery
Eggs
POV
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import bhi160 import color import leds import utime font = [[0, 0, 0, 0, 0, 0, 0, 0], [126, 129, 169, 141, 141, 169, 129, 126], [126, 255, 215, 243, 243, 215, 255, 126], [112, 248, 252, 126, 252, 248, 112, 0], [16, 56, 124, 254, 124, 56, 16, 0], [24, 93, 255, 255, 255, 93, 24, 0], [8, 29, 63, 255, 63, 29, 8, 0], [0, 0, 24, 60, 60, 24, 0, 0], [255, 255, 231, 195, 195, 231, 255, 255], [0, 60, 102, 66, 66, 102, 60, 0], [255, 195, 153, 189, 189, 153, 195, 255], [14, 31, 17, 17, 191, 254, 224, 240], [0, 114, 250, 143, 143, 250, 114, 0], [3, 7, 255, 254, 160, 160, 224, 224], [3, 255, 254, 160, 160, 166, 254, 252], [153, 90, 60, 231, 231, 60, 90, 153], [254, 124, 124, 56, 56, 16, 16, 0], [16, 16, 56, 56, 124, 124, 254, 0], [0, 36, 102, 255, 255, 102, 36, 0], [0, 250, 250, 0, 0, 250, 250, 0], [96, 240, 144, 254, 254, 128, 254, 254], [2, 91, 253, 165, 191, 154, 192, 64], [0, 14, 14, 14, 14, 14, 14, 0], [1, 41, 109, 255, 255, 109, 41, 1], [0, 32, 96, 254, 254, 96, 32, 0], [0, 8, 12, 254, 254, 12, 8, 0], [16, 16, 16, 84, 124, 56, 16, 0], [16, 56, 124, 84, 16, 16, 16, 0], [60, 60, 4, 4, 4, 4, 4, 0], [16, 56, 124, 16, 16, 124, 56, 16], [12, 28, 60, 124, 124, 60, 28, 12], [96, 112, 120, 124, 124, 120, 112, 96], [0, 0, 0, 0, 0, 0, 0, 0], [0, 96, 250, 250, 96, 0, 0, 0], [0, 224, 224, 0, 224, 224, 0, 0], [40, 254, 254, 40, 254, 254, 40, 0], [36, 116, 214, 214, 92, 72, 0, 0], [98, 102, 12, 24, 48, 102, 70, 0], [12, 94, 242, 186, 236, 94, 18, 0], [32, 224, 192, 0, 0, 0, 0, 0], [0, 56, 124, 198, 130, 0, 0, 0], [0, 130, 198, 124, 56, 0, 0, 0], [16, 84, 124, 56, 56, 124, 84, 16], [16, 16, 124, 124, 16, 16, 0, 0], [0, 1, 7, 6, 0, 0, 0, 0], [16, 16, 16, 16, 16, 16, 0, 0], [0, 0, 6, 6, 0, 0, 0, 0], [6, 12, 24, 48, 96, 192, 128, 0], [124, 254, 142, 154, 178, 254, 124, 0], [2, 66, 254, 254, 2, 2, 0, 0], [70, 206, 154, 146, 242, 102, 0, 0], [68, 198, 146, 146, 254, 108, 0, 0], [24, 56, 104, 202, 254, 254, 10, 0], [228, 230, 162, 162, 190, 156, 0, 0], [60, 126, 210, 146, 158, 12, 0, 0], [192, 192, 142, 158, 240, 224, 0, 0], [108, 254, 146, 146, 254, 108, 0, 0], [96, 242, 146, 150, 252, 120, 0, 0], [0, 0, 102, 102, 0, 0, 0, 0], [0, 2, 110, 108, 0, 0, 0, 0], [16, 56, 108, 198, 130, 0, 0, 0], [36, 36, 36, 36, 36, 36, 0, 0], [0, 130, 198, 108, 56, 16, 0, 0], [64, 192, 138, 154, 240, 96, 0, 0], [124, 254, 130, 186, 186, 248, 120, 0], [62, 126, 200, 200, 126, 62, 0, 0], [130, 254, 254, 146, 146, 254, 108, 0], [56, 124, 198, 130, 130, 198, 68, 0], [130, 254, 254, 130, 198, 124, 56, 0], [130, 254, 254, 146, 186, 130, 198, 0], [130, 254, 254, 146, 184, 128, 192, 0], [56, 124, 198, 130, 138, 206, 78, 0], [254, 254, 16, 16, 254, 254, 0, 0], [0, 130, 254, 254, 130, 0, 0, 0], [12, 14, 2, 130, 254, 252, 128, 0], [130, 254, 254, 16, 56, 238, 198, 0], [130, 254, 254, 130, 2, 6, 14, 0], [254, 254, 112, 56, 112, 254, 254, 0], [254, 254, 96, 48, 24, 254, 254, 0], [56, 124, 198, 130, 198, 124, 56, 0], [130, 254, 254, 146, 144, 240, 96, 0], [120, 252, 132, 142, 254, 122, 0, 0], [130, 254, 254, 144, 152, 254, 102, 0], [100, 246, 178, 154, 206, 76, 0, 0], [192, 130, 254, 254, 130, 192, 0, 0], [254, 254, 2, 2, 254, 254, 0, 0], [248, 252, 6, 6, 252, 248, 0, 0], [254, 254, 12, 24, 12, 254, 254, 0], [194, 230, 60, 24, 60, 230, 194, 0], [224, 242, 30, 30, 242, 224, 0, 0], [226, 198, 142, 154, 178, 230, 206, 0], [0, 254, 254, 130, 130, 0, 0, 0], [128, 192, 96, 48, 24, 12, 6, 0], [0, 130, 130, 254, 254, 0, 0, 0], [16, 48, 96, 192, 96, 48, 16, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 192, 224, 32, 0, 0, 0], [4, 46, 42, 42, 60, 30, 2, 0], [130, 254, 252, 18, 18, 30, 12, 0], [28, 62, 34, 34, 54, 20, 0, 0], [12, 30, 18, 146, 252, 254, 2, 0], [28, 62, 42, 42, 58, 24, 0, 0], [18, 126, 254, 146, 192, 64, 0, 0], [25, 61, 37, 37, 31, 62, 32, 0], [130, 254, 254, 16, 32, 62, 30, 0], [0, 34, 190, 190, 2, 0, 0, 0], [6, 7, 1, 1, 191, 190, 0, 0], [130, 254, 254, 8, 28, 54, 34, 0], [0, 130, 254, 254, 2, 0, 0, 0], [62, 62, 24, 28, 56, 62, 30, 0], [62, 62, 32, 32, 62, 30, 0, 0], [28, 62, 34, 34, 62, 28, 0, 0], [33, 63, 31, 37, 36, 60, 24, 0], [24, 60, 36, 37, 31, 63, 33, 0], [34, 62, 30, 50, 32, 56, 24, 0], [18, 58, 42, 42, 46, 36, 0, 0], [0, 32, 124, 254, 34, 36, 0, 0], [60, 62, 2, 2, 60, 62, 2, 0], [56, 60, 6, 6, 60, 56, 0, 0], [60, 62, 14, 28, 14, 62, 60, 0], [34, 54, 28, 8, 28, 54, 34, 0], [57, 61, 5, 5, 63, 62, 0, 0], [50, 38, 46, 58, 50, 38, 0, 0], [16, 16, 124, 238, 130, 130, 0, 0], [0, 0, 0, 238, 238, 0, 0, 0], [130, 130, 238, 124, 16, 16, 0, 0], [64, 192, 128, 192, 64, 192, 128, 0], [14, 30, 50, 98, 50, 30, 14, 0]] masks = [2**n for n in range(7,-1,-1)] try: with open('pov_word', 'r') as f: msg_word = f.read() except: msg_word = 'BOLLOCKS' msg = list(map(ord, msg_word)) bhi = bhi160.BHI160Accelerometer(sample_rate=16, sample_buffer_len=1) def pov_char(char, reverse=False): if reverse: col_seq = font[char][::-1] else: col_seq = font[char] for col in col_seq: for i in range(8): if masks[i] & col: leds.prep(i+1,color.GREEN) else: leds.prep(i+1,color.BLACK) leds.update() utime.sleep(0.0025) for i in range(8): leds.prep(i+1,color.BLACK) leds.update() utime.sleep(0.0025) def word(reverse=False): if reverse: for char in msg[::-1]: pov_char(char, reverse=True) else: for char in msg: pov_char(char) def shake(): acc = [] while not acc: acc = bhi.read() old_z = acc[0].z > 0 while True: acc = [] while not acc: acc = bhi.read() new_z = acc[0].z > 0 if old_z and not new_z: word() if new_z and not old_z: word(True) old_z = new_z shake()