def run(): """Run the page scheduler """ pages = [NTP(display), StarWars(), PacMan(display), Seconds(display), Time(display)] clear_next = True while True: current_ticks = utime.ticks_ms() now = utime.localtime() for page in pages: if page.ready(current_ticks, now): if clear_next: display.clear() clear_next = page.show(now) if clear_next: display.show() break utime.sleep_ms(5)
def show_health(health): display.fill(0) if health.is_healthy(): display.text('API healthy', 0, 20) else: display.text('API unhealthy!', 0, 20) display.show()
def load_and_show_trackables_menu(): trackables = api.get_trackables() display.fill(0) text = [] for trackable in trackables: text.append( [trackable.name, 'scrobble_item(' + str(trackable.id) + ')']) menu.initText(text) display.show()
def button_down_callback(pin): d = debounce(pin) if d == None: return elif d: # print('down') # print(pin.value()) # display.fill(0) # display.text('Down', 0, 0) # display.show() menu.moveDown() display.show() else: return
def button_up_callback(pin): d = debounce(pin) if d == None: return elif d: # print('up') # print(pin.value()) # display.fill(0) # display.text('Up', 0, 0) # display.show() menu.moveUp() display.show() else: return
def scrobble_item(item_id): display.fill(0) display.text('Scrobbling...', 0, 20) display.show() scrobble = api.post_scrobble(item_id) if scrobble == None: display.text('Something went wrong', 0, 30) display.show() else: display.text('Done!', 0, 30) display.show() sleep(3) load_and_show_trackables_menu()
roundWin = "X" #game manager gameWin = "X" ''' #move this code to gamemanager while (startVar.upper() != 'Y' or startVar.upper() != 'N'): startVar = input ("Do you want to start a game of blackjack?") if startVar == 'Y': gameMan = gameManager() chipsize, chipNums = gameMan.initChips() chipMan = chipManager(chipsize, chipNums) cardDealer = dealCards () player1, dealer = cardDealer.blackjackDeal() display.show(player1) display.show(dealer) continueVar = "Y" while continueVar.upper() == "Y": stayOrHit = 'H' val = "1" while (stayOrHit.upper() == "H"): stayOrHit = input ("Hit or Stay? press H to hit and S to stay") if stayOrHit == "H": player1 = player1.append(cardDealer.hit(deckOfCards)) if gameMan.busted(player1) gameMan.addRoundWin("Dealer") chipMan.transferToDealer (True) gameWinner = gameMan.checkWin(chipMan.getP1Chips(),chipMan.getP2Chips()) display.statusDisplay(gameWinner) break
def get_bottom( self): # Only required method for an object to work with display """ Get the bottom pixel y location of the objects image :return: """ # In this case, return the 'y' of the box + the 'height' of the box return self.box[1] + self.box[3] img = loadimg("../Images/dum.png" ) # Load up a dummy image, method is from 'pygameFunctions.py' obj = D(image=img) # Make an object display.show(obj) # Add object to display while True: # Main loop display.sample_frame() # Do a frame (this draws and waits a frames time keys = pygame.key.get_pressed() # Get the pressed keys # Move the object by key. Remembering that obj.box is a list '[x,y,width,height]' if keys[K_w]: obj.box[1] -= 1 if keys[K_s]: obj.box[1] += 1 if keys[K_a]: obj.box[0] -= 1 if keys[K_d]: obj.box[0] += 1
from display import display, graphics, menu display.text('Booting...', 0, 0) display.show()