Use Visual Studio Code for your Particle development needs

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.

sorry to hear about your bad day. Continue to write if you want to commiserate together further, I wasnā€™t having a super good day eitherā€¦ just not with this platform :slight_smile:
I think what you are after is a on-the-fly parser of the code, that would kick in while you write, but no, I havenā€™t seen such a piece of plugin/software around. Maybe the arduino plugin in VS Code could evolve to such thing in the future, maybe the Particle DEV could as well. However one can argue that the build process is so quick that ā€œinstantaneous feedbackā€ vs ā€œthree to five seconds away feedbackā€ is fine for a lot of people.
hope things look better tomorrow for you!
Gustavo.

2 Likes

Thanks.

If this were a language I had 1000 more hours of experience with, I would agree with you fully. As it stands, I fight syntax errors FAR more than anything else. The tooling should be able to assist me with that. I mean thatā€™s what tools and computers are for.

My skills lie partially in C#, and C# is one way to write plugins for Visual Studio, which DOES understand C++ well enough to give me what Iā€™m after.

So I think Iā€™m going to write a Particle extension for Visual Studio.

2 Likes

that would be extremely awesome!

I have fully switched to VSCode for doing Particle development.
Having all the login and device selection in Atom was nice, but the error parser never worked and the lack of control+click for jump-to-definition forced the switch.

To get the error parser working for Particle cloud build in VSCode, I extended the script from the original source in this post. There was a pretty odd thing where ā€œworkspaceā€ would be prepended to paths when errors were reported, and youā€™ll see it removed with the error parser regex.

Works on OSX. Untested on other platforms. Be sure to install the C/C++ extension. Error parsing isnā€™t always perfect, but it pretty much works and it is very nice to have. Use of a .ino file will not work, since it gets internally renamed to .cpp upon compile.

Hereā€™s my tasks.json:

//tasks.json for Particle online build
{ 
"version": "0.1.0", 
"command": "particle", 
"isShellCommand": true, 
"args": [], 
"showOutput": "always", 
"echoCommand": true, 
"tasks": [ 
    { 
        "taskName": "compile", 
        "suppressTaskName": false, 
        "isBuildCommand": true,             
        "args": ["electron","${workspaceRoot}", "--saveTo", "${workspaceRoot}/firmware.bin"],
        // Use the standard less compilation problem matcher.
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": ["relative", "${workspaceRoot}"],
                "pattern": {
                    "regexp": "^(/workspace|/worksapce/)(.*?):(\\d+):(\\d+):\\s+(warning|error|fatal error):\\s+(.*)$",
                    "file": 2,
                    "line": 3,
                    "column": 4,
                    "severity": 5,
                    "message": 6
                },
                "severity":"error"
            }
    }, 
    { 
        "taskName": "flash",             
        "suppressTaskName": false, 
        "isTestCommand": true, 
        "args": ["--usb", "firmware.bin"] 
    }    
]     
}
1 Like

Hi Andrew,
Iā€™d like to give this a shot, but I need to ask you few questions:

How is this supposed to work?
what does it do if you have an error in the code when you compile?
is it supposed to flag the line with the error in the source file itself?

If you have a screenshot with the outcome, Iā€™d like to see it, please.

I tried it in Ubuntu to see if I could find out how and if it would work, but did not succeed at even understanding what it should do.
thanks!
Gustavo.