Visual studio code (vscode) integration

I thought I’d share my findings and thoughts on a better IDE. I’m running everything on an iMac (but what I’m sharing can work on Windows too)

The Arduino IDE is pretty limited. I’ve experiments w/ a few IDEs and am settling in on VS Code. It’s a much better IDE (actually quite nice); supports most of what you’d expect while developing (reference search, auto-complete, etc) and debug. It’s also open source.

With a couple of adjustments in VS Code and Blinks, I’ve managed to integrate VS Code with Blinks libs and seems to be working fine for dev and debug. Note, VS Code still relies on the Arduino IDE for compiling and upload. Right now, VS Code does see the “Blinks Tile” board but not the new faster Blinks Programmer… yet!

Some Notes:

  1. Serial Port monitor baud rate
    The serial port monitor (in vscode) has an upper limit baud rate of 250000 but the original Blinks core hardwires the baudrate to 500000. So, I modified my local Blinks core (and Blinklib) to support specifying either 250k or 500k baud rate during initialization of the ServicePortSerial (e.g. sp.begin(250000)). The 250k baud rate has proven to be reliable.

ServicePortSerial sp;

void setup() {// specify a baud rate, or call begin() to stay with 500k

    The default (no argument) call to the begin method keeps it at the 500k rate.
  1. Faster Blinks Programmer:
    The faster Blinks Programmer is not being seen by VSCode yet. The new programmer works fine on the Arduino IDE but not in VSCode yet :thinking: - still actively working on why. In the meantime, I’m using the USBTiny programmer.

  2. Specifying Arduino app location.
    If needed, you can specify the Arduino app path in the VS Code User Settings (CMD-Shift-P).

  3. Compile cache (Arduino output path)
    To speed up compiles in VSCode, you’ll need to set an output folder (compile cache location) for the Arduino IDE. I did this by editing the arduino.json file in the .vscode directory for my sketch, and adding a new line (and manually creating the new build directory):

"output": "../build",

Hope others find this useful. I’ll update this more as I move forward.

Thanks for offering this up Ken! Excited to check it out!

This looks promising. @Vanilla has been using Sublime to do a similar trick, we are gonna test out workflows.

One thing I should note is that the faster “Blinks Programmer” is just a flag being set for AVRDUDE. The flag is -B3 and the number behind the B simply sets the bitclock. The lower the number the faster the programming speed, I believe the USBTiny is something like B10 and I couldn’t get reliable programming less than B3.

Not sure if that helps directly with getting that programmer working, but if you have it working with the USBTiny, it should just be a matter of adding that flag to the AVRDUDE command (assuming it is still using AVRDUDE to program)

Yes, I figured out the bitclock calculation based on the F_CPU speed (async double speed) and so the UBRR0 was 1 for the 250k baud rate. You’re right, the USBTiny was limited to B3.

I haven’t used Sublime. What level of integration does it support for Blinks dev (or Arduino dev)? Programming directly? Compiling? Editor only? I’m pleased to hear there’s alternatives to the Arduino IDE and folks are looking into it!

Ok, I’m pretty sure I figured out how to add the Blinks Programmer to VSCode via a backdoor method. I’ll update later with the details but it looks promising and my initial tests are working.

I took up a suggestion from @jbobrow to look into modifying the USBTiny parameter directly. To do this required identifying the correct programmers.txt file used by the Arduino app, which changes if you’ve updated using Boards Manager. I finally found the right one as described here. So, although figuring out the backdoor linkage between VSCode and the Arduino IDE was interesting (VSCode javascript file modification) I’m going to opt for the easier path of just modifying this “Application Data” programmers.txt file instead.

I think it should be similar to use VS Code. Someone made a Sublime Text plugin that provides an Arduino-like environment for editing, compiling and uploading sketches. It’s called Stino. But for the blinks platform, it fails to check the toolchain(which I have no idea what it is). I saw someone reported that bug on Stino’s Github page. But there is no reply to it. And for the serial, it only shows 25000 but no 50000. It can’t recognize fast programmer as well. Therefore, I have to make sublime only a text editor. And the sublime became very slow when I enable the plugin. Wonder VS Code would not be that slow as well?

I’ve been using VSCode for development, compile, and upload/debug (and it’s Git aware). With some minor modifications (I posted here awhile ago) uses the faster programmer too. And the Serial Monitor works at the 250k baud rate (with the Blinks core change I just checked in). I’d recommend VSCode at this point as it gives everything needed for development.