Exclude Arduino library from compilation - arduino

I've created an Arduino project using the "Adafruit_SSD1306" display library, which works as expected using a Uno board.
A subsequent project needed to use the ESP8266 wifi board, which required a new display library "ESP_SSD1306". I can see from the source this library is derived from the "Adafruit_SSD1306". Everything compiles and works as expected.
However, if I go back and try to rebuild my old project, or any old project, sample etc that references "Adafruit_SSD1306", it will not build, unless I remove the "ESP_SSD1306" library from my "libraries" folder.
The error is:
sketch_aug04b_xxxxxxx.ino:24:30: fatal error: Adafruit_SSD1306.h: No such file or directory
compilation terminated.
Error compiling.
The workaround is to add or remove this library from the libraries folder whenever I switch to non-ESP8266 project and manually add it back when I switch to an ESP8266-based project.
I'm guessing the libraries conflict in some way, but I am hoping there is a better user experience for dealing with this. Some #define or project setting I can use to remove a library from the compilation path (other then the current process, which involves manually removing the library).

Looks like I've found the answer.
Both libraries have the identical name in their library.properties file. This appears to be what is causing the conflict.
The solution was to change the name property of the ESP_SSD1306 library from "Adafruit SSD1306" to "ESP SSD1306":
name=ESP SSD1306
version=1.0.0
author=Adafruit
maintainer=Adafruit
sentence=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs!
paragraph=SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs!
category=Display
url=https://github.com/adafruit/Adafruit_SSD1306
architectures=*

Related

How to add Arduino library to CLion PlatformIO project

I worked through the steps at https://www.jetbrains.com/help/clion/platformio.html to get PlatformIO installed and working with CLion. The following program now works:
void setup() {
Serial.begin(9600);
Serial.println("yay, I'm working.");
}
void loop() {
}
Now... I need to get an ESP32-compatible SSD1306 library installed (among others), so I can actually do something useful.
As far as I can tell, CLion (with or without the PlatformIO plugin) has nothing like the library browser in the Arduino IDE. Is there a less barbaric way of getting Arduino libraries into a CLion-PlatformIO project than grabbing the library's repo from Github and hand-copying files (and their recursive dependencies)?
Are PlatformIO projects created via CLion round-trip compatible with VSCode+PlatformIO? Like, can I create the PlatformIO project in CLion, exit CLion, launch VSCode, open the same project, use VSCode to add the libraries, exit VSCode, then go back into CLion and use them? Or is that a recipe for pain, tears, and corrupt config files?
Opening a CLion+PlatformIO project in Visual Studio Code works fine especially when you just want to add Libraries.
As far as am concerned PlatformIO works best with Visual Studio Code.
As far as I can tell, CLion (with or without the PlatformIO plugin) has nothing like the library browser in the Arduino IDE. Is there a less barbaric way of getting Arduino libraries into a CLion-PlatformIO project than grabbing the library's repo from Github and hand-copying files (and their recursive dependencies)?
Using PlatformIO, you just need to add the library name into platformio.ini file. PlatformIO provides PlatformIO Home to help you with searching and adding library into platformio.ini file. Run pio home in the your terminal. If your setup is correct you will be able to run the command and access the web app.
For your reference:
Home page
Library Browser
Adding library to your project
platformio.ini
Are PlatformIO projects created via CLion round-trip compatible with VSCode+PlatformIO? Like, can I create the PlatformIO project in CLion, exit CLion, launch VSCode, open the same project, use VSCode to add the libraries, exit VSCode, then go back into CLion and use them? Or is that a recipe for pain, tears, and corrupt config files?
Yes. You can open it from both IDE. You can view more in their docs

Uno-Platform: How to add a Library

