Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Using a custom usb_desc.h per-project with platformio?

  1. #1
    Junior Member
    Join Date
    Apr 2017
    Posts
    4

    Using a custom usb_desc.h per-project with platformio?

    Hi there,

    I'm working on a project where I've changed some code in the USB joystick class, which means that I've got modified versions of usb_desc.h, usb_desc.c, and usb_joystick.h in /cores/teensy3/. I switched from the Arduino IDE to PlatformIO recently, and am wondering if there's a way that I can include these three modified files in my project folder and have them override the default ones in the PlatformIO framework, so that they go along with the project. Is that possible?

    As an extension of that idea, is it possible to include an entire specific version of the Teensy package with the project? That way if I were to come back to this project in the future, I wouldn't have to worry about future updates to Teensy breaking it.

    Thanks for any tips!

  2. #2
    Senior Member blackketter's Avatar
    Join Date
    May 2015
    Location
    San Francisco
    Posts
    292

  3. #3
    Junior Member
    Join Date
    Apr 2017
    Posts
    4
    I tried that tip and it doesn't seem to work. boards_dir is actually pointing at some json files, not the cores directory, and when I do put a local copy of the cores into boards_dir it still just pulls from the global installation. The boards json files don't have any place to put a cores directory that I can tell.

  4. #4
    Senior Member blackketter's Avatar
    Join Date
    May 2015
    Location
    San Francisco
    Posts
    292
    Ah, that makes sense. I hadn't tried that myself.

    My workaround is just above that: https://forum.pjrc.com/threads/58781...l=1#post224576

    Not as clean and doesn't solve your problem as you described it, but it works.

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,118
    As an extension of that idea, is it possible to include an entire specific version of the Teensy package with the project? That way if I were to come back to this project in the future, I wouldn't have to worry about future updates to Teensy breaking it.
    Your statement above is exactly why I developed VisualTeensy a couple of years ago. I had some bad experiences with maintaining old code which was not compatible to current versions of IDEs and libraries. Of course this stuff always happens if you need to fix things under emergency conditions.

    So, if you are not bound to PIO and work under Windows you might give VisualTeensy a quick try. Nothing to install, just unzip the binaries and run it.

    Like PIO it uses vsCode as IDE. The only thing it does is setting up your project by generating a few json files which vsCode needs for intellisense and the build process. It then uses the native vsCode capabilities to build and upload. It was important to me that, after setting up your project you don't need VisualTeensy anymore. So, no long term dependency on third party code (well in my case its first party but you get the idea :-) ). Actually, since it uses standard make behind the scene you don't even need vsCode to compile. In case of emergency you can always type 'make all' in the project folder and it compiles :-)

    And, it has this nice little button which copies the core library to your project...

    Click image for larger version. 

Name:	Anmerkung 2020-08-06 220549.jpg 
Views:	6 
Size:	17.9 KB 
ID:	21292

    It also copies used libraries to the project and you can set the path to the compiler per project.

    Here the WIKI with a quick start guide https://github.com/luni64/VisualTeensy/wiki

    Remark: By default it sets up a standard c++ development environment, i.e. you need to manually include Aduino.h and forward declare your stuff. But, I think this is the same with PIO? Anyway, if you really want to use the Arduino builder you can choose to do so in the settings tab. You then get the same build behaviour as with the Arduino IDE. But, of course, you'll have another dependency which might break your code in 5 years.

Posting Permissions

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