Is it possible to add "example" sketches to a third party board package?

If so, where do they go?

Or can you only provide examples for libraries included with a third party board package?

DrAzzy: If so, where do they go?

Or can you only provide examples for libraries included with a third party board package?

Have you ever seen the code here on the forum include a copyright statement? I really don't understand why you are asking.

Paul

Paul_KD7HB: Have you ever seen the code here on the forum include a copyright statement? I really don't understand why you are asking.

Paul

I am asking because I maintain ATTinyCore, a third party hardware package.

I would like to include an "example" sketch that demonstrates reading the internal temperature sensor. However this is specific to the core (I added a #define to make it easier to do this), but not to any specific library - and have that example appear in the File -> Examples menu under the "Examples for (board name)" section. I know how to provide examples for libraries, but not for the core in general. (Why this specific issue? It recently spawned a surprisingly long issue on github, culminating in a working sample sketch in the issue - but I'd like that example to be easy for the next guy to find)

I have no idea what gave you the idea that my post has anything to do with copyright statements.

If the program listing is not copyrighted, then you are certainly not limited in how you use it. Ask your local attorney if still concerned.

What is the worst that can happen???

Paul

I am not asking if it is LEGAL to do so. It is code I wrote for the express purpose of this example, being included for free use in the core that I maintain. There is absolutely no legal/copyright issue at all here - I do not know where you got the idea that I was asking about copyright stuff.

I am asking if it is TECHNICALLY POSSIBLE to do so, and if so, where I put the files in the core to make them show up. All I can figure out how to do is add examples for libraries included with the core (with the examples folder inside the library folder). And I can't find any other core examples that include non-library-associated examples. Do I need to create a dummy library just to put the examples in?

DrAzzy: I am not asking if it is LEGAL to do so. It is code I wrote for the express purpose of this example, being included for free use in the core that I maintain. There is absolutely no legal/copyright issue at all here - I do not know where you got the idea that I was asking about copyright stuff.

I am asking if it is TECHNICALLY POSSIBLE to do so, and if so, where I put the files in the core to make them show up. All I can figure out how to do is add examples for libraries included with the core (with the examples folder inside the library folder). And I can't find any other core examples that include non-library-associated examples. Do I need to create a dummy library just to put the examples in?

Ah, now I understand!

Paul

Well, the Adafruit Metro M4 has libraries that are associated with it, so it MUST be possible…

Hmm. Got it working… Basically you set up a library that doesn’t actually contain any code. (The actual link of the library code into an example is based on the “#include” that gets put in the source. If your example doesn’t reference any include files from the libraries, then it won’t add anything from the library path to the compilation.)

However, there DOES need to be a src/library.h file for the IDE to consider it a “valid” library worth searching for examples. (It can be an empty file.)

And you have to have a board from that platform selected before the examples will appear in the menu.

Starting up the IDE in debug mode (ie from a CLI window) will show you what complaints it might have about the library directory structure.)

WWHackintosh<10080> pwd

/Applications/Arduino-1.8.5.app/Contents/Java/portable/packages/Optiboot/hardware/avr/0.7.0

WWHackintosh<10080> ls
README.TXT      boards.txt      bootloaders/    libraries/      platform.txt

WWHackintosh<10080> ls -R libraries/
Optiboot/

libraries//Optiboot:
examples/              library.properties        src/

libraries//Optiboot/examples:
chaucer112k/    chaucer256k/    chaucer64k/    test_dospm/    test_reset/
chaucer16k/    chaucer32k/    eeprom_data.c  test_eeprom/

libraries//Optiboot/examples/chaucer112k:
chaucer112k.ino

libraries//Optiboot/examples/chaucer16k:
chaucer16k.ino

:

libraries//Optiboot/examples/test_eeprom:
test_eeprom.ino

libraries//Optiboot/examples/test_reset:
test_reset.ino

libraries//Optiboot/src:
optiboot.h

Screen Shot 2018-10-08 at 4.31.59 PM.png

There is a feature request for this: https://github.com/arduino/Arduino/issues/3297 The dummy library approach described by westfw works well enough though, and is used by quite a few 3rd party hardware packages.

I like to leave an explanatory comment in the dummy library's empty .h file to prevent confusion.

Thanks :-)