Toggle Navigation
Hatchery
Eggs
Catcontent
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
""" """ import buttons import display import ledfx import os import utime FILEPATH = "/apps/Catcontent" def start(): while True: v = buttons.read(buttons.BOTTOM_LEFT | buttons.BOTTOM_RIGHT | buttons.TOP_RIGHT) if v != 0: ledfx.kitt(cycles=20) draw_cat() utime.sleep_ms(10) def draw_cat(): files = sorted( os.listdir( FILEPATH ) ) files = [ txt for txt in files if txt.endswith( ".txt" ) ] if len( files ) == 0: return randN = int( os.urandom( 1 ) [ 0 ] ) filename = FILEPATH + '/' + files[ randN % len(files) ] f = open( filename, 'r' ) with display.open() as disp: disp.clear() for i, line in enumerate( f ): disp.print( line, posy=i*20 ) disp.update() disp.close() f.close() start()