-
|
Hello, I am trying to setup a program to do receive data via bluetooth from my computer, it may or may not be too much data for the hub to hold all at once on top of the code telling the hub what to do with the data. So my first thought is to define functions and pass arguments/parameters through my function call but this doesn't seem to do anything at all (see example) from pybricks.hubs import CityHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Direction, Port, Stop
from pybricks.tools import multitask, run_task, wait
hub = CityHub()
X_Motor = Motor(Port.A, Direction.CLOCKWISE)
Y_Motor = Motor(Port.B, Direction.CLOCKWISE)
async def main():
def test_function (x_coord, y_coord):
await multitask(
X_Motor.run_target(500, x_coord, Stop.COAST),
Y_Motor.run_target(500, y_coord, Stop.COAST))
test_function(800, 390)
wait(1000)
run_task(main())My plan is for the data stream to include coordinates for X, Y, and Z motors that can be passed directly into the run target function but either I'm doing something wrong here or it doesn't work the way I expect it to. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
from pybricks.hubs import CityHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Direction, Port, Stop
from pybricks.tools import multitask, run_task, wait
hub = CityHub()
X_Motor = Motor(Port.A, Direction.CLOCKWISE)
Y_Motor = Motor(Port.B, Direction.CLOCKWISE)
async def test_function(x_coord, y_coord):
await multitask(
X_Motor.run_target(500, x_coord, Stop.COAST),
Y_Motor.run_target(500, y_coord, Stop.COAST))
async def main():
await test_function(800, 390)
await wait(1000)
run_task(main())All functions that
|
Beta Was this translation helpful? Give feedback.
All functions that
awaitneed to beasyncand all functions that areasyncneed to beawaited.run_task()andmultitaskare special in that they t…