Open rkandilarov opened 7 years ago
Thank you for the thumbs up :)
The library compiles fine in Sloeber V4. You are compiling for an atmega328p that has no timer 4. Please try to compile for an atmega2560 and see if the problem persists.
Of course it will work if I select the proper board :). But as I need it for atmega328p I need to rename the files with definitions for the inexistent timers in order to prevent the IDE to try to compile them.
Will sent you proposition for some pragma changes, but when I come back to the project in few weeks.
You are right!
I'm using Sloeber V4 so I installed the latest Arduino software and it seems that the behavior of include changed since the last time I tested this with the Arduino software. Include now not only includes the file but all the files in that directory :(
Work around at the moment is to delete the unwanted files in the library.
I think that I have to put in some compiler conditionals so that the files for the timers available in the chip are only visible to the compiler when those timers are present.
Thank you for bringing this up :)
I have added compiler conditionals for the microcontroller type. The library now compiles for the atmega328p and the like.
I tested this again and found out that the compiler error is also present in Sloeber. I probably tested the timer 4 and timer 5 code only with the 2560 and never checked if it was still working for the 328 :(
The funny thing is that without the guards you get an error when using the SMT172.h as the compiler also sees SMT172_T4.cpp and SMT172_T5.cpp when compiling for a 328 but does not see the SMT172_T4.h and SMT172_T5.h
I wonder if the compiler only uses the included header files in the first stage and all of the cpp files in the library in the second stage.
First I would like to say - GREAT JOB for the library!!! It saves me a lot of time using the SMT172 sensors!
But the library as it is now cannot be used directly (without dummy "hack" - deleting/renaming files) as external lib to Arduino IDE. By default, as I understand it, ARDUINO compiles all *.cpp files under the
library/LIBNAME/src
folder. So if anybody simply clones this repo (as s/he'll usually do with the other libs) s/he'll have underlibraries/SMT172/src
3 incompatible with each other "versions" of the library. Then the compiler fill fail. In my case (Arduino UNO selected as board) it gives the error:I'm not deep in ARDUINO world but suppose that the clear way to do it should be like in
arduino-1.6.*/libraries/IRremote/IRremoteInt.h
:Only one header file with #pragmas defining pseudo names for the timers
Using the pseudo names in the only one cpp
Will try to submit pull request when I have time these days.