Skip to content

Commit

Permalink
setmode (#52)
Browse files Browse the repository at this point in the history
* handling setmode support

* upgraded ws2812b reference

* aligning mode values

* restored test
  • Loading branch information
pelikhan committed May 21, 2020
1 parent d283dc8 commit b04e886
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 5 additions & 4 deletions neopixel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ enum NeoPixelColors {
*/
enum NeoPixelMode {
//% block="RGB (GRB format)"
RGB = 0,
RGB = 1,
//% block="RGB+W"
RGBW = 1,
RGBW = 2,
//% block="RGB (RGB format)"
RGB_RGB = 2
RGB_RGB = 3
}

/**
Expand Down Expand Up @@ -247,6 +247,7 @@ namespace neopixel {
//% weight=79
//% parts="neopixel"
show() {
ws2812b.setBufferMode(this.pin, this._mode);
ws2812b.sendBuffer(this.buf, this.pin);
}

Expand Down Expand Up @@ -496,7 +497,7 @@ namespace neopixel {
strip.buf = pins.createBuffer(numleds * stride);
strip.start = 0;
strip._length = numleds;
strip._mode = mode;
strip._mode = mode || NeoPixelMode.RGB;
strip._matrixWidth = 0;
strip.setBrightness(128)
strip.setPin(pin)
Expand Down
6 changes: 5 additions & 1 deletion neotest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
let strip = neopixel.create(DigitalPin.P0, 24, NeoPixelMode.RGB);

strip.setPixelColor(0, 0xff0000)
strip.setPixelColor(1, 0x00ff00)
strip.setPixelColor(2, 0x0000ff)
strip.show()
pause(2000)
strip.showRainbow();
for (let i = 0; i <= strip.length(); i++) {
strip.rotate();
Expand Down
2 changes: 1 addition & 1 deletion pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"dependencies": {
"core": "*",
"ws2812b": "github:Microsoft/pxt-ws2812b#v0.0.4"
"ws2812b": "github:microsoft/pxt-ws2812b#v0.1.0"
},
"files": [
"README.md",
Expand Down

0 comments on commit b04e886

Please sign in to comment.