Products > Programming

Arduino: variant.cpp JSON etc. HELP

(1/2) > >>

Jester:
Hi,

Context:

* I'm an engineer not a programmer
* I'm okay with C language programming, less so with C++
* I have developed a few custom boards using a Cortex SAMD21G, so similar to Arduino MKR ZERO with more pins in use
* Wrote some Arduino code for the boards and it works great
* To accomplish above I tweaked the original MKR ZERO variant files to use the extra pins and reassign some pins to other uses
The problem
As I switch from one project to the other I need to manage the various versions of variant.cpp and variant.h.
My understanding is that the proper way to this is to create a custom Arduino board using a JSON file, that's where things get fuzzy.

I did find this tutorial:  https://www.instructables.com/Arduino-IDE-Creating-Custom-Boards/
I'm at step 8

My questions


* Assuming I can figure out how to create a JSON file, is it necessary to post this with a URL? Can I not do this locally on my hard drive at least until I know that it works?
* It's not clear to me if the JSON file is simply a zipped text file with the 70 or so lines in the example or more than that?
* Am I better off just managing the various variant files, or is it worth completing the last couple of steps to actually create an Arduino custom board?
Thanks in advance
[/list]

westfw:

--- Quote ---Assuming I can figure out how to create a JSON file, is it necessary to post this with a URL? Can I not do this locally on my hard drive at least until I know that it works?
--- End quote ---
It's easy enough to put on github or other site.


--- Quote ---It's not clear to me if the JSON file is simply a zipped text file with the 70 or so lines in the example or more than that?
--- End quote ---
The json file isn't even zipped.  Just plain text.  JSON is one of those "languages" for encoding a data structure as plain text.The file that the json points to is generally a zipped file containing the appropriate directory structure for the custom board.You might want to look at https://github.com/Optiboot/optiboot/blob/master/optiboot/release.sh which is a script I use to prepare the .json file and "release zip" for optiboot (it's been a while since I've used it; optiboot is now better served via one of the board packages that use it (MCUDude or SpenceKonde's))


--- Quote ---Am I better off just managing the various variant files, or is it worth completing the last couple of steps to actually create an Arduino custom board?
--- End quote ---
I dunno.  The Arduino board manager is pretty neat, but I think you can still add hardware just by putting files in the (legacy) ~/sketchbook/hardware directory as well.  (Possibly in some not-quite-legacy directory structure.)

Jester:
It's working.

BTW:  I was able to test locally by adding file://C:/Users/*****/Documents/Arduino/package_myBoard_index.json to Additional Boards Manager URLs: in File|preferences

Thanks for your help.

westfw:

--- Quote ---I was able to test locally by adding file://C:/Users/*****/Documents/Arduino/package_myBoard_index.json
--- End quote ---
I was wondering if that would work!Where did you end up putting the .zip files for the board itself with a local .json ?

Jester:
I think you can put the zip file as well as the JSON file anywhere, because the JSON file tells the IDE where to look for the zip file. The board manager then makes a copy of the required core files from your zip file and places them in a slightly different location than the other installed libraries. I can’t recall the exact folder now, but obviously you need to know if you want to tweak your custom variants as your project evolves.

I’m now wondering if their is a way to specify in your c code (sketch < not sure why I dislike that term) to use a particular “Board”, for that code ,  because whenever I switch to another project I also have to select the appropriate “Board”

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod