Compiling Teensy Sketches with VisualCode (Win10)

Workaround for non standard Arduino installations

@turbok: I did a quick workaround and uploaded it to GitHub: https://github.com/luni64/VisualTeensy/releases/tag/0.9.1. Can you give that a try? (please follow the instructions on GitHub). As soon as I find some time, I'll improve the first startup behavior.

@WMXZ: Due to a bug, the last version didn't start up if it didn't find an Arduino installation. So turbok had no change to set the correct location in the settings tab.
 
luni,
with the introduction of vtCore, I cannot anymore compile VisualTeensy
gives me vtCore(unavailable) in the solution explores
maybe because I'm using net4.7.2 (I use also the 4.7.2 dev pack)
any advice?
 
I separated the GUI (project VisualTeensy) from the logic (vtCore.dll). vtCore.dll parses board.txt and generates makefiles, vscode.json etc.). Since vtCore doesn't contain a GUI it can easily be built platform independently. Therefore, it must not be linked against the full dotNet (which is Windows only) but against ".Net Standard 2.0" which is platform independent.

For testing purposes the solution also contains a quick test app (project "DotNetCore Tester"). This app should run under Linux, Max and Windows without recompiling (to be tested).

So, if you want to compile VisualTeensy you need to add the dotNetCore package to your VS2017 installation: In the VisualStudio Installer, go to workloads and add the "dotNet Core" package ("Plattformübergreifende .NET Core-Entwicklung", don't have a English installer). Make sure that dotNetCore 2.1 is selected in the details section.

Let me know if this doesn't work.
 
Let me know if this doesn't work.
reinstalled VS2017 with .net core and got it compiling
Get still some error in execution from VS2017 (e.g Arduino15 not found).
In my case "C:\Users\Walter\AddData\Local\Arduino15\packages"
 
Last edited:
completely missed that directory but the file seems not be there. Continue debugging
edit:
it seems VisualTeensy is looking for two directories in Arduino15: packages and hardware.
both are not in my installation.
from date of file it seems only preferences.txt is recently accessed
all other files 'package_index,...' are over one year old.
may it be that I download only Arduino.zip and do use installation?
 
Last edited:
The IDE BoardManager creates that directory maybe only if some device is pulled down. Looking at mine there is only one thing there relating to nRF52 I pulled the other week (15Nov2018) on what is other wise a new machine where I never got ESP boards or other Board - being mostly Teensy specific. On my system all dates are that 15Nov date.

So current IDE is still using that Arduino15 naming, just may not be populated for use.
 
Sorry, was in a rush this morning. I did some experiments trying to use VisualTeensy to support all boards Arduino supports (via Arduino Builder). Therefore I scanned the Arduino15 folder which contains installed plattforms... This was experimental code and was supposed to be in the development branch. Shit happens... I'll clean that up tomorrow.
 
Disabled the platform detection, should work again in master and development branches.
 
Something to discuss:
libraries:
we have the following possible library locations
- inside-sketch: "./lib"
- inside-sketch-folders "$(sketchfolder)/libraries"
- teensyduino libraries "$(arduinoroot)/hardware/avr/teensy/libraries"
- Arduino libraries "$(arduinoroot)hardware/avr/arduino/libraries"
At the moment teensyduino libraries are copied into sketch library

Q: is it a good idea to copy 'standard' libraries to inside-sketch library? IMO, this would only make sense if I wanted to modify stock library.
At least there should be an option 'link' or 'copy'

I would suggest to keep all four library locations separate
IMO:
sketch library is sketch specific (e.g. for development, overriding all others)
sketch-folder library is cross sketch
teensyduino and Arduino libraries are 'fixed' for all users
we can come-up with better and more intuitive path names
 
libraries:
we have the following possible library locations
- inside-sketch: "./lib"
- inside-sketch-folders "$(sketchfolder)/libraries"
- teensyduino libraries "$(arduinoroot)/hardware/avr/teensy/libraries"
- Arduino libraries "$(arduinoroot)hardware/avr/arduino/libraries"
At the moment teensyduino libraries are copied into sketch library

Plus you have the libraries from the "Arduino repository". I currently download them directly from the net into the project :)

