Go Down

Topic: How to get complete code from arduino ide (Read 655 times) previous topic - next topic

parag81

Hey there,

I'm new to Arduino Ide and  for the forum so dont know the place is correct for this question? Help me out if not.
I have tried some of the example where all the syntax is new to me im wondering if i can fetch the complete C code from the ide?
Complete means everything lke main all the functions.

I'm using MPLAB IDE from the Microchip from about 6 years so in there u have to do everything from scratch now that idea is fitted on my mind.

The reason to get full code is i want to learn in deep from taking some pre-written  example.


pert

The standard Arduino API is in the Arduino core library files. Note that the location of the active core library can change depending on which board you have selected from the Tools > Board menu.

The easiest way to find the core library location is as follows:
  • Select a board from the hardware package from the Tools > Board menu
  • File > Examples > SPI > BarometricPressureSensor
  • Sketch > Show Sketch Folder
  • Move up folder levels until you reach the one that contains boards.txt
  • The core library will be under the cores subfolder


You can find the paths to the various library folders by doing this:
  • File > Preferences > Show verbose output during: > compilation (check) > OK
  • Sketch > Verify/compile


After the compilation finishes scroll the black console window at the bottom of the Arduino IDE window up. You will see all the commands the Arduino IDE generated for the compilation process, which will include the paths.

You can also use the example sketch folder trick to easily find the location of any library that has an example sketch. As with the core, the active version of the library may depend on the board selection. You might have multiple versions of a library installed so it's important to make sure you're looking at the one that's actually being compiled for your board.

pert

You should know that it's possible to write as low-level "from scratch" code as you like in the Arduino IDE. The Arduino platform does like to offer a more high-level, beginner friendly option but it's not absolutely forced on you.

For example, the IDE will automatically generate function prototypes in .ino files for you but if you don't want that you can either just add the prototypes yourself or put your code in files with other supported extensions (.cpp, .h, .c, .S, etc.), which the Arduino IDE doesn't do any special preprocessing on.

parag81

Thanks pert you just made my day :)

Quote
You can find the paths to the various library folders by doing this:

   1. File > Preferences > Show verbose output during: > compilation (check) > OK
    2.Sketch > Verify/compile
But finding a variable in this ide i think not an easy task
for example
 i tried example>basic>blink

in that they used LED_BULTIN
i know its define somewhere as 13 pin as i using arduino uno

but im not able to find it where..

bit in MPLAB X you can easily by preesing ctrl button and click on that.

I know there is always some good and flaw in ide and due to that we are getting updates..

but i think that ctrl thing should work in this ide too..

pert

I agree that it would be a very useful feature to be able to view the external source files. Arduino users tend to treat libraries and the hardware package files as black boxes but if they were easier to access then they could easily take a peek under the hood and find it's just more code similar to what they're already writing in their sketches. I've learned a lot from digging into the source code. I believe that if someone were to submit a pull request to the Arduino IDE adding this feature without harming the user experience (maybe a right click menu item would be better) the Arduino developers would welcome it. I just don't think it's their top priority to implement the feature themselves since the average Arduino user is not clamoring for it.

LED_BUILTIN is defined in the variants/{variant name}/pins_arduino.h under the active hardware package folder I showed you how to find in my last reply. {variant name} is defined by the build.variant property of the currently selected board in boards.txt. You'll note there is also a build.core property defined there, which determines the subfolder of the cores folder that is used for the selected board. I didn't mention that before because most hardware packages only use a single core library but the Arduino IDE does provide the ability for multiple core libraries if a package author needs it.

westfw

#5
Apr 14, 2018, 12:49 pm Last Edit: Apr 14, 2018, 12:49 pm by westfw
You can also browse the source on github.  It doesnt have the "advanced ide" features like "go to definition", but it does have search.

Go Up