Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Is there a getPixel command for the WS2812Serial Library?

  1. #1
    Junior Member
    Join Date
    Apr 2019
    Posts
    2

    Is there a getPixel command for the WS2812Serial Library?

    I'm trying to move a project from a Teensy 3.2 with the Octo2811 library to a Teensy LC with the WS2812Serial library. The one thing that is hanging me up is the fact that there is no getPixel command in the WS2812Serial library. Is there an equivalent function in the WS2812Serial library to read the status of the LEDs or another way to read the "frame buffer"?

  2. #2
    Junior Member
    Join Date
    Apr 2019
    Posts
    2
    I created a function in WS2812Serial.h that worked for me. It does not take into account different LED color orders (RGB vs. RBG vs. GRB etc.). I hope it can help someone.

    Code:
    int getPixel(uint32_t num) {
    
            if (num >= numled) return -1;
            int color=0;
            num *= 3;
            color = drawBuffer[num+2] & 255;
            color = color << 8;
            color |= drawBuffer[num+1] & 255;
            color = color << 8;
            color |= drawBuffer[num+0] & 255;
            
            return color;
        }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •