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

No way to query color of a specific pixel #30

Open
samelhusseini opened this issue Jun 11, 2018 · 1 comment
Open

No way to query color of a specific pixel #30

samelhusseini opened this issue Jun 11, 2018 · 1 comment

Comments

@samelhusseini
Copy link
Contributor

samelhusseini commented Jun 11, 2018

Unlike pxt-common-packages, there's no way to query a color of a specific pixel.

"In circuit playground, you have a block "pixel color at 0" which returns the colour of that light. Is this block available in micro:bit for strips that you add on? e,g. I want to know what colour light 4 is in my RGB strip?"

User request:
https://twitter.com/LMcUnderwood/status/1006204237834018816

@CDEguia
Copy link

CDEguia commented Oct 31, 2024

In Java it would look like

function getLedValues (led: number) {
    // Get the current values for all leds
    let current_buff = strip.buf
    // Break up the buffer into chunks, each corresponding to an LED 
    let chunked_buff = current_buff.chunked(3)
    // Get the Value requested
    let current_value = chunked_buff.get(led)
    // ENHANCEMENT: Return in different/requested format
    // Returns: array of [green],[red],[blue] values, but could also return an  int, string, or ...
    return current_value.toArray(NumberFormat.UInt8LE)
}```

CDEguia added a commit to CDEguia/pxt-neopixel that referenced this issue Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants