-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Added ESP32 IR receive support (IRsend not implemented yet). #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- disable a lot of defines not relevant to ESP32, set them to 1 (no-op) - change default IR pin to 35 from 11 - changed serial speed to 115200 (9600 is too slow to keep up with IR input) - irSend disables code that will not compile on ESP32. It won't work, but it won't break compilation either.
Dear maintainer: If you're not overjoyed with my ifdef ESP32 for IRpin and baud rate, feel free to revert those bits. |
Sorry just saw this! My only concerned before merging is that I have no way to test it and would prefer validation from another user just to maintain a level of QC. @bengtmartensson @AnalysIR do you have access to this board? |
No worries, it wasn't a long wait :) |
If not I'll just review it a bit and merge anyways, one it's released others should be able to report bugs, of any. Also you might want to search github for other esp32 ir libraries in case they help with development |
There is https://github.com/ExploreEmbedded/ESP32_RMT which uses hardware specific to ESP32, but I didn't use it because I'm already using RMT to talk to neopixels and it doesn't seem to support all the IR protocols your library does. |
I have one on order, but it will be many weeks before it lands... |
@AnalysIR I have a custom board you can't really buy: https://github.com/marcmerlin/IoTuz |
Okay, in that case @marcmerlin I think I'll just give the main contributors (including myself) a few days to review this PR and if there are no objections I will merge it into a release and anyone that does have an issue can report it as a bug. @AnalysIR do you think thats a good plan? I don't like including code that hasn't been tested a lot, but it seems that the only way to get this kind of library tested is to release it? @marcmerlin |
@z3t0 indeed, your main concern is to make sure my code
For licensing, you may have this patch under both GPLv3 and MIT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this PR violates good practice in handling hardware dependencies. Such dependencies should be isolated to certain isolated areas, here [IRremote]boardddefs.h. There should be no #ifdef HARDWARE
in the high-level code. Instead, the low-level, hardware dependent file should say
#ifdef HARDWARE
#define PROPERTY
#endif
and the highlevel code should use only #ifdef PROPERTY
etc. Here, this goes for the sending ability, for example. (I think the Gnu coding guidelines states this explicitly.)
Everything "IMHO"...
Also, the change of baud rate is better separated from a PR intended to support new hardware.
Unfortunately, I do not presently have access to the hardware, and have not been able to test.
@bengtmartensson I totally agree with what you're saying, I actually tried to put things in the hardware file, but sadly it didn't quite work out that way for some changes (other ones did end up in the hardware file) As for the defines, there are 4 and here is an explanation for each: second one: third one in irRecv.cpp: fourth one in irSend.cpp: For the rest, you'll see that I did put defines in the hardware file, when it was possible, all the way to defining code that won't compile on ESP32 to '1' instead when that code wasn't needed. My changes to the examples (pin and serial speed), as per my first message, you are totally ok to reject/revert/remove them, they are not vital to the code working, just a suggestion at best. |
examples/IRrecvDemo/IRrecvDemo.ino
Outdated
@@ -8,16 +8,22 @@ | |||
|
|||
#include <IRremote.h> | |||
|
|||
#ifdef ESP32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the ESP32 work in a way where the receive pin needs to be specified like this? For the arduino's we only have restriction on the send pins as they are tied to timers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, as I said earlier, on the default platform I have, pins are already assigned in other ways, but there is no hardware restriction. If I had a bare chip, I would be able to use the same pin assignment than the default code.
So if you'd rather drop this bit, as per my earlier comment, I'm totally ok doing so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that removing this is a good idea, just to keep the example files consistent. Thanks for the foresight though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do.
examples/IRrecvDemo/IRrecvDemo.ino
Outdated
|
||
IRrecv irrecv(RECV_PIN); | ||
|
||
decode_results results; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(9600); | ||
Serial.begin(115200); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can create a separate issue that asks the community if the Serial rate needs to be changed, otherwise it would be best to keep it as. And for sure as @bengtmartensson said if we do incorporate this change, it should be in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. 9600 was not fast enough to output timely for a test I did, but there took, as per prior comment, I'm totally ok removing this too if you'd like me to.
IRremote.cpp
Outdated
@@ -120,7 +122,11 @@ int MATCH_SPACE (int measured_ticks, int desired_us) | |||
// As soon as first MARK arrives: | |||
// Gap width is recorded; Ready is cleared; New logging starts | |||
// | |||
#ifdef ESP32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better placed in boarddefs.h
Something like this
#ifdef ESP32
#define IR_USE_TIMER_ESP32
#endif
// then near the bottom of the same file
#if defined (IR_TIMER_USE_ESP32)
...
#endif
Also, I think the actual timer definition might be better defined as modelled here
Notice how all the timer definitions are defined with the same macros, that way the higher level implementation is platform agnostic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like of the same functionally speaking than the original, but if you prefer this, happy to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! The only reason for this is if the macros are named in the way I specified in my example, then the code for other platforms will not be included. That way the compiler ends up only including the code needed for each platform, but the higher level implementation isnt aware of this if there is for example only ever one TIMER_INIT function.
Does that make sense?
Also, I am sorry if it appears that we are being very strict, or unwelcoming. I am sure I speak for the entire Arduino community when I say that your contributions are not only welcomed but very much encouraged! I realize it takes a lot of energy and time to contribute upstream to a project and I hope you take our criticism as nothing more than constructive and positive.
If you have any questions about any of our "demands" then feel free to extend the discussion and ask as about why we are doing something a certain way, or even suggest another way that you think would be better.
Hopefully, we don't scare you a way 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, don't worry, I have a thick skin and been doing CR/PRs for many years. Also I know that accepting code just before it works is not a great idea by itself, there are other requirements that should be met.
Easy to change, will do.
boarddefs.h
Outdated
@@ -39,6 +39,10 @@ | |||
# define BLINKLED_ON() (PORTD |= B00000001) | |||
# define BLINKLED_OFF() (PORTD &= B11111110) | |||
|
|||
#elif defined(ESP32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be defined as writes to PORTS (or the equivalent on ESP32).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, there is no status LED to write on, on the reference platform I have (led13 on AVR). Also, you don't write to ports like you do on AVR, digitalWrite is actually fast on ESP32, so no tricks needed.
If I were to add a status LED to an ESP32 chip, this could be made to work, but by default there is none, and my specific platform has no I/O left to send random on/off flips to.
Given that, I disabled this functionality since there is no safe I/O port to write to without affecting another peripheral.
Given this, what would like me to do? I could pick a random I/O port and send random on/off events to it. but it just doesn't seem very safe. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, there is no status LED to write on, on the reference platform
Oh I see my bad, I was not aware of that.
digitalWrite is actually fast on ESP32,
Thank god!!
Given this, what would like me to do? I could pick a random I/O port and send random on/off events to it. but it just doesn't seem very safe. What do you think?
Probably not a good idea to pick a random port as that would give unexpected results... I'll take a look at the code and how other platforms deal with this (if at all) and get back to you
boarddefs.h
Outdated
@@ -147,12 +151,21 @@ | |||
// | |||
#if defined(IR_USE_TIMER2) | |||
|
|||
#ifdef ESP32 // Used in irSend, not implemented yet (FIXME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good but the rest of the timer functions such as reset and count should also be implemented under here, refer to the comment before the last
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is related to IR sending, not receiving, correct?
If so, I don't have a way to test this code for now, hence my having disabled it and added a FIXME.
In other words, I know this is not the right code, but I'm leaving it to someone else to write and test, someone who is using IR sending and can test this and send you a patch after mine is in.
I do have to stub those though, otherwise the code won't build or run on the receive side.
So, I know this is the wrong code, but that's all I have for you :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see! Sorry I saw the part about it not being implemented but didn't connect that to the rest being a stub... Sorry I'm a bit slow in the mornings!
In that case a better way to deal with this is like so:
#if defined(SOMETHING)
// Make the compiler cry out since this is not yet implemented
#warning "Sending has not yet been implemented for ESP32"
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the irony, here, is that I was actually not to put ifdef ESP32 all around the existing code, and stick to boarddefs.h when possible (which is what you were also asking earlier on).
I can do what you suggest here, but basically it means moving board specific code away from boarddefs.h and instead add more ifdefs inside the main code.
From what you said earlier, I'm not sure this is what you wanted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but basically it means moving board specific code away from boarddefs.h and instead add more ifdefs inside the main code.
Sorry but I may be misunderstanding you. Where would the ifdefs be placed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now in change those defines to stub code that compiles and does nothing (i.e. '1').
If I need to emit a compile warning, it likely should be put inside the irsend function if it gets used/compiled in.
Or I could ifdef the whole code block in irsend
#ifdef ESP32
#warning no irsend support on ESP32
#else
the current code in the function
#fi
That's easy to do, but it adds more ifdefs directly inside the worker functions, which you didn't love (and I understand why, I don't love that either, which is why I found a way to avoid it here)
@@ -117,6 +122,15 @@ IRrecv::IRrecv (int recvpin, int blinkpin) | |||
// | |||
void IRrecv::enableIRIn ( ) | |||
{ | |||
// Interrupt Service Routine - Fires every 50uS | |||
#ifdef ESP32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know enough about ESP32 to make a decision here, but there should be a neater way to do this with a compare interrupt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, you lost me here. What I understood of the AVR code, was that it fires every 50ns to run the ISR. What do you mean by "compare interrupt", or what should I be doing differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay sorry, I wasn't reading the code properly. It seems that you are using a compare interrupt after all. What that means is that the way timers work is that they count up to a certain number and then run an interrupt, meaning they run an interrupt on comparing the value of the timer to the value they count to.
I am not very experienced with using the Arduino methods for interrupt and am concerned that it may have a performance delay? The other method of course is to write directly to the bits ... but I am also not sure exactly how ARM bits work under Arduino, can we just write to them as usual? @bengtmartensson any ideas?
Also, this might be another issue where the function works fast on the ESP32 unlike normal Arduino and we don't have to worry about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it indeed running a timer/compare/reset like you said, which is why I was confused by your comment.
But I'm still confused by your comment in this context.
The code sets up an interrupt handler that fires every 50ns. I did the exact same thing on ESP32, it's just a different syntax.
Maybe there is a better way to be receiving IR, but I'm not trying to change this. I'm using the same code you already have and getting it to run as an interrupt with the same frequency on ESP32
Given that, I'm not sure there is anything to change here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so the difference here is that in your patch, Arduino functions are being used to enable the interrupt. Whereas, in the library we try our utmost to avoid Arduino functions and instead write directly to the register.
For example:
TIMER_CONFIG_NORMAL();
// Timer2 Overflow Interrupt Enable
TIMER_ENABLE_INTR;
TIMER_RESET;
These three macros are used to write to the registers of the microcontroller and to enable and configure the timers. This is done because the level of abstraction provided by the arduino functions are convenient but often slower than a direct write.
So for example, those macros above expand into for one of the Timer2 implementations:
#define TIMER_RESET
#define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A))
#define TIMER_CONFIG_KHZ(val) ({ \
const uint8_t pwmval = SYSCLOCK / 2000 / (val); \
TCCR2A = _BV(WGM20); \
TCCR2B = _BV(WGM22) | _BV(CS20); \
OCR2A = pwmval; \
OCR2B = pwmval / 3; \
})
The overall result is a higher performance library than if we were to directly use:
timer = timerBegin(1, 80, 1);
timerAttachInterrupt(timer, &IRTimer, 1);
// every 50ns, autoreload = true
timerAlarmWrite(timer, 50, true);
timerAlarmEnable(timer);
I am not sure about one thing though, as you mentioned earlier, the ESP32 does a better job with its high level functions? For example, you said digitalWrite is much faster on the ESP32. Perhaps do a bit of googling or searching on the Arduino forums to determine whether there is a real performance hit in using the Arduino functions to schedule timers on ESP32. I know for a fact that there is on the Arduino boards, which is why we prefer to write to the registers directly instead.
Does that make more sense? Sorry for the wall of text!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also ESP32 is an order of magnitude, or two, faster than many AVR chips :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also ESP32 is an order of magnitude, or two, faster than many AVR chips :)
True! My only concern is that we should not take that speed for granted, especially not for optimizations that are easily made during compilation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see your point now, but I don't think it's relevant in the ESP32 case:
you only setup the timer once. It does everything on its own after that.
ESP32 is definitely not AVR. You actually have a supervisor/HAL underneath and you're not talking to the hardware directly either way. However the one time I tried to use a way to bypass digitalwrite, I was told by the arduino-esp maintainer that what I did was actually slower and that I should stick to the digitalwrite API.
Long story short, using the actual API timer libraries on ESP32 is the correct thing to do, the arduino layer on ESP32 was definitely written to be fast, and trying to talk directly to the hardware is actually discouraged.
So everything you said makes sense, and is the way to go on AVR, but not the case for ESP32.
Ah that would make a lot of sense. Just for the sake of verbosity could you perhaps link that discussion with the maintainer or another source on this topic as I am not very well versed in it and would like to read up on it before making a decision? It's just that we would be changing a guideline that has been followed for a while on this library, which I have no concern over changing! But to do so I'd like to document the reasons in the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmh, that was over gitter (i.e. IM), so I don't really have a good link.
But basically, this is the only supported way I know to fire interrupts on ESP32, and was told by the arduino-esp maintainer to use this.
I can add a comment stating so in my new pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a comment to address your concern/questions.
Thanks for the detailed review and comments. Please see my followup questions before I can give you a new version. |
@z3t0 just to be clear, I did have a few questions above I was waiting for an answer on, before I can do that new version for you :) |
@marcmerlin done! |
@z3t0 replied to your comments, PTAL |
@marcmerlin done! |
Ok, is there still anything outstanding? If not, I'll work on an updated version of the PR with the comments I can act on with new code. |
No I think we're good! You can just push your new changes and it'll automatically be added to this pr |
…ples. - fixed indenting on existing code in a few places for consistency - introduced IR_TIMER_USE_ESP32 for ifdefs within the code as per request - added comments explaining what's missing for irsend support on ESP32 - IRrecvDemo.ino gets a warning before and after interrupt is enabled in case it causes a crash TESTED=IoTuz ESP32 board and original 328p arduino to make sure current code did not break.
@@ -18,14 +18,17 @@ | |||
// Whynter A/C ARC-110WD added by Francesco Meschia | |||
//****************************************************************************** | |||
|
|||
#include <avr/interrupt.h> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I had to move this down for IR_TIMER_USE_ESP32 to be defined (you asked me to use this instead of ESP32, which I was able to test without moving the include line, but now I have to move it down)
Ok, I believe I took care of all your comments, including reverting changes to the example code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still have some issues with ESP32 functions vs using generic macros with ESP32 specific implementations
@@ -39,9 +39,14 @@ | |||
# define BLINKLED_ON() (PORTD |= B00000001) | |||
# define BLINKLED_OFF() (PORTD &= B11111110) | |||
|
|||
// No system LED on ESP32, disable blinking | |||
#elif defined(ESP32) | |||
# define BLINKLED 255 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, @bengtmartensson what do you think?
boarddefs.h
Outdated
// way to do this on ESP32 is using the RMT built in driver like in this incomplete library below | ||
// https://github.com/ExploreEmbedded/ESP32_RMT | ||
#elif defined(IR_TIMER_USE_ESP32) | ||
#define TIMER_RESET 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a better idea to use these macros instead of specifying the code elsewhere.
For example:
// In boarddefs.h
#elif defined(IR_TIMER_USE_ESP32)
#define TIMER_RESET() ({
timer = timerBegin(1, 80, 1);\
})
#define TIMER_INTR () ({
timerAttachInterrupt(timer, &IRTimer, 1);
})
Note: this code doesn't actually compile since timer
isnt defined but it explains the concept of using macro functions which can be replaced by the processor so the actual code compiled has no concept of "boards" because the compiler takes care of that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmh, I supposed I can do that, but that makes the code hard to read and debug to be honest (ESP32 actually has crash tracebacks with line numbers, but by the time you're using complex macros like this, it all stops working in a useful fashion).
If you insist, I can go ahead, but again the architectures are sufficiently different that
- it kind of feels like pushing a round peg in a square hole
- I'm not sure every last ESP32 define can be removed from the main code, or it's going to be ugly macros.
Basically I think macros were reasonable as long as you stuck with AVR, but by the time you're adding different platforms, I think a macro only solution is going to get out of hand, and honestly I haven't seen any other arduino library that goes through those extremes once they're supporting non AVR platforms.
I do realize it kind of is kicking the sandcastle and you're not very happy with the idea, so I'll let you consider and decide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen any other arduino library that goes through those extremes once they're supporting non AVR platforms.
I do realize it kind of is kicking the sandcastle and you're not very happy with the idea, so I'll let you consider and decide.
My experience there is quite limited as I haven't worked with any non AVR boards hmm.
I'm just trying to make suggestions from what I do understand about micro controllers 😄, no judgement. But it seems that my understanding doesn't really extend to non-AVR platforms as you have mentioned.
I'm perfectly fine with breaking the sandcastle though! I'll give this another run through and merge 🎉
@@ -120,7 +123,11 @@ int MATCH_SPACE (int measured_ticks, int desired_us) | |||
// As soon as first MARK arrives: | |||
// Gap width is recorded; Ready is cleared; New logging starts | |||
// | |||
#ifdef IR_TIMER_USE_ESP32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too keen on having a separate function just for the ESP32 and would again prefer macros dealing with this its much cleaner by ensuring that the only file that deals with the hardware differences is boarddefs.h
Though I am open to doing it this way as well, @bengtmartensson thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef IR_TIMER_USE_ESP32
void IRTimer()
#else
ISR (TIMER_INTR_NAME)
#endif
If there is a fancy way to write this with a #define, let me know. Otherwise, what do you mean by "separate function' ? I'm using the same function code, I just have to name it something else since the signature is different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This essentially refers to the other comment about macros, il go reply on that.
boarddefs.h
Outdated
#elif defined(IR_TIMER_USE_ESP32) | ||
#define TIMER_RESET 1 | ||
#define TIMER_ENABLE_PWM 1 | ||
#define TIMER_DISABLE_PWM Serial.println("IRsend not implemented for ESP32 yet"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try this just for consistency within the library code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just ping me once you've committed this change
irrecv.enableIRIn(); // Start the receiver | ||
Serial.println("Enabled IRin"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good idea
Could you also add timer info to the README? |
Sorry, I missed the part where you asked me to increase y and not z. |
I don't understand why the ESP code can't use the macros like everyone else. If this is done for more boards, the code will become quite a mess. |
Especially thing like this:
Really, how hard is it to just define TIMER_INTR_NAME to be IRTimer and define ISR the same as Teensy and other non-AVR boards do. This pull request makes a mess just for one chip. Not good. |
@PaulStoffregen you obviously have more experience with this than I do (I have your teensy chips and 3rd party drivers, thank you). |
@PaulStoffregen These were my thoughts as well... I think I'll revert the PR for the moment and allow the discussion to continue, but ideally yes we should avoid breaking the standards. @marcmerlin sorry for all the fuss! |
Before you revert, I'm happy to send a followup CL, as long as you give me clear actionable direction. Otherwise honestly, I'm just going to give up on this. In this case, I've tried to use a hybrid approach, but things that were easy in the boards file to avoid sprinkling the entire code with ifdefs, but stay clear of double macro substitutions on a single line or macros that expand to multi-line code. So back to this patch, I see 3 options:
#3 is silly, but at the same time, there is only so much time I can spend on this, and chasing a goal that I'm not even sure is achievable reasonably, or goes against what I think is reasonable readable code, isn't that appealing to me either. |
Agreed #3 is silly, I'm quite busy at the moment, so I'll hold on reverting until I am able to give you actionable feedback |
And to be clear, "silly" applied to "me keeping an unmerged out of date fork", not "you reverting" :) |
If that helps my point that multiple plaforms for certain kinds of operations, ends up being hard, look at show() in |
I think that the present version is not "acceptable", as I have argued in my previous message, That also goes for the Adafruit example. The core problem is that the "high-level" files mix in concepts on the wrong abstraction level, like the type of the board. I fooled around a bit, and came up with this. It is also found in my fork. Since I do not presently have the hardware, have not tested it though. |
@bengtmartensson thanks for giving this a shot, definitely helps.
If you are interested in seeing if your code compiles with the right defines, you can either force a define ESP32 at the top of the .h file to enable those code paths and verify that it builds although it might not quite due to the interrupt definitions. |
I wrote the patch for discussion, not for direct deployment. (Yes, I am a theoretician...) |
Understood |
I have updated the fork; the update is available as patch here.
I think it is reviewable as-is, but on his request, I will do so. Add to 2. above: Cf. OO programming: Calling fly() on an object of type Penguin is supposed to give a compile-time error, NOT throw a run-time exception, or even worse, produce an error message saying that penguins cannot fly :-). |
Thanks @bengtmartensson . Your patch was reviewable before, just not as convenient to comment inline, in, as when it's a real github patch where the github UI allows one to type inline inside the patch. |
As you desired, I have created a PR, #437. Just for the fun of it, I threw in SAM support too, see #390. |
Great thank you so much. Il take a look once I get a chance. In the meantime. If @ladyada and @marcmerlin and others could test. |
@marcmerlin @z3t0 Are there any plans on implementing IRsend for ESP32? I am only asking because of the title of the PR (...not implemented yet). |
Just defining USE_SOFT_CARRIER and removing the undef of SENDING_SUPPORTED for ESP32 and it "should" work. Please try. (USE_SOFT_CARRIER "should" work on anything fast enough.) |
@PePe79 I won't be adding this myself simply because I don't have hardware to test it, or any use for that feature. |
@marcmerlin @bengtmartensson I had time to test your suggestions. It took a while to understand that your suggested changes are based upon your current fork/PR: #437 In the end I accomplished to send some commands to my LG-television with my ESP32 board....woohoo ;-) In order to do so, some minor other changes were necessary to compile successfully: marcelkottmann@9b71ca8 |
@bengtmartensson just making sure you got this, would be good to merge into your temporary fork |
Added ESP32 IR receive support (IRsend not implemented yet).
but it won't break compilation either.