-
Hi, I'm currently using PyBricks with VS Code. Currently, I'm facing an issue where, if I have multiple SPIKE Prime Hub on at the same time, VS Code doesn't seem to allow us to choose which brick to connect to. Is there any solution to this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
You can give each hub a unique name when you flash the firmware and then specify the name when using the |
Beta Was this translation helpful? Give feedback.
-
Hi, unrelated but how do you use PyBricks Spike with vsc? |
Beta Was this translation helpful? Give feedback.
-
We have several spike hubs for our team, and we use VS code to program/execute. We have a VS Code task to automate the running of the code. .vscode\tasks.json {
"version": "2.0.0",
"tasks": [
{
"label": "Run on robot",
"type": "shell",
"command": "${workspaceFolder}/.venv/Scripts/pybricksdev.exe",
"args": [
"run",
"ble",
"--name",
"${env:robotName}",
"${file}"
],
"problemMatcher": {
"owner": "python",
"fileLocation": [
"absolute"
],
"pattern": {
"regexp": "^(.*)File(.*)(C:(.*)\\.py)(.*)(line(\\s*))([0-9]+),",
"file": 3,
"line": 8
}
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": false,
"revealProblems": "onProblem"
}
},
{
"label": "git pull on startup",
"type": "shell",
"command": "git pull",
"windows": {
"command": "git pull"
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"runOptions": {
"runOn": "folderOpen"
},
"problemMatcher": []
},
{
"label": "Run on any robot",
"type": "shell",
"command": "${workspaceFolder}/.venv/Scripts/pybricksdev.exe",
"args": [
"run",
"ble",
"--name",
"${input:robotName}",
"${file}"
],
"problemMatcher": {
"owner": "python",
"fileLocation": [
"absolute"
],
"pattern": {
"regexp": "^(.*)File(.*)(C:(.*)\\.py)(.*)(line(\\s*))([0-9]+),",
"file": 3,
"line": 8
}
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": false,
"revealProblems": "onProblem"
}
}
],
"inputs": [
{
"type": "pickString",
"id": "robotName",
"description": "Which Robot?",
"options": [
"BOB",
"CURIOSITY",
"GABE",
"LEROYYY",
"MITZVAH",
"NOTDECLAN",
"OAKS",
"PATRIOT",
"SUPERNOVA",
"TIMOTHY"
]
}
]
} First set a user environment variable named "robotName" and set the value to whatever your hub name is. That way there can be a default robot per laptop. Then you can use a keyboard shortcut to run on the default robot with ctrl-shift-L, or you can use ctrl-alt-L to have the option to launch on any of the team robots. Here are the keybindings for that keybindings.json [
{
"key" : "ctrl+shift+l",
"command" : "workbench.action.tasks.runTask",
"args": "Run on robot"
},
{
"key" : "ctrl+alt+l",
"command" : "workbench.action.tasks.runTask",
"args": "Run on any robot"
}
] You can see in the tasks.json that we also have a git pull run every time we open our code for editing. You can choose to use that too or not. We have been using pybricks with vs code for a couple of years now, so let us know if you have any questions, or just ask here! https://github.com/FLL-Team-24277/FLL-Fall-2024-Submerged |
Beta Was this translation helpful? Give feedback.
You can give each hub a unique name when you flash the firmware and then specify the name when using the
pybricksdev
command.