def boot(): gc.collect() log.setup() # config.setup() # Setup display display.setup() log.success("display setup") display.text("wifi") wifi.setup() log.info("trying to connect to wifi") for _ in range(25): if wifi.isconnected(): log.success("connected to wifi {}".format(wifi.get_wifi_ip())) break machine.sleep(200) else: log.error("could not connect to wifi") return # pylint: disable=no-member #asyncio.get_event_loop().run_until_complete( # display.scroll_text("{}".format(wifi.get_wifi_ip()))) machine.sleep(500) # Set time display.text("time") clock.setup() log.success("time is synced") display.text("done")
def setupCanvas(): global canvas, origin origin = (canvasWidth / 2, canvasHeight / 2) canvas = Canvas(width=canvasWidth, height=canvasHeight) canvas.pack() canvas.configure(background=di.getHex(51)) di.setup(width, wheelbase, wheelWidth, wheelDiameter, wheelOffset, canvas, canvasWidth, canvasHeight, canvasScale)
def open(): ''' Initialize all the hardware used for sampling.''' GPIO.setmode(GPIO.BCM) #GPIO.setwarnings(False) # only needed if my scheme for pin sharing doesn't work LED.setup() LED.setColor(init_color) LCD.setup() LDR.setup() barometer.setup() #DHT.setup() cloud.init()
def setup(): gpio.setmode(gpio.BOARD) display.setup() gpio.setup(leds, gpio.OUT) gpio.output(leds, gpio.LOW) gpio.setup(buttons, gpio.IN, pull_up_down=gpio.PUD_UP) for pin in buttons: gpio.add_event_detect(pin, gpio.FALLING, bouncetime=200) gpio.add_event_callback(pin, set_active_destination) set_active_destination_led()
try: f = open('port.txt', 'r') except IOError: print "No server found" sys.exit(1) port = int(f.readline()) f.close() s.connect(('glaser', port)) name = raw_input("Enter your name: ") s.send(name) act = None; plyrs = None; tblCards = None; pot = None; btn = None; actPlyr = None; nxtBlndRs = None; blnds=None; msg = '' display.setup() while True: nxtMsg = s.recv(4096).split(":") #print "Recieved", nxtMsg myMny = 0; myBet = 0; maxBet = 0 if nxtMsg[0] == "ACTION": for p in plyrs: if p == "": continue pName, cards, mny, bet = p.split(",") if name == pName: myMny = int(mny) myBet = int(bet) if int(bet) > maxBet: maxBet = int(bet) #print maxBet, myBet
#!/usr/bin/python import pygame, display pygame.init() clock = pygame.time.Clock() # Clock to limit speed screen = display.setup() for n in range(100): clock.tick(45) colour = display.random_colour(100, 255) display.draw_circle(colour, screen) pygame.display.update() raw_input("Press a key")
choice = song_list[pick] play_song(choice) def knop_pressed(pin): print("Knop is ingedrukt") pick_song() time.sleep(1) threading.Timer(1, lees_potentio).start() threading.Timer(2, lees_thermistor).start() threading.Timer(1, lees_pulse).start() knop1.on_press(knop_pressed) try: display.setup() print("Display setup complete") #write_message("") display.send_instruction(0b11000000) display.write_message("169.254.10.1") print("Display message completed") except KeyboardInterrupt as e: print("quitting...") if __name__ == '__main__': socketio.run(app, debug=False, host='0.0.0.0')