Q: is it a good idea to copy 'standard' libraries to inside-sketch library? IMO, this would only make sense if I wanted to modify stock library.
At least there should be an option 'link' or 'copy'
IMO: this always makes sense since it will keep projects independent from possibly breaking changes in later versions of a library. Disk space is somewhat irrelevant these days. But I am fully aware that most users prefer to use shared stock libraries. So, I agree that having that as the default option is a good idea. Currently only the libraries from "$(sketchfolder)/libraries" are shared, the others are copied into the project.
Note: as soon as you allow more than one location for shared libraries the linker might get into troubles with "double" libraries so that needs to be handled in the generated makefile somehow... Having more than one location for shared libraries also needs changes to the libs section of the makefile I'm afraid. Maybe you find a more generic solution for that than the one currently implemented.
 
Nice extension!
Thanks

Are you considering targeting macOS as well?
As soon as there is some decent c# cross platform GUI...

Meanwhile: I tried to separate the business logic from the GUI, so if you want to port it to macOS it shouldn't be too hard.
 
Hello Luni,

Thank you for this addon to VSC. I like it and will never go back to arduino IDE !
 
Glad you like it. Once you got used to using a state of the art IDE like vscode it feels somehow sluggish to code with the Arduino IDE :)
 
Hi, I've just downloaded VisualTeensy and tried to use it unfortunately it will not run. Capture.PNG The pic shows the errors I received.
I installed vsCode followed by the c/c++ extensions. Then executed VisualTeensy.exe in VisualTeensy_v0_9_7_3. That produced the output shown above.
Bye the way what is the difference between VisualTeensy_v0_9_7_3 and VisualTeensy-master?
 
Looks like you don't have Arduino / Teensyduino installed? It requires a few files from it.
 
I had installed Arduino and Teensyduino before installing vsCode.
I assumed that was a given so I did not mention it.
 
Ok, I once had a similar issue with a fresh Arduino install. It looks like some of the required files (e.g. the huge list of Arduino libraries) are only generated at the first run. It probably doesn't find \AppData\Local\Arduino15\library_index.json. I recommend to first build a sketch with the Arduino IDE and use the Library manager once.

Sorry, I definitely need to make that first start code more robust...

-----------
Edit: I just deleted my \AppData\Local\Arduino15 folder and get the same error as you. After starting Arduino once the IDE regenerates the folder and vsTeensy starts without issue but without the Arduino library list. Using the Arduino library manager once generates the missing library_index.json which gives you the Arduino library repository in vsTeensy.
 
Last edited:
Yep, that worked fine. Thanks. Instead of altering your start up code, just change your Quick Start Guide.
Bye the way what is the difference between VisualTeensy_v0_9_7_3 and VisualTeensy-master? I was initially confused as to which should be installed. But then there is no .exe in the master.
 
what is the difference between VisualTeensy_v0_9_7_3 and VisualTeensy-master
Master is a Git thing. It is the branch of the source code which should compile into the currently released version. You only need to clone/download this if you want to compile yourself. VisualTeensy_v0_9_7_3.zip contains the binaries of this version.

The net is full of tutorials for Git and GitHub. They can explain this stuff much better than I can. Just read into it if you are interested. If not, just download the binaries, unzip and you are done.

Instead of altering your start up code, just change your Quick Start Guide.
Yep, that's at least a quick win.
 
Just released a new version of VisualTeensy which should be more robust regarding installation and first startup.

To achieve this I removed the problematic dependency on the Arduino library index. This index is updated by the Arduino IDE whenever you start the library manager. Using the new version of VisualTeensy you can download the index directly from https://downloads.arduino.cc/libraries/library_index.json. Thus, you can update this file (see picture below) whenever you like. The index currently contains about 3500 libraries and is about 13Mb large. You can of course use the fast full-text search engine below the library list to quickly find the library you need.

Here the link to the new binaries https://github.com/luni64/VisualTeensy/releases

89432468-7391c300-d741-11ea-9adf-e581305fb6f3.png
 
Back
Top