Toggle Navigation
Hatchery
Eggs
Blinkeparty
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import bhi160 import display import utime import leds from color import Color disp = display.open() v = 1 h = 0 orient = bhi160.BHI160Orientation() gyro = bhi160.BHI160Gyroscope() refresh = 0 orient.sample_rate = 200 gyro.sample_rate = 200 FILENAME = 'nickname.txt' # Load Nick f = open(FILENAME, 'r') nick = f.read() f.close() while True: gp = gyro.read() if len(gp) > 0: g = gp[0] v = (abs(g.x) + abs(g.y) + abs(g.z)) / 400 op = orient.read() if len(op) > 0: h = op[0].x if utime.time_ms() % 50 == 0: c = Color.from_hsv(h,1,v) comp = c.get_complementary() disp.clear(col=[c.red, c.green, c.blue]) disp.print(nick, fg=[comp.red, comp.green, comp.blue], bg=[c.red, c.green, c.blue], posx=80 - round(len(nick) / 2 * 14), posy=30) disp.update() del c del comp if v < 0.3: v = 0.3 if v > 1: v = 1 for i in range(11): leds.prep_hsv(i, [h,1,v]) leds.update()