def feedme(feed): feed = feedparser.parse(feed.encode('utf-8')) for i in range(6): b.graph_set_led_state(i,1) print(feed['entries'][i]['title']) scrollText(feed['entries'][i]['title']) b.graph_off()
def cleanup(): """ Function called on exit. Just clears the screen and turns all the lights off """ lcd.clear() backlight.rgb(0,0,0) backlight.graph_off()
def run(self): CMPFUNC = CFUNCTYPE(None, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p) cmp_func = CMPFUNC(self.callbackfunction) lib.tdInit() lib.tdRegisterDeviceEvent(cmp_func, 0) lcd.clear() lcd.set_cursor_position(0, 1) lcd.write('Waiting...') backlight.off() backlight.graph_off() print 'Started' while True: time.sleep(1)
class GracefulKiller: kill_now = False def __init__(self): signal.signal(signal.SIGINT, self.exit_gracefully) signal.signal(signal.SIGTERM, self.exit_gracefully) def exit_gracefully(self, signum, frame): self.kill_now = True if __name__ == '__main__': killer = GracefulKiller() backlight.graph_off() backlight.graph_set_led_duty(0, 1) while True: cpu = psutil.cpu_percent() backlight.graph_off() backlight.set_graph(cpu / 100) if killer.kill_now: break sleep(0.3) print "End of the program. I was killed gracefully :)" backlight.graph_off()
def stop(): p.stop() b.rgb(255,0,0) l.write("S T O P") b.graph_off()
def player(radio): global p p = vlc.MediaPlayer(radio) p.play() def stop(): p.stop() b.rgb(255,0,0) l.write("S T O P") b.graph_off() #MAIN BODY l.clear() b.graph_off() @j.on(j.UP) def handle_up(ch,evt): print("Playing BBC Radio 2") l.clear() b.rgb(255,0,255) l.write("BBC Radio 2") player(radio2) @j.on(j.DOWN) def handle_down(ch,evt): print("Playing BBC 6 Music") l.clear() b.rgb(87,145,146) l.write("BBC 6 Music")
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 files = [] print('Loading samples from: {}'.format(patch)) for filetype in FILETYPES:
[0,0,0,2,0,0,0,0], [0,0,0,0,4,0,0,0], [0,0,0,0,0,4,0,0], [0,0,0,0,0,0,8,0], [0,0,0,0,0,0,0,16], [0,0,0,0,0,0,0,0] ] def tidyup(): backlight.off() lcd.clear() def get_anim_frame(char,fps): return char[ int(round(time.time()*fps) % len(char)) ] backlight.graph_off() backlight.off() lcd.set_cursor_position(0,0) lcd.write(chr(0) * 16) lcd.set_cursor_position(0,1) lcd.write(chr(0) * 16) lcd.set_cursor_position(0,2) lcd.write(chr(0) * 16) time.sleep(1) for x in range(0,255,5): backlight.single_rgb(3,x,x,x) atexit.register(tidyup)
def reset(): lcd.clear() backlight.graph_off() backlight.off()
def tidyup(self): backlight.off() backlight.graph_off() lcd.clear()
def clear_indicators(self): backlight.graph_off()
def tidyup(): backlight.off() backlight.graph_off() lcd.clear()