Use Visual Studio Code for your Particle development needs

Hey,
if you are a fan of Visual Studio Code I wrote an article on how to use it to build and flash your Particles in Hackster:

enjoy!
Gustavo.

8 Likes

Looks pretty good !
The only drawback is that I can’t configure the include path…
I updated my c_cpp_properties.json file with the following:

[...]
"includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
    "D:/Projects/Dev_WTY" ]
[...]

where the second path is where I stored the libs like OneWire. I’m still getting the message :

TemperatureSensorDS18XX.h:24:29: fatal error: OneWire/OneWire.h: No such file or directory
#include "OneWire/OneWire.h"

and of course, the file exists as D:/Projects/Dev_WTY/OneWire/OneWire.h

Any clues ?

Hi, are you getting that error when you try to compile? It so, I read somewhere that the particle CLI does not support include files, so you have to create soft links or copy all the lib files to the dir where you have your ino file.
Hope it helps,
Gustavo

CLI does allow for subdirectories but your include statements need to be flat

//#include "OneWire/OneWire.h"
// needs to be
#include "OneWire.h"
1 Like

thanks @ScruffR!
So @YbuQc, maybe you should copy (or softlink) the directories of your libraries to the project folder, and flatten your include statements as ScruffR mentioned in his post below.
Let us know how it goes…
Gustavo.

2 Likes

It’s indeed working if I perform a brutal copy.

Too bad, but for me it’s a no go. There is no way I will modify my code to accommodate a specific tool. It’s a shame as Visual Studio Code looks pretty nice and fun to play with. I’d lik to be able to use my code in either web IDE or a local tool, and this can’t be done right now.

Thanks @ScruffR and @gusgonnet for your help.

That issue with needing to cater for different tools seperately will be sorted with Libraries 2.0 and IDEs 2.0, which also make importing other libraries a lot easier.

2 Likes

Thanks for the info @ScruffR, that’s a very good news! Can’t wait to use IDEs 2.0 :wink:

getting curious now where you got that info and when is the ETA for IDE 2.0 :neutral_face:

@gusgonnet, as Elites we do get some peeks behind the scenes what’s going on and coming up and one of the bigger tasks Particle is currently working on is this Library 2.0 which is already undergoing some “early beta” testing and is a basis for IDE 2.0.
There is no official ETA but it’s rather high on the prority list.

3 Likes

cool! that's what I want to be when I grow up!!! :stuck_out_tongue:
thanks

3 Likes

Please add these instructions to the tutorial to get OTA flashing to work with the Electron. Thanks!

done, many thanks for the suggestion!

1 Like

Is this guide still accurate? I have lots of build issues when I try this. I guess it might be the IDE naming everything with a .ino extension and VSCode naming everything with a .cpp extension. I know there are caveats when switching between them, but I don’t know what they are. VSCode won’t flippin’ tell me. Compiling just tells me everything is SUPER WRONG

Actually, before that, is there any IDE environment that shows code problems inline, before you compile, for Particle devices? Compiling simply to check for errors is … non-optimal and only minimally helpful.

If .ino poses a problem, just use .cpp and add #include <Particle.h> and function prototypes in all your .cpp files.

still valid. I’ve been using it almost every day for the last 5 months.
if you include a library please flatten the directory structure so all lib files (.cpp and .h) are next to your .ino files.
Gustavo.

Do I have to flatten all of the Particle headers also?

Before I even attempt to collect all of those things and put them in one place, does this IDE show you compilation errors before you compile like any other IDE made in the past 20 years?

not sure what you meant. If those headers are included in the libs your proj is using then the answer is yes.

nope

Are there any IDEs at all that do show compile errors before you build?

This is a basic thing I’m asking for. Just basic syntax validation and rudimentary type checking.

double radians(double deg);```

it's pointing at the 2nd ```double```, not the first.  that formatting is lost here.

I have dozens of compile errors like that.  This code compiles fine on the Web "IDE"

Sorry that I sound super whiney, I’m having a bad day and am very frustrated with getting anything “off-road” working on this platform. The paved route is very well done, manicured, well-kept, etc. One step off that path and you are in the weeds.