Skip to content
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

Compatibility for NEC protocol is fixed #68

Merged
merged 3 commits into from
Apr 21, 2024

Conversation

tkomde
Copy link
Contributor

@tkomde tkomde commented Apr 16, 2024

This PR fix #40, #39, #65 and enhance one.

First of all, the IR protocol used primarily in the world is the NEC protocol. The code in this repository was also inferred to assume the NEC protocol from the code comments.

#40 is a sample issue, so I have adapted to the NEC protocol.
#39 may also be a sample issue, I added the value instead of 0 because the NEC protocol requires an trail.

examples/irremote_transmit.py

    header=[9000, 4500], one=[560, 1700], zero=[560, 1700], trail=560

At the same time, decoding was adapted to the NEC protocol. This is a destructive change, but if this is not done, the RX/TX will not be consistent.

adafruit_irremote.py

        if (space * 0.75) <= pulse_length <= (space * 1.25):
            pulses[i] = True
        elif (mark * 0.75) <= pulse_length <= (mark * 1.25):
            pulses[i] = False

#65 is simply a typing change.

adafruit_irremote.py

    :param List[int] header: The length of header in microseconds, the length should be even
    :param List[int] one: The length of a one in microseconds
    :param List[int] zero: The length of a zero in microseconds

And the following is enhancement. The header is now variable instead of 2 fixed. This is useful for protocols that require a leader mark in addition to the header (e.g., Hitachi remote controls).

adafruit_irremote.py

        durations = array.array(
            "H", [0] * (len(self.header) + bits_to_send * 2 + (0 if self.trail is None else 1))
        )
        
        for i, _ in enumerate(self.header):
            durations[i] = self.header[i]

Please review and merge.
Because of the disruptive changes, a major version update would be desirable.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanation here and in the referenced issues along with the code changes make sense and look good to me. I did not test on hardware.

Thank you for these fixes and improvements @tkomde

@FoamyGuy FoamyGuy merged commit d3f3b31 into adafruit:main Apr 21, 2024
1 check passed
@tkomde
Copy link
Contributor Author

tkomde commented Apr 21, 2024

@FoamyGuy Thanks for your review and merge. I think it is safe to close issues #39 and #65.

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 22, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO08X to 1.2.6 from 1.2.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO08x#48 from Tekunalogy/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_IRRemote to 5.0.1 from 4.1.19:
  > Merge pull request adafruit/Adafruit_CircuitPython_IRRemote#69 from tkomde/patch-1
  > Merge pull request adafruit/Adafruit_CircuitPython_IRRemote#68 from tkomde/feature/updates202404

Updating https://github.com/adafruit/Adafruit_CircuitPython_RFM69 to 2.1.20 from 2.1.19:
  > Merge pull request adafruit/Adafruit_CircuitPython_RFM69#53 from michaeldye/ver35-compat-check

Updating https://github.com/adafruit/Adafruit_CircuitPython_AVRprog to 1.5.0 from 1.4.13:
  > Merge pull request adafruit/Adafruit_CircuitPython_AVRprog#35 from Danct12/atmega328pb

Updating https://github.com/adafruit/Adafruit_CircuitPython_RSA to 1.2.22 from 1.2.21:
  > Merge pull request adafruit/Adafruit_CircuitPython_RSA#42 from FoamyGuy/gen_json_keys

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NEC one/zero codes reversed
2 participants