This introduction is copied from: http://eclipse.baeyens.it/learn.shtml
The arduino IDE put the focus on "a low entry level". Honestly with decades of experience in software development I can tell you -hand on heart- that the Arduino IDE is very good designed ... for it's purpose.
But when you start growing and "the low entry level" is no longer your first concern. You start to want a "rich tool", not a "this way it will work always work tool". So a tool that allows you to control more things, and as such does not stop you from breaking things.
As it is nearly impossible to combine a "rich tool" with a "low entry level tool" many "requests for improvements" are rejected by the arduino core team as it may infringe the "low entry level" target.
So when you have a need that goes above "low entry level" you are out of the focus of the arduino IDE development team and you need to start banging another door/tool.
At that point in time, one of the doors/options is the arduino eclipse plugin. One of the strong points of the Arduino eclipse plugin compared to the other available tools is that it is multi platform. It has active users using Windows, Mac and linux.
The arduino eclipse plugin is easy to set-up (though harder than the Arduino IDE) and easy to use. It has the same icons for verifying upload and serial monitor as the arduino IDE. And to name the biggest plus: It supports you to serve your multiple projects with different configurations (of each project). And it supports you from writing your code up to hopping into code of included libraries – seamless.
Most people have uploaded their first sketch in Slouber in less than 30 minutes - there are some people who never succeeded in running the tool – with this introduction we firmly believe that you belong to the first group. Good luck and have fun with this impressive extension!
- Table of contents
- Installation
- First Project Blink on Arduino UNO
- Discovering the Arduino cores
- Manage Debug and Release version in one project (Multiple configurations)
- Two different sources in the same project
- Change platform to ESP32
- Useful Settings
- Advanced features
- Working sets
- Tips and Tricks
- Errors and Problems
- Software updates
In windows environment, choose an install path with a short name e.g. C:\Sloeber. Otherwise, while installation, some path names will be longer than accepted under Windows.
Create empty directory as workspace C:\sloeber-workspace
Start sloeber-ide.exe, select the new workspace and check "Use this…"
Since you do not have secure data, you may allow for public sites.
Close the welcome tab.
Wait while sloeber is loading the current core and libraries
This is the Eclipse window with the Sloeber extensions as well as two extra buttons you will add in a few seconds!
Here we choose a sample sketch as start for our project.
This is the Sloeber/Eclipse window for the Source file Blink.uno.
On the right, you see the Outline window, with all variables and functions listed for quick access.
In the middle, there are the edit windows.
Left is the Project Explorer with the tree view of your projects and files.
On the Bottom, there are some Views like the Console and Serial monitor view.
We think that the presence of the file “sloeber.ini.cpp” is a crutch. How to get rid of it? Just rename “Blink.ino” into “Blink.cpp” and the sloeber.ini.cpp file will vanish.
Note: If you do so, you must add the line #include <Arduino.h> in your source.
Open **Window > Preferences
**
Search for line and check Insert spaces for tabs and Show line numbers
Open Project properties with Alt + Enter
Check **use alternative size command? (AVR only)
Do not check it for any non AVR platform!
**
To be sure, that your upload includes all your recent changes, you should enable Save automatically before manual build option in Window > Preferences > General > Workspace > Build.
You must set the Com Port in the Arduino properties of your project to the port number of your Arduino board, which is displayed in the Windows Device Manager. You most likely have to attach the Board, before selecting the port, because only Com-Ports currently attached can be selected.
The Blink_test.hex file is the file used by uploading with avrdude.exe
You can remove the Release folder and other build folders anytime. Sloeber will restore them at the next build.
If you place the cursor over an Arduino (or library) function, it shows you the sourcecode.
If you press F3, the function definition will open in a new editor window. If you activate the Link with Editor button, the Project Explorer window shows you all core files.
You can even modify the core sources, but be careful!
Each project has individual settings, like Board/CPU (type/clock), libraries, clock speed, Com Port, or Sources used for compile.
To have 2 different settings, you can of course create 2 projects, but then you have to take care to keep the sources synchronized .
With configurations, you can have different sets of settings for one source. Each configuration is available at one mouse click.
First, we extend the menu to have two useful buttons available for configuration management.
Check Build Configuration on the Action Set Availability tab to enable the Active Build Configuration and Build Active Configuration buttons.
Save the changes to the current perspective in order to have it persistent even after a reset perspective. We simply overwrite the existent Arduino perspective.
The index for active build configuration should be enabled. This allows for more advanced usage of configuration, like binding different libraries etc.
Open this with Window > Preferences.
You can open the Manage Configuration
window also by Project > Build Configuration > Manage.
We can now change easily to the Debug configuration
Now we change the Debug configuration to have the DEBUG macro defined. This is equivalent to including the line #define DEBUG in your code. To have it specified in our configuration allows fast switching between using or not using the define without changing the code.
Switching back to the Release configuration shows that the DEBUG guarded statements are inactive now.
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
// Just to know which program is running on my Arduino
#ifdef DEBUG
Serial.println(F("START " __FILE__ " from " __DATE__));
#endif
}
// the loop function runs over and over again forever
void loop() {
#ifdef DEBUG
Serial.println("Activate LED");
#endif
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
#ifdef DEBUG
Serial.println("Deactivate LED");
#endif
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Next, we add an additional source file with an extended version of our blink example.
Without a new configuration, we get the multiple definition of `setup' Error on compile.
And yet another for the Debug variant for the new source.
Here we just copy the settings from the existent Debug configuration, so the –DDEBUG is already set on creation
.
In Eclipse, all project sources (and libraries) are assigned to all configurations by default.
For each source, you must therefore specify all the configurations where this source should be excluded. Here we exclude the old file Blink.cpp from the new configurations.
The "same" must be done for the new source file.
This can be done in two ways.
Add https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Open Arduino > Preferences again and choose the desired version in Platform and Boards. You can choose multiple versions, which can be used for different configurations or projects.
Here you find the unofficial list of all known core / board URL's
https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls
A few more common URL's:
-
http://arduino.esp8266.com/stable/package_esp8266com_index.json
-
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
-
https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
-
http://dan.drown.org/stm32duino/package_STM32duino_index.json
-
https://raw.githubusercontent.com/ArminJo/DigistumpArduino/master/package_digistump_index.json
-
http://raw.githubusercontent.com/MHEtLive/arduino-boards-index/master/package_mhetlive_index.json
-
https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json
-
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
-
https://raw.githubusercontent.com/xukangmin/TinyCore/master/avr/package/package_tinycore_index.json
-
https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json
One drawback of Sloeber is, that the default settings are not filled in. But they can easily be determined, if you select the same board in the Arduino IDE.
The standard auto format settings are the Kernighan & Ritchie style with a maximum line length of 80 characters. If you feel that this is too short for your HD Monitor (like I do), set maximum line length to e.g. 132.
Open **Window > Preferences
**
Navigate to the C++ Formatter, click on New…. and give it a sensible name.
Then change Maximum line width on the Line Wrapping tab to 132.
By default, the file history is limited to 7 days.
I personally prefer an unlimited history, it does not take too much space on your disk (2.6 GB for 136 projects and 5 years).
The local history (stored on your computer) can be accessed by selecting a file and them Team > Show Local History
This is an example history.
This opens a Windows explorer window located at the file currently selected in the edit window. It is very handy if you want to modify or copy the file outside of Sloeber.
You can also create a launch configuration for external tool, to have this function available at one click.
Add the path C:\Windows\explorer.exe and add Arguments "/select,${resource_loc}"**
**
On the Build tab, uncheck the Build before launch checkbox
On the Common tab, check External Tools
- Search definition of a variable/function with
F3
- Search Usage of variable/function with
Ctrl + Shift + G
- Rename variable/function/macro at all occurrences with
Alt + Shift + R
- Format source with
Ctrl + Shift + F
- Comment/Outcomment with
Ctrl + Shift + /
- Search (and replace) in Project or complete Workspace with
Search \> File …
Here the completion for "Seria".
It handles also available functions of an object if pressed after the dot.
Type "sw", press Ctrl + Space and select switch case statement. A complete switch template will be generated for you.
Type "for", press Ctrl + Space and you get:
This results in:
for (int var = 0; var < max; ++var) {
}
In the History view you can not only display historical file contents, but also compare them with current content.
If you select two dates / lines in the history view, you can compare them with each other.
Open Project > Properties > C/C++ Build > Settings > Build Steps and add "avr-objdump -h -S ${BuildArtifactFileBaseName}.elf > ${BuildArtifactFileBaseName}.lss" in the field Post-build steps > Command
The assembler output is located in Blink/Blink_test.lss and looks like:
If you activate the "Link with Editor" button. The tree view will position at the file in the Editor window (which is not always desirable).
You can specify the location where your manually managed libraries are located.
First, select the lines of code you want to have as a function, then use Refactor > Extract Function and specify name of the function as well as other parameters. The function will then be created and inserted before the current function.
If you create a project from an Arduino example or download Arduino examples, you always have an *.ino file as main program.
If you just rename your *.ino file to *.cpp, you will get compiler errors. You must first include the lines
#include "Arduino.h"
void setup() ;
void loop() ;
void calibrate() ;
from the file sloeber.ino.cpp into the *.ino file before any #defines or declarations. After renaming your file, the file file sloeber.ino.cpp will be deleted (and if you rename it back, it is created again ).
If after a while you have many projects in your workspace, you can group them with working sets.
Here I grouped all projects with the same core into a working set and used the project configuration for the different source files/examples
You can detach every window by just dragging it elsewhere.
Dragging back can be done by simply clicking on the tab (not on the title of the detached tab window). Then you will see mouse cursor change showing you where you can drop it to attach the tab back to Eclipse. Alternatively, you can close the window and use Window > Perspective > Reset Perspective.
By double clicking on the tab of every window, this window changes to full screen / full window. The next double click reverts this change.
Before you chase a strange error, it is always recommended to try Sloeber > Reattach Libraries, right mouse button > Clean Project and Index > Rebuild and to close and open the project or even restart Sloeber. Also look to the list of libraries with Sloeber > Add a library to the selected project and check, if it corresponds to your requirements.
Reset window arrangement with Window > Perspective > Reset Perspective.
Do NEVER check the box Also discard perspective's customization.
If you get errors like
make: \*\*\* \[libraries\FreeRTOS\src\croutine.c.o\] Error 1
then check libraries, sometimes there are more libraries than required. In this case, Sloeber thinks you might need the FreeRTOS library for the project.
Simply delete it in the Project Explorer or exclude it from your configuration.
This happens sometimes after changing configuration.
Run Index > Rebuild or Index > Freshen All Files and the strange behavior will vanish.
If you get errors like
ESP8266/core/build.opt: No such file or directory
then just removing the line build.opt.flags="@{build.opt.fqfn}"
in the files platform.txt and platform.sloeber.txt and restarting Sloeber will fix it.
"Build options" can be specified in the Compile Options tab in the Sloeber project settings.
The files can be found at e.g. Sloeber\arduinoPlugin\packages\esp8266\hardware\esp8266\3.1.1.
Keyboard layout can be (accidentally) changed by Alt + Shift to English and back.
You accidentally selected AVR_ALTERNATIVE
for use alternative size command?
Do not select it for any non AVR platform!
Check for updates with Help > Check for Updates
You see a list of available updates
Then you will be asked to accept the terms of the license agreements
And because the package is of course not signed, you must choose Install anyway
At last restart Sloeber