cyborg5 / IRLib2

Library for receiving, decoding, and sending infrared signals using Arduino
GNU General Public License v3.0
384 stars 138 forks source link

frameTimeout exposes IRP implementation details #102

Open MaschMaker opened 3 years ago

MaschMaker commented 3 years ago

@cyborg5 This is really a IRLib2 design question I need help with. I have implemented a new IRLib2 protocol for XMP which is used by Comcast for its DC50X cable box and UEI DTA (URC-3067BC0-R) remote. This is my first IR related project. My issue has to do with how the default frame timeout value is modified. XMP has a "long" half frame gap space of 13800µs which is longer than the default frame timeout of 7800µs. From the IRLib2 documentation (which is awesome!), I know that I can call the setFrameTimeout() method on the receiver object from the sketch. However, this requires that the sketch developer understands/knows about the implementation details of the XMP protocol. I would like to hide all the XMP IRP implementation details in the XMP decode class which was accomplished except for frame timeout.

My question is: what is the best way to modify the frame timeout from within the decode class?

What I have done so far is to modify both the recvGlobal.frameTimeout and recvGlobal.frameTimeoutTicks inside the constructor for my new decode class. The downside to this is two fold:

  1. I need to include IRLibHardware.h in order to get the USEC_PER_TICK value needed for setting recvGlobal.frameTimeoutTicks, and
  2. This biggest problem is that if the sketch developer declares the receive object variable AFTER the decode object variable then the receive object blindly overwrites the frameTimeout values during instantiation. My workaround for this is when the decode method fails for reasons of a RAW_COUNT_ERROR (because the receiver did not stop filling the decodeBuffer at the correct spot) then I can check the value of frameTimeout and reset it as needed. However, this means that one IR stream has been lost. The next IR stream however will be correct. I would prefer to not require the sketch developer to declare object variables in the "correct for XMP" way.

Is there a better way to handle this situation? Appreciate your thoughts/ideas.

Lastly, is there any interest in adding XMP to your list of protocols? If so, I'd be happy to share.

Thanks!

st4ck commented 1 year ago

Hello @MaschMaker , I'm trying to implement XMP protocol too using IRLib2 lib, have you any hints / code to share? Any help would be appreciated. Thank you