Uno Platform...
In VS2019 (out of the box tests):
added uno templates: all good
create project.....: all good
run WASM project...: all good
run UWP project....: all good
added a Uno Library: various issues (see list below)
Uno Library (in UWP and WASM) issues:
complaint about a android 10 library... I remove it and compile OK
after adding this library to the UWP project found multiple netstandard2 compilation code;
I am using the uno project template as is... but can't even add a Uno-Library without adding any code, just what ever is generated by the wizard.
Question:
I will like to prepare a library and add it to any target... any advise?
Ed.
It appears (so far) to be a successful workaround:
Temporarily move the uap10.0.xxx target framework to be at least second in the TargetFrameworks list. (See this for more details: https://github.com/unoplatform/uno/issues/3909)

how to use selected arduino libraries?

I would like to know if it is possible to use selective arduino libraries in our AVR projects. For Example: I am using Atmega328 and Atmel studio. I would like to use DS1307 related library file(twi.c and Wire.c source files I guess) in my project. Can we use individual libraries and then include applicable header files in our build? If so where are these libraries located and what is the extension? I saw few articles on building entire arduino project in Atmel studio and I am not interested in that. I want to manage without installing arduino if possible (I can install arduino only to get library if needed). I thought of including source files, but they are in C++ and I started getting error messages when included in C project. Is it possible to do without modifying the source files much?
After searching, i found that
Any 5V microcontroller with I2C built-in can easily use the DS1307.
check also first lines here.
I look quickly at DS1307.c and found it is not using any functions from wire.c
But instead of all that you could get source code for DS1307.c and implement any function begin with i2c by yourself and small modifications for interrupt functions. and you can use it in your code. i downloaded the library from this link.
There are a lot of twi/i2c libraries for avr, you could download most suitable one and rename it's function like the function called from DS1307.c

How do I remove a library from the arduino environment?

In the Arduino GUI on windows, if I click on Sketch --> Import Library, at the bottom of the menu there is a section called "Contributed".
Unfortunately, I had misclicked and added a library I did not want to that list.
How can I remove it from that list?
The help page only mentions that "If a sketch no longer needs a library, simply delete its #include statements from the top of your code" but it does not mention how to remove the library from the list of contributed libraries.
Go to your Arduino documents directory; inside you will find a directory named "Libraries". The imported library directory will be there. Just delete it and restart the Arduino app.
Your Arduino library folder should look like this (on Windows):
My Documents\Arduino\libraries\ArduinoParty\ArduinoParty.cpp
My Documents\Arduino\libraries\ArduinoParty\ArduinoParty.h
My Documents\Arduino\libraries\ArduinoParty\examples
....
or like this (on Mac and Linux):
Documents/Arduino/libraries/ArduinoParty/ArduinoParty.cpp
Documents/Arduino/libraries/ArduinoParty/ArduinoParty.h
Documents/Arduino/libraries/ArduinoParty/examples
The only issue with unused libraries is the trivial amount of disk space they use. They aren't loaded automatically so don't take up any application memory of the Arduino IDE.
Quote from official documentation as of August 2013:
User-created libraries as of version 0017 go in a subdirectory of your default sketch directory. For example, on OSX, the new directory would be ~/Documents/Arduino/libraries/. On Windows, it would be My Documents\Arduino\libraries\. To add your own library, create a new directory in the libraries directory with the name of your library. The folder should contain a C or C++ file with your code and a header file with your function and variable declarations. It will then appear in the Sketch | Import Library menu in the Arduino IDE.
To remove a library, stop the Arduino IDE and remove the library directory from the aforementioned location.
The answer is only valid if you have not changed the "Sketchbook Location" field in Preferences. So, first, you need to open the Arduino IDE and go to the menu
"File -> Preferences"
In the dialog, look at the field "Sketchbook Location" and open the corresponding folder.
The "libraries" folder in inside.
I have found that from version 1.8.4 on, the libraries can be found in ~/Arduino/Libraries. Hope this helps anyone else.
I had to look for them in C:\Users\Dell\AppData\Local\Arduino15\
I had to take help from the "date created" and "date modified" attributes to identify which libraries to delete.
But the names still show in the IDE... But it is something I can live with for now.
For others who are looking to remove a built-in library, the route is to get into PackageContents -> Java -> libraries.
BUT : IT MAKES NO SENSE TO ELIMINATE LIBRARIES inside the app, they don't take space, don't have any influence on performance, and if you don't know what you are doing, you can harm the program.
I did it because Arduino told me about libraries to update, showing then a board I don't have, and when saying ok it wanted to install a lot of new dependencies - I just felt forced to something I don't want, so I deinstalled that board.
In Elegoo Super Starter Kit, Part 2, Lesson 2.12, IR Receiver Module, I hit the problem that the lesson's IRremote library has a hard conflict with the built-in Arduino RobotIRremote library. I am using the Win10 IDE App, and it was non-trivial to "move the RobotIRremote" folder like the pre-Win10 instructions said. The built-in Libraries are saved at a path like: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries
You won't be able to see WindowsApps unless you show hidden files, and you can't do anything in that folder structure until you are the owner. Carefully follow these directions to make that happen: https://www.youtube.com/watch?v=PmrOzBDZTzw
After hours of frustration, the process above finally resulted in success for me. Elegoo gets an F+ for modern instructions on this lesson.
as of 1.8.X IDE
C:\Users***\Documents\Arduino\Libraries\
My solution is low-tech but effective so I want to share:
create a folder for disabled libraries next to libraries
move libraries here to disable, swap back in to re-enable

Arduino in pure C

I've attempted this myself by compiling the Arduino libraries into their own standalone library and linking to a project in Eclipse, but have had a couple of issues along the way.
Is there a decent guide on how to get this up and running? I've been hard pressed to find one online that actually works... The arduino.cc guide has a couple of flaws in, and troubleshooting drove me insane.
I'm on Mac OS X 10.5 with an Uno board.
Edit: Might be worth noting that most Arduino C guides don't specify the baud rate necessary, just the MCLK frequency (16 MHz). Make sure you've changed this or AVRDude won't understand how to flash your IC.
Other people have had some success using the guide Using Eclipse with Arduino Duemilanove.
Arduino will not work in pure C setup as it requires a C++ compiler. However if you want to include arduino core and other libraries inside your project then read on. Here we can see how to use Arduino Ethernet Library with our code.
STEP BY STEP GUIDE
Get Arduino cores and variants/ files.
Get relevant library, e.g. Arduino Ethernet library
The directory structure is
/
lib/arduino/cores
lib/arduino/variants//pins_arduino.h
lib/arduino/makefile
lib/arduino/build
lib/
The sample make file can be downloaded from:
https://gist.github.com/rjha/b7cda6312552c3e15486
First create Arduino core as a static library. To do so:
$cd to lib/arduino folder
$ make clean
$ make lib
This will create lib/arduino/build/libarduino.a static library file.
Next we goto main project Makefile. There we can define any Arduino library,e.g. Arduino SPI or Arduino Ethernet as a make target that compiles against Arduino core library.
Inside our own make target, we can include Arduino Target that in turns include Arduino core.
For (7) and (8) example, see this gist
https://gist.github.com/rjha/e7b123d3dc4346b5830c
(9) when creating Hex and general linking, link using -larduino and keep the libarduino.a in the search PATH. #see above Gist for an example.
(10) Using this structure you can use any Arduino libraries inside your own code.
Most of the Arduino libraries are a mess dependencies wise and the code quality is also poor. The only benefit is that you can get some ready made libraries to link against your code.

Resources