Onboarding tips (VS Code) and issues

It appears that I’m late to the party as I recently discovered Arduboy. I wish I learned of this neat little device while I was waiting for my PlayDate to arrive.

Anyway, I recently set up my development environment and I thought I’d share my workflow as well as issues I have run into. Since I don’t have a physical Arduboy yet I have been using the ProjectABE emulator. Although the emulator provides a code editor, I’d prefer to stick with my typical IDE, VS Code (especially as it supports a VIM plugin).

To work with VS Code, you need to install the Arduino extension provided by Microsoft. You then need to install the Arduino IDE. Unfortunately the extension does not yet support version 2.0 of the Arduino IDE so make sure you install a previous version. I wasted quite a bit of time trying to get this to work

In the Arduino IDE, make sure you install the recommended libraries like Arduboy2, see this guide. Unfortunately I was not able to create a board management configuration for Arduboy as https://arduboy.github.io/board-support/package_arduboy_index.json appears to be dead. Nonetheless, this is not an issue. In the VS Code Arduino extension you’ll simply need to select the Leonardo board.

Now to configure your project in VS Code, make sure you have an arduino.json at the root of your project. This file will contain your selected board, e.g. "board": "arduino:avr:leonardo". This file also needs to contain an output configuration, e.g. "output" = "build". Otherwise, the VS Code extension will build to a tmp directory and immediately remove it upon a successful build (odd default behavior).

Now for the workflow, you can create a build by running Arduino: Verify. This will create a .hex file in your configured output location. Finally you can run the file on the emulator with the command ~/ProjectABE/ProjectABE build/GameName.ino.hex. I tried to configure this command to run as a post build script through the Arduino VS Code extension but I was getting a screen error. I’m developing on a Chromebook so others may have better luck. On a side note, I wish the emulator remembered the window location as I have to resize it every time it’s launched.

And that’s it! Now I can develop on the emulator using my preferred IDE, VS Code, along with all of my plugins and great intellisense support.

(I would have provided more links above but I guess new users to this forum are limited to only 2)

2 Likes

This should be buit automatically when you select an .ino file

Mine shows the selected board, etc.

If I click on the Board Configuration (in my case where it says ‘Arduboy (FX)’, it reveals the ‘Arduino Board Configuration’ panel. Allowing you to configure these parameters.

Are you getting the same?

Does the tmp folder get deleted when you build rather than verify?

My tip here is to build into a directory that is not part of your project path as it mucks up searching. When you build into the same path and search for text within your code, you will often get two results - one in the source and one in the build. This can be confusing and can result in you editing copies of the original source in the build directory.

"output" : "C:/Temp/Build" 

@bateske recently reached out to me to help him fix this but he hasn’t responded to my reply.

Yes. Although there is no default output configuration.

Does the tmp folder get deleted when you build rather than verify?

Is there a way to trigger a build beside verify? That’s the only way I know how to trigger one.

When you build into the same path and search for text within your code, you will often get two results - one in the source and one in the build.

Thanks for the tip. I think I read that recommendation somewhere else as well. I have it one level up in a build folder.

@bateske recently reached out to me to help him fix this but he hasn’t responded to my reply.

Am I missing something not having the “correct” board configuration?

No there isn’t. Shame really!

Ooops, I meant Upload. Ctrl-Shift-U on Windows maybe? (I am on a Mac).

Ooops, I meant Upload. Ctrl-Shift-U on Windows maybe? (I am on a Mac).

It might not get deleted but I don’t have a physical device yet so upload doesn’t make sense. I’m on a Chromebook which is effectively Linux (through Crostini).

1 Like

Not really. The binaries will be a couple of bytes larger because the board name is embedded somewhere in them and Arduboy is shorter than Leonardo.

Until it’s properly fixed, I have a repo that hosts a back-up copy:


That should be "output": "build" (:, not =), though the "build" can be any valid directory name.

To be honest, I rarely bother with this unless I actually need a copy of the .hex file. It might speed build times up perhaps, or reduce wear on the storage device, but usually I don’t find that to be much of an issue. VSCode/VSCodium has an ‘upload’ button that uploads immediately after building, before the folder is wiped.

Though I suspect for Windows it might actually just put the file in the %TEMP% directory. I would have thought a Linux-based system would do the same, but apparently not?

(If I get time, I’ll double-check what it does for Windows.)

I think the intented way is to install the IDE first and then the Arduino extension, but if it works the other way around then the order possibly doesn’t matter.

That’s probably the case. You can always go back and edit them in later.