Particle Workbench - Berkeley-MDes/24f-desinv-202 GitHub Wiki
Create, edit, and flash a new project in Particle Workbench
- click on the Particle Workbench extension on the left sidebar of VS code
- scroll down to the area labeled "Code" and click on "Create new project"
- A window will open, prompting you to select a parent folder for the project
- Navigate to the location you want the project to live, and click on blue button
- VS Code will prompt you in the Command Palette to enter a project name
- Type it in, and hit 'Enter'
- VS Code will prompt you to verify that you want to do this; click or select 'ok' and hit 'Enter'
- The project has now been created
Navigate to source code
- In the explorer view on the left, open up the 'src' directory
- click on the file with your project name, as in .cpp
- This will expose the file you are going to use for the project
- You can start to edit the file from the boiler plate code provided, or paste in your own
- To paste in your own, select all (command-a or control-a) and hit backspace or delete, then paste from your clipboard
Clean your workspace
- Sometimes, after many compilations in VS Code (or after moving your files), you need to clean the directory area you're working in
- To do this, you can click on the notifications button in the bottom-right area of the screen (Bell icon) and located the notification with a message like "Your local abuild appears to be dirty. Clean?"
- Click the [clean] button
- Cleaning can take some time, so please be patient
Set the project up
- At the bottom of VS Code's window, you will see a status bar
- If you have installed Particle Workbench, this will include tabs for the following
- Active Particle [Platform]
- Active [deviceOS Version]
- Your Target [Device] ID/Name
- First, click the [deviceOS Version] button and select the correct version (5.8.0 as of 9/27/24)
- Next, click the [Platform] button and select [Photon 2 / P2]
- Finally, click the [] button and VS Code will prompt you to enter the name int he Command Palette. Your device name is the name you gave your device when you registered the photon2 in the Particle.io Console
- You are now ready to compile code using the Particle Workbench! Note that after cleaning in a new project context, you should be able to continue to compile repeatedly without cleaning, and that compilation will take far less time.
Note: You can also bring up the command palette with โงโP (Windows, Linux) | โงโP (macOS)
and type Particle: Configure Project for Device
, which uses the currently connected device's name, and automatically selects the OS and platform based on what is on the device.
Connect your device
- Connect your device via USB or to a wifi network
- Once connected, you can start to flash the device with firmware
Edit and compile/flash
- Edit your file (this is the fun stuff!!)
- Compilation can frequently be faster than flashing, so feel free to "check" your code for errors before flashing
- If you are sure that your code is operative, go ahead and skip compilation and flash instead
Common Pitfalls
- You aren't able to compile and receive a strange error, even though everything seems like it's been set up correctly. This can happen as a result of moving files around, sharing projects between computers, or because you've made significant changes to a project that the Particle Workbench hasn't tracked.
- Solution: Clean your project
- You have installed something new in your shell environment, but you don't see the tools you've recently installed.
- It's possible that you haven't refreshed VS Code by opening up a new Terminal window (which initializes your shell session and includes all of your latest greatest).
- Solution: Open up a new terminal to gain access to your new tools.
- You type
particle serial mac
but you get an error indicating the CLI tools aren't installed.
- Solution: You might need to click on the Particle Workbench extension home page, and then click on [Launch CLI] for the first time, which sometimes prompts the workbench to install the command line Particle tools.
- You haven't set your project up and you try to compile without selecting the correct targets.
- Your compilation process is "taking a long time". This can happen because it's the first time you've attempted to compile, and there is a LOT of stuff that VS Code needs to know about that first time!
- Solution: Please be patient; the subsequent compilations should take less time.
Tips'n'Tricks
-
In the beginning, you may find it easier to set up a single project to use for a while and just copying in the text of your files so that you have them elsewhere. Once you start compiling more frequently across many projects you'll be generating larger files on disk, so portability decreases. It's also easy to forget to set up your project when you're in a hurry and just need a quick answer about a problem. That said, as long as you're removing your build folders, projects stay pretty small.
-
See this page for a troubleshooting guide regarding the main status LED