def scroller(): x = 0 while True: x += 3 x %= 360 backlight.sweep((360.0 - x) / 360.0) menu.redraw() sleep(0.01)
def test(): print("Testing") l.clear() l.write("Jedi oder Sith?") x = 0 while True: x+=1 b.sweep( (x%360)/360.0) sleep(0.01)
def display_boot_animation(self, anim_time=10.0): self.clear_indicators() elapsed_time = 0.0 x = 0 while True: if elapsed_time >= anim_time: break x += 1 backlight.sweep((x % 360) / 360.0) time.sleep(DotHatGadget.ANIM_INTERVAL_SECONDS) elapsed_time += DotHatGadget.ANIM_INTERVAL_SECONDS self.set_background_status(BackgroundStatus.Info)
def backlight(data): if data["command"] == "off": backlight.off() return True if data["command"] == "sweep": backlight.sweep(data["hue"],data["range"]) return True if data["command"] == "hue": backlight.hue(data["hue"]) return True if data["command"] == "rgb": backlight.rgb(data["r"],data["g"],data["b"]) return True if data["command"] == "left_hue": backlight.left_hue(data["hue"]) return True if data["command"] == "left_rgb": backlight.left_rgb(data["r"],data["g"],data["b"]) return True if data["command"] == "mid_hue": backlight.mid_hue(data["hue"]) return True if data["command"] == "mid_rgb": backlight.mid_rgb(data["r"],data["g"],data["b"]) return True if data["command"] == "right_hue": backlight.right_hue(data["hue"]) return True if data["command"] == "right_rgb": backlight.right_rgb(data["r"],data["g"],data["b"]) return True if data["command"] == "set": backlight.set(data["index"],data["value"]) return True if data["command"] == "set_bar": backlight.set_bar(data["index"],data["value"]) return True if data["command"] == "set_graph": backlight.set(data["value"]) return True if data["command"] == "update": backlight.update() return True
lcd.write(chr(0) + " such rainbow!") def get_anim_frame(char, fps): return char[int(round(time.time() * fps) % len(char))] x = 0 text = " pimoroni ftw " while True: x += 3 x %= 360 backlight.sweep((360.0 - x) / 360.0) backlight.set_graph(abs(math.sin(x / 100.0))) if x == 0: lcd.set_cursor_position(0, 1) lcd.write(" " * 16) pos = int(x / 20) lcd.set_cursor_position(0, 1) lcd.write(text[:pos] + "\x02") lcd.set_cursor_position(0, 2) lcd.write(colours[int(x / 52)]) lcd.create_char(0, get_anim_frame(pirate, 2)) lcd.create_char(1, get_anim_frame(heart, 2))
mqtt_server = "10.0.1.3" pygame.mixer.pre_init(44100, -16, 1, 512) pygame.mixer.init() pygame.mixer.set_num_channels(256) patches = glob.glob(os.path.join(BANK, '*')) print(patches) patch_index = 0 if len(patches) == 0: exit("Couldn't find any .wav files in {}".format(BANK)) # Display-o-Tron setup lcd.clear() backlight.sweep(5) # Set a rainbow background lcd.set_contrast(50) # Readable contrast, for our Displayotron HAT lcd.write("SYSTEM START") backlight.graph_off() # Make sure the hellish-bright sidebar LEDs are off def natural_sort_key(s, _nsre=re.compile('([0-9]+)')): return [ int(text) if text.isdigit() else text.lower() for text in re.split(_nsre, s) ] def load_samples(patch): """Load audio samples into buffers for playback.""" global samples, files, octave, octaves
def touch_button(chan, event): """When the OTHER button is pressed""" backlight.sweep(random(), random())
} }, lcd=lcd, idle_handler=lightsoff, idle_timeout=1, input_handler=Text()) backlight.off() lcd.clear() backlight.set_graph(0) nav.bind_defaults(menu) atexit.register(tidyup) x = 0 ###################################################################################### #Background while loop - defaults to jsut redraw the screen, no backlight unless Backlight turned on from menu OR Cycle RGB loop initiated from menu ###################################################################################### while True: if cyclts == False: menu.redraw() time.sleep(0.01) else: x += 1 backlight.sweep((x % 360) / 360.0) menu.redraw() time.sleep(0.01)
#!/usr/bin/env python print(""" This example shows you a feature of the Dot HAT backlight. You should see a rainbow sweep across the whole display! Press CTRL+C to exit. """) import dothat.backlight as backlight import dothat.lcd as lcd import time import math lcd.set_cursor_position(0, 1) lcd.write(" Such Rainbow! ") x = 0 while True: x += 1 backlight.sweep((x % 360) / 360.0) backlight.set_graph(abs(math.sin(x / 100.0))) time.sleep(0.01)
def getAnimFrame(char, fps): return char[int(round(time.time() * fps) % len(char))] raspberry x = 0 text = " pimoroni ftw " while True: x += 3 x %= 360 backlight.sweep((360.0 - x) / 360.0) backlight.set_graph(abs(math.sin(x / 100.0))) if x == 0: lcd.set_cursor_position(0, 1) lcd.write(" " * 16) pos = int(x / 20) lcd.set_cursor_position(0, 1) lcd.write(text[:pos] + "\x02") lcd.set_cursor_position(0, 2) lcd.write(colours[int(x / 52)]) lcd.create_char(0, getAnimFrame(pirate, 2)) lcd.create_char(1, getAnimFrame(heart, 2))