from flask import Flask from practicum import find_mcu_boards, McuBoard, PeriBoard from time import sleep import math soundValue = 0 devs = find_mcu_boards() app = Flask(__name__) if len(devs) == 0: print("*** No practicum board found.") exit(1) mcu = McuBoard(devs[0]) print("[Yak G]") print("Mr. Poon Shotateerawasu 6010500109") print("Mr. Chutchawin Thaengthong 6010504686") print("= = = = = = = = = = = = = = = = =") print("*** Practicum board found") print("*** Manufacturer: %s" % \ mcu.handle.getString(mcu.device.iManufacturer, 256)) print("*** Product: %s" % \ mcu.handle.getString(mcu.device.iProduct, 256)) peri = PeriBoard(mcu) @app.route("/playeri") def playerI(): # val = str(peri.get_sound()) # val = str(peri.get_sound_player_i()) val_i = str(peri.get_sound(player = 1)) print("player 1 : ", val_i)
import arcade from practicum import find_mcu_boards, McuBoard, PeriBoard SCREEN_WIDTH = 600 SCREEN_HEIGHT = 600 SCREEN_TITLE = "Takro" BALL_COLORS = [ arcade.color.RED, arcade.color.GREEN, arcade.color.YELLOW, arcade.color.BLUE, arcade.color.MAGENTA, arcade.color.CYAN, ] mcu = McuBoard(find_mcu_boards()[0]) peri = PeriBoard(mcu) ######################################### class Game(arcade.Window): def __init__(self): super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE) arcade.set_background_color(arcade.color.DARK_SLATE_GRAY) self.score = 0 self.lives = len(BALL_COLORS) self.is_over = False self.balls = [] self.player = Player() peri.set_led_value(self.lives)
import usb from practicum import find_mcu_boards, McuBoard, PeriBoard from time import sleep import serial ser = serial.Serial('/dev/tty.Obi-Wan-SPPDev', 38400) devs = find_mcu_boards() if len(devs) == 0: print("*** No practicum board found.") exit(1) mcu = McuBoard(devs[0]) print("*** Practicum board found") print("*** Manufacturer: %s" % \ mcu.handle.getString(mcu.device.iManufacturer, 256)) print("*** Product: %s" % \ mcu.handle.getString(mcu.device.iProduct, 256)) peri = PeriBoard(mcu) sleep(2) print('ready') while True: try: val = peri.get_cmd() ser.write(str(val)) print(str(val)) sleep(2) except usb.core.USBError as e: print(type(e), str(e))
from practicum import find_mcu_boards, McuBoard, PeriBoard devices = find_mcu_boards() mcu = McuBoard(devices[0]) peri = PeriBoard(mcu)