Vscode for gamebuino with intellisense -- By bfx

VSCode for Gamebuino with IntelliSense

Author : Β bfx

The Arduino IDE is a good starting point to code with the Gamebuino, but it lacks features that one can expect from a modern development environment:

  • Context-aware syntax highlighting (the highlighting in the Arduino IDE is based on static keywords)
  • Code auto-completion
  • Contextual information on function or structure definition

VSCode is an open source IDE from Microsoft (more or less based on Visual Studio) that provides all these modern features under the name IntelliSense and supports Arduino development. So it is normal to try to use it with the Gamebuino.

There is already a tutorial in french by delay for the basic steps, and a forum post by Crystal Noir regarding the proper configuration of "IntelliSense" (the VSCode set of functions for context-aware features). This is a good basis, but I could not really make IntelliSense work as expected, with unpredictable results. Eventually, by chance, it worked.

So I found the problem deserves more in-depth analysis, and a decent understanding of the "obscure reasons". So here we are! Consider this tutorial as the English version of the other one, with some formalization of the IntelliSense configuration.

Please go to the full tutorial on GitHub.

As soon as the MarkDown editor is available for the Gamebuino pages, I will copy the content of the tutorial here.

Author : Β Steph

Hi, bfx,

Thank you for this long tutorial full of explanations and advice. You really delved into the subject! I understand some things better now:-)

Here are some tips for macOS (lower-case m!):

Complete reset of the IntelliSense Database

IntelliSense user databases are located in ~/Library/Application Support/Code/User/workspaceStorage:

$ tree -a ~/Library/Application\ Support/Code/User/workspaceStorage
/Users/steph/Library/Application Support/Code/User/workspaceStorage
└── 82a2b96a83f9401ecbc0e7e3f177d858
    β”œβ”€β”€ ms-vscode.cpptools
    β”‚   β”œβ”€β”€ .browse.VC.db
    β”‚   β”œβ”€β”€ .browse.VC.db-shm
    β”‚   └── .browse.VC.db-wal
    β”œβ”€β”€ state.vscdb
    └── workspace.json

And the local sketch database is actually located in .vscode/ipch:

$ tree -a sketchname
β”œβ”€β”€ .vscode
β”‚   β”œβ”€β”€ arduino.json
β”‚   β”œβ”€β”€ c_cpp_properties.json
β”‚   β”œβ”€β”€ ipch
β”‚   β”‚   └── c7e9a5004e7d31e0
β”‚   β”‚       β”œβ”€β”€ sketch.ipch
β”‚   β”‚       └── mmap_address.bin
β”‚   └── settings.json
└── sketchname.ino

c_cpp_properties.json configuration file

The environment variable that designates the user space is not USERPROFILE, but HOME :

"env": {
        "PACKAGES_PATH":   "${env:HOME}/Library/Arduino15/packages",
        "SKETCHBOOK_PATH": "${env:HOME}/Arduino"

... and I guess it must be the same for Linux!

Thanks again for this tutorial which is really very useful!

Author : Β bfx

Thanks for the info!! I will integrate it as soon as possible (once I found a way to correct formatting issues on the web page).

BTW do not trust too much the part with "multiple .ino files", I still have troubles with that, and I will need to adapt the section.

Author : Β Steph

I've never used multiple .ino files... and I sincerely think I will never code this way ;-)

Author :

Β Steph

Due to recent update of Arduino Boards SAMD 32-bit ARM Cortex-M0+ (v1.8.1) and Gamebuino META Boards (v1.2.2), it would be advisable to update your c_cpp_properties.json file by checking the compilation options and inclusion paths :-/

Hi bfx,

Thank you for updating your IntelliSense configuration file. You should correct some small mistakes about the path to the compilers on macOS and Linux:

"compilerPath": "${env:LINUX_PACKAGES_PATH}/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++.exe ..."

"compilerPath": "${env:MAC_PACKAGES_PATH}/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++.exe ..."

It would be necessary to replace g++.exe by g++.

I saw that you didn’t reflect the changes in the text of the tutorial… I guess you got lazy… which is quite understandable. But I think a little warning note might be useful for your future readers.

Thank you again!

1 Like

UPDATE July 2019:

  • Adapted folder paths to reflect the last version of the Gamebuino and SAMD boards (hopefully)
  • Added support for the Windows Store version of the IDE
  • Added a section to explain what the VSCode Arduino extension creates as a default file with minimal Tag Parser support
  • Corrected the typo with β€œ.exe” (thanks Steph for the finding!)