Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions neopixel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@ namespace neopixel {
this.setPixelRGB(pixeloffset >> 0, rgb >> 0);
}

/**
* Returns an array of RGB, GRB or RGBW values for the given pixel in a strip
* @param pixeloffset position of the NeoPixel in the strip
*/
//% blockId=neopixel_get_pixel_colors block="%strip|get pixel %pixel"
//% strip.defl=strip
//% blockGap=8
//% weight=5
//% parts="neopixel" advanced=true
getPixelColor(pixeloffset: number, ){
if (pixeloffset < 0 || pixeloffset >= this._length) return [];
const stride = this._mode === NeoPixelMode.RGBW ? 4 : 3;
return this.buf.chunked(stride).get(pixeloffset).toArray(NumberFormat.UInt8LE)
}

/**
* Sets the number of pixels in a matrix shaped strip
* @param width number of pixels in a row
Expand Down