Skip to content

Off-by-one Error In RMT Example #2921

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

Closed
tedhenry100 opened this issue Jun 23, 2019 · 1 comment · Fixed by #2986
Closed

Off-by-one Error In RMT Example #2921

tedhenry100 opened this issue Jun 23, 2019 · 1 comment · Fixed by #2986

Comments

@tedhenry100
Copy link

In https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/RMT/RMTWriteNeoPixel/RMTWriteNeoPixel.ino lines 64 and 65 there is an off by one error.

The shift is too much. for the first iteration of the loop 1<<(8-0) is 100000000 which is not the desired bit mask. The desired bit mask is 1000000. It should be 1<<(7-0)

        for (bit=0; bit<8; bit++){
            if ( (color[col] & (1<<(8-bit))) && (led == led_index) ) {

There is a comment from @VerusLogic in the related commit about this problem.

4e96bff#diff-e59a7abf6f432b9f3d716a15f5f9b715

@david-cermak

david-cermak added a commit to david-cermak/arduino-esp32 that referenced this issue Jul 14, 2019
Fixed bit shift in demo application of using RMT peripheral. Init data array to be transmitted was off by one, as for the first iteration (i==0) the mask was 1<<8, which results in shifted RGB value in color variable
Closes espressif#2921
@david-cermak
Copy link
Contributor

Hi @tedhenry100

sorry for such a late response.
Yes, there's an off by one error, thanks for noting! Posted a PR

me-no-dev pushed a commit that referenced this issue Jul 16, 2019
Fixed bit shift in demo application of using RMT peripheral. Init data array to be transmitted was off by one, as for the first iteration (i==0) the mask was 1<<8, which results in shifted RGB value in color variable
Closes #2921
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 a pull request may close this issue.

2 participants