Compiled code with VisualTeensy in VSCode successfully, how do I upload to Teensy?

Status
Not open for further replies.

Experimentalist

Well-known member
Hi, I have just successfully compiled code with VisualTeensy in VSCode, how do I upload to Teensy?

I have configured the PJRC uploader in VisualTeensy but how do I launch it?
 
. . . got it now, for anyone else having the question . . . from within VSCode use the 'Terminal' menu and select 'Run build task...' (or use CTRL-SHIFT-B) then select 'Upload (teensy.exe)' from the available tasks . . . easy when you know how (0:
 
Try using PlatformIO from within VisualCode ... it will make uploading very simple.
 
Try using PlatformIO from within VisualCode ...
Yes this is a quite impressive piece of software. Runs out of the box for nearly all modern hardware and probably fits the needs most of the users.

The reason why I did VisualTeensy non the less is, that I personally prefer projects with as little outside dependencies as possible. With VisualTeensy I can automatically generate self contained projects including the Teensy core files, the used libraries, makefile etc. I dont even need Arduino or VisualTeensy installed and can still work on, build and download old projects. If you have a product out in the wild and need to urgently change something in 5 Years the last thing I want to do is to recompile with shiny new versions of libraries, IDE's etc. which unfortunately changed their interfaces or don't support my old hardware anymore etc... But that is of course my personal paranoia only :)
 
. . . got it now, for anyone else having the question . . . from within VSCode use the 'Terminal' menu and select 'Run build task...' (or use CTRL-SHIFT-B) then select 'Upload (teensy.exe)' from the available tasks . . . easy when you know how (0:

Good thing is that vsCode remembers the last choice. I.e. you only need Ctrl+Shift+B ENTER to recompile and upload after the first time.
 
That can be done also using PlatformIO but its always wise to follow a choice you are allready accustomed to. I merely wanted to signal that PlatformIO is often overlooked whilst it can make things (especially when you work with several platforms) easy. And I dont have any link to PlatformIO, I am just a user that is very happy with what the combination PlatformIO/VisualCode brings.
 
Can you explain these settings in the make file and where it gets the paths from please?

LIBS_SHARED_BASE := <Path Removed>
LIBS_SHARED :=


LIBS_LOCAL_BASE := lib
LIBS_LOCAL :=

Presumably lib represents some kind of abbreviation for a local library folder. I am struggling to get my code to compile as it can't find the libraries and I am sure this is the key to it, am I right?
 
LIBS_SHARED_BASE should be the base folder of your shared libs. Usually ...\documents\Arduino\libraries. It reads the path from the Arduino config file.
The LIBS_LOCAL_BASE is the base folder for the libraries you copy to your project. It is <projectFolder>/lib

Usually you don't have to fiddle around with that. Can you describe what exactly doesn't work?
 
Let me have a look . . . I always find the library linking confusing :confused: I'll report back. Where is the Arduino configuration file usually?
 
LIBS_SHARED_BASE should be the base folder of your shared libs. Usually ...\documents\Arduino\libraries. It reads the path from the Arduino config file.
The LIBS_LOCAL_BASE is the base folder for the libraries you copy to your project. It is <projectFolder>/lib

Usually you don't have to fiddle around with that. Can you describe what exactly doesn't work?

This is verbatim from the makefile:

LIBS_LOCAL_BASE := lib

Should it fill in the
<projectFolder>/lib
automatically or do I need to edit it somewhere?
 
No, this is exactly what it should read.

It might be easier if you just explain what you want to do and what doesn't work. You really don't need to edit the makefile it will be generated automatically.
 
I realise I don't need to edit the makefile I just need to edit the files it reads from as I have not worked with Arduino and Teensyduino for a while and it is somewhat of a mess. I have just edited my preferences file to point to the correct location for my shared libs and am now trying VisualTeensy again but it crashes:

---------------------------


---------------------------
Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.


at vtCore.Makefile_Make.generate(IProject project, LibManager libManager, SetupData setup)


at ViewModel.ProjectTabVM..ctor(IProject project, LibManager libManager, SetupData setup) in U:\HAK\Arduino\Github\VisualTeensy\VisualTeensy\ViewModel\ProjectTab\ProjectTabVM.cs:line 292


at ViewModel.MainVM..ctor(IProject project, LibManager libManager, SetupData setup) in U:\HAK\Arduino\Github\VisualTeensy\VisualTeensy\ViewModel\MainWin\MainVM.cs:line 61


at VisualTeensy.App.OnStartup(StartupEventArgs e) in U:\HAK\Arduino\Github\VisualTeensy\VisualTeensy\App.xaml.cs:line 180
---------------------------
OK
---------------------------

... I have just loaded the source in VS and was going to have a look what is going on.
 
It is failing to build in VSCode as it can't find the Teensy libraries which are in:

C:\Arduino\1.8.9-TD-1.47\hardware\teensy\avr\libraries

Where does this path need setting so that VisualTeensy can read it in?
 
Set the Arduino Folder to C:\Arduino\1.8.9-TD-1.47 and use Quick Setup in the Project Tab

settings.png
 
Just to make sure: You did select the needed libraries in the libraries tab?
 
I am trying to build Teensy_Prop_Shield.ino from:

https://github.com/kriswiner/Teensy_Prop_Shield

I copied and pasted it in and added:

#include "Arduino.h"


The first line of it failing is:

src/main.cpp: In function 'void setup()':
src/main.cpp:377:3: error: 'Wire' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_RATE_400);

I have these libraries referenced in VisualTeensy:

Libraries.png
Still not sue where I am going wrong at the minute
 
Wow, I do not comment on other people's coding style, so, let's put it that way: this is a very interesting way to structure a program.

The problem for VisualTeensy is that this 1700 + 200 line *.ino files heavily rely on the Arduino IDE to combine the mutually dependent source files and correctly forward declare all of those "hundreds" of functions. I tried to convert this into a standard c++ code by untangling and forward declaring the functions and variables manually but after an hour or so I gave up.

Anyway, VisualTeensy can alternatively use the native ArduinoBuilder which is able to handle this. Just select it in the settings tab:

arduinobuilder.png

It then compiles without an error (but a lot of warnings...)


@CorBee: Does PlatformIO use the ArduinoBuilder or do they build with a makefile?
 
Thanks for your efforts, that's not my repo just one that was recommended to me by a forum member to see some of the Teensy Prop Shield functions. Got it working now using the Arduino build tool, thanks (0:
 
That can be done also using PlatformIO but its always wise to follow a choice you are allready accustomed to. I merely wanted to signal that PlatformIO is often overlooked whilst it can make things (especially when you work with several platforms) easy. And I dont have any link to PlatformIO, I am just a user that is very happy with what the combination PlatformIO/VisualCode brings.

I just downloaded Platform IO and am going to have a look at that also, thanks for the tip (0:
 
Status
Not open for further replies.
Back
Top