arduino / Arduino

Arduino IDE 1.x
https://www.arduino.cc/en/software
Other
14.08k stars 7.01k forks source link

[Boards Manager] Include core examples to Examples menu #3297

Open mikaelpatel opened 9 years ago

mikaelpatel commented 9 years ago

Examples in core libraries are automatically added to the Examples menu. Unfortunately core examples are not.

Would like to suggest a sub-menu with the core example sketches and libraries instead of a single level. Could be named after the core.

E.g. File>Examples>CORE>Examples>.... the examples directory File>Examples>CORE>Libraries>... the examples in the libraries directory

where CORE could be, for instance, Cosa.

Cheers!

ffissore commented 9 years ago

@mikaelpatel what's a core example? the IDE looks for examples only in libraries folders and in its built-in "examples" folder

mikaelpatel commented 9 years ago

@ffissore Sorry about the somewhat short description. The "issue" occurs when using the new Boards Manager and installing a package/core with it (in my case Cosa). When previously installing to the Sketchbook/hardware/avr folder the Cosa/examples folder was available in the Sketchbook sub-menu. With the Boards Manager only the examples in the libraries folder are available. It would be great to allow a built-in examples folder per core (same level as libraries) i.e. per package.

per1234 commented 7 years ago

This turns out to be a fairly common need for hardware packages. Some examples:

As you see, we found the workaround of using a dummy library for these, which does work.

jpliew commented 5 years ago

@per1234 , The workaround works with 2 confusions

  1. If the package has more than 1 board, the board name for the selected board from Tools ->Board will show up on the title of the example. Take this SparkFun workaround

image

The board selected was SerLCD but the examples was written for LilyPadProtoSnapPlus. Still the examples shows up on File->Examples menu.

  1. When user select Sketch->Include Library, the LilyPadProtoSnapPlus showed up as an includable library

image

but it is not a library, therefore causing user confusion.

Cheers JP

per1234 commented 5 years ago

If the package has more than 1 board, the board name for the selected board from Tools ->Board will show up on the title of the example.

Wrong. The name of the library will show up in the File > Examples menu. SparkFun just happens to have given their libraries the same names as boards: https://github.com/sparkfun/Arduino_Boards/tree/master/sparkfun/avr/libraries

The board selected was SerLCD but the examples was written for LilyPadProtoSnapPlus. Still the examples shows up on File->Examples menu.

True. The Arduino IDE displays examples for all bundled libraries of the hardware package, regardless of which board of that package is selected. This is the very reason why SparkFun named the dummy libraries that way. I would have put all the examples under one dummy library:

libraries
|_SparkFun_Examples
   |_SparkFun_Examples.h
   |_examples
      |_LilyPadProtoSnapPlus
      |  |_LPP_01_Blink
      |  |  |_LPP_01_Blink.ino
      |  |_LPP_02_BasicColorMixing
      |  |  |_LPP_02_BasicColorMixing.ino
      |  |_etc...
      |_Qduino
         |_batteryLeveltoRGB
         |  |_batteryLeveltoRGB.ino
         |_fuelGauge
         |  |_fuelGauge.ino
         |_etc...      

I'm not convinced that board-specific examples are a common enough need that it's worth the work and maintenance burden to add that feature to the Arduino IDE but that's for someone else to decide. It seems like any confusion could be worked around with a bit of documentation, which SparkFun has done.

When user select Sketch->Include Library, the LilyPadProtoSnapPlus showed up as an includable library ... but it is not a library, therefore causing user confusion.

Well it technically is a library, just an empty one, so this is the correct behavior. The dummy library is simply a workaround. It's undeniably a bit of a hack. This is the first time I've heard of anyone being confused by the dummy library and I think a lot of the blame in this case lies with SparkFun's vague library names.

My intention with my previous comment was more to point out that the requested feature is not a corner case. I think it would be great if Arduino added true support for example sketches bundled with hardware packages. Even after they do so, the problem of support for people using previous IDE versions will remain for some time so a slightly hacky workaround that works with all IDE versions remains valuable.

jpliew commented 5 years ago

@per1234 ,

I am sorry if I was not clear with my comment. Causing you to be confused by saying wrong.

If the package has more than 1 board, the board name for the selected board from Tools ->Board will show up on the title of the example. Take this SparkFun workaround.

The board selected was SerLCD but the examples was written for LilyPadProtoSnapPlus. Still the examples shows up on File->Examples menu.

These two paragraphs were meant to be read as one explanation. When I said

the board name for the selected board from Tools ->Board will show up on the title of the example.

I was referring to

Example for SparkFun SerLCD

Anyway, if you have not heard of anyone get confused, doesn't mean that no one is confused. The world is so big. Arduino is the most used product at school, anyway we can do to minimized confusion should be WELCOME.

Board specific examples is definitely something useful, it may not be for you, but does not mean others will not be beneficial.

Good luck.

jpliew commented 5 years ago

@per1234

I would have put all the examples under one dummy library:

libraries
|_SparkFun_Examples
   |_SparkFun_Examples.h
   |_examples
      |_LilyPadProtoSnapPlus
      |  |_LPP_01_Blink
      |  |  |_LPP_01_Blink.ino
      |  |_LPP_02_BasicColorMixing
      |  |  |_LPP_02_BasicColorMixing.ino
      |  |_etc...
      |_Qduino
         |_batteryLeveltoRGB
         |  |_batteryLeveltoRGB.ino
         |_fuelGauge
         |  |_fuelGauge.ino
         |_etc...      

Even if someone does the above suggestion, the title of the example will still be called

Examples for xxxxx

where xxxxx is the selected board. So this suggestion is technically still confusing.