I just started really digging into Workbench on VScode. It’s pretty great.
However, I am having trouble just getting what I would consider to be basic info about how this IDE works.
My first question: I have a project that requires a master Argon and a slave argon. They run different firmware. I would like to have one project with the two INO files, and then target one or the other for build/compile/flash at a time. I can’t figure out how to do this.
Secondarily, is there a good place to learn how this environment works? What and where are these config files? If I remove a library, what do I need to edit? Are there additional options for the IDE and the build process? Where might I learn all this?
I have tried following the VScode tutorials, but seriously… “Here’s how to install themes!” is nice to know, but WTF where is the important stuff!!!
I just started really digging into Workbench on VScode. It’s pretty great.
awesome! happy to hear
I have a project that requires a master Argon and a slave argon. They run different firmware.
VSCode has a featured called "multiroot workspaces" that seem to align pretty well with what you are trying to do. read up on them here:
is there a good place to learn how this environment works?
if you haven't already seen them, we have a bunch of docs and walk-thru videos:
in particular, you might want to check out:
Getting Started with Particle Workbench:
Building Firmware Locally with Particle Workbench:
TL;DR
cmd/ctrl+shift+p reveals VSCode's "Command Palette", typing Particle: filters the list of available commands to just those added by Workbench / Particle
projects need to be formatted specifically to take advantage of Workbench functionality - run Particle: Create Project, follow the prompts, and check out the results
under the hood Particle Workbench uses the Particle CLI to do many of the core operations - login, cloud compile & flash, project creation, etc. you'll see this in effect running commands like Particle: Serial Monitor
basic project & library settings are stored in project.properties, VSCode / Workbench-specific settings in .vscode/settings.json
you can interact with the Local Compiler directly (inspect current settings, apply overrides, view and run available tasks) - run the Particle: Launch Compiler Shell command and play around
Thank you for all that. But I’m not sure it answers my questions.
For example, I can’t seem to have two .INO files in the same folder. So it seems that either VSCode or PW is configured to search for and find a top level .ino/cpp file and compile that.
I tried to use the CLI and specify the top level file, but that failed, with or without the 2nd .INO file.
So one kind of thing I’d like to know is how does this tool (presumably PW but maybe just VSCode?) know to use the .ino file as the top level? And is there an easy way to target a specific one or switch?
The Multi-root workspaces thing you sent doesn’t really seem to help me. What I want is to be able to work on two .ino files that share both installed libraries AND possibly other included .cpp files with shared code, but ones not managed like libraries. For example, I have some data structures defined in those files. I’d like to be able to have one copy of those data structures, manage it in place, and not have to worry that my two executables are compiled with different versions. The Multi-root feature seems to be a way of working on two separate code bases at the same time, but this isn’t really a separate code base.
All that said, I appreciate your help, but if your answer is “Look, it’s really a lot easier if you just maintain two separate folders/projects for both the master and slave”, I will trust you.
And it's not the "top level" (whatever you are refering to here) but the one and only .ino file that resides inside the src folder next to the project.properties file of the project.
What I'd do would be one single .ino file which may pull in either the master or slave code (stored in their respective .cpp files) via compiler directives.
@ScruffR, can you just let me know if this is some type of standard with VScode, or something to do with the PW extension? I looked in the project setup and configuration files, and there’s nothing about INO files. This leads me to believe that the extension has set something up somewhere.
So looking in the project files, I see this in settings.json:
Holds on to my last set device options (And provides a debug setting, which I haven’t used yet)
So I take it that the extension core is what dictates the plan to search for an INO file, and treat is as the top level? But if that’s the case, why would the extension alias be set here? Or is this redundant or placed here for override/seeding in case a user wants to have more extensions?
Cool. But I am still trying to understand what part of the compile tools recognizes which file has the main entry point for the program.
In one of my earlier issues, I had to change the extension for an example buried in a library because they used .ino, and the compiler was confused, seeing multiple setup() and loop() definitions. So it appears that the Particle Extension looks for an INO and includes it by default.
If I were to change the extension to cpp on my top level file, how would the compiler know where to start?
(Just tried to invoke Particle: Cloud Compile, and… failed to compile)
So yeah, looks like the Particle Workbench assumes the project has one and only one .INO file (or if there are more, they can’t contain duplicate function definitions).
Interesting question. I think it’s the one that includes #include "Particle.h. And you just need one setup() and loop() in there. When you rename from .ino to .cpp you have to add that include.
I renamed my source to rrr.cpp and it compiled just fine provided I added the import.
Are you using Particle Workbench in VSCode? None of my files have #include Particle.h.
I think that when I first tried these out with a Spark Core I used that in the online IDE.
(I tend to move on to something else and then come back to these guys every few years to solve another problem! So I start over from scratch essentially. I think you could drop that include statement with the Photons a while ago, if you were using their tools.)
I'm pretty sure that's not the case but I'd have to test.
The "main" file of the project is the one inside src that holds setup() and/or loop() and there can only be one that holds either one of them.
BTW, it's not an issue for the compiler if there were more but the linke wouldn't know which one to pick. When putting everything together all global symbols must be named disambigously.
The thing with .ino files is that they undergo an extra preprocessor run to convert them into .cpp files by adding some things like the #include statement @kenmacd mentioned as well as adding function prototypes where needed.
But they should when they are using any Particle symbol. For .ino files the preprocessor will add it when it's not present, for .cpp files you must add it.