Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 27

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

  1. #1
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274

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

    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?

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    . . . 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:

  3. #3
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    258
    Try using PlatformIO from within VisualCode ... it will make uploading very simple.

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    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

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    . . . 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.

  6. #6
    Senior Member CorBee's Avatar
    Join Date
    Jun 2018
    Location
    Netherlands
    Posts
    258
    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.

  7. #7
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    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?

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    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?

  9. #9
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Let me have a look . . . I always find the library linking confusing I'll report back. Where is the Arduino configuration file usually?

  10. #10
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    ....\AppData\Local\Arduino15\preferences.txt

  11. #11
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Quote Originally Posted by luni View Post
    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
    Quote Originally Posted by luni View Post
    <projectFolder>/lib
    automatically or do I need to edit it somewhere?

  12. #12
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    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.

  13. #13
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    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\Vi ewModel\ProjectTab\ProjectTabVM.cs:line 292


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


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

    ... I have just loaded the source in VS and was going to have a look what is going on.

  14. #14
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Fixed that, I set it to the wrong folder by mistake . . . hang on

  15. #15
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    . . . also trying to cook dinner . . . hence the mistakes

  16. #16
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    Sounds familiar :-)

  17. #17
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    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?

  18. #18
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    Set the Arduino Folder to C:\Arduino\1.8.9-TD-1.47 and use Quick Setup in the Project Tab

    Click image for larger version. 

Name:	settings.png 
Views:	7 
Size:	57.0 KB 
ID:	17472

  19. #19
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    Just to make sure: You did select the needed libraries in the libraries tab?

  20. #20
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    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:

    Click image for larger version. 

Name:	Libraries.png 
Views:	3 
Size:	17.7 KB 
ID:	17473
    Still not sue where I am going wrong at the minute

  21. #21
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Got to go out . . back later

  22. #22
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    I'll give it a try, hang on

  23. #23
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    534
    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:

    Click image for larger version. 

Name:	arduinobuilder.png 
Views:	3 
Size:	60.7 KB 
ID:	17474

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


    @CorBee: Does PlatformIO use the ArduinoBuilder or do they build with a makefile?

  24. #24
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    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:

  25. #25
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    274
    Quote Originally Posted by CorBee View Post
    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:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •