CodeCraft icon indicating copy to clipboard operation
CodeCraft copied to clipboard

Add Neopixel WS2813

Open vongomben opened this issue 2 years ago • 6 comments

Can you update the Chainable LED to the Neopixel Led with the official neopixel library?

vongomben avatar Jan 21 '24 15:01 vongomben

This Neopizel integration is a big opportunity to introduce in Codecraft for Wio terminal the pin declaration. My idea is that you can name more strips, on different pins, th left or right Grove connector on the Wio, ora a custom one (which should become the self defined when used with Arduino?)

image

Left stands for BCM3, right stands for BCM27

This block revolves around this declaration:

Which basically calls:

#include <Adafruit_NeoPixel.h>

and

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

Neopizel-declaration

And

void setup() {

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)

}

vongomben avatar Jan 22 '24 18:01 vongomben

strip.setPixelColor(n, red, green, blue); from here

setPixelColor

vongomben avatar Jan 22 '24 18:01 vongomben

strip.show strip-show

vongomben avatar Jan 22 '24 18:01 vongomben

strip.clear();

strip-clear

vongomben avatar Jan 22 '24 18:01 vongomben

I would add all functions in strandtest: ColorWipe

colorWipe(<stripName>.Color(r, g, b), ms);

colorwipe

void colorWipe(uint32_t color, int wait) {
  for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }
}

vongomben avatar Jan 22 '24 19:01 vongomben

theaterChase(strip.Color(127, 127, 127), 50); // White, half brightness

THEATER-CHASE

void theaterChase(uint32_t color, int wait) {
  for(int a=0; a<10; a++) {  // Repeat 10 times...
    for(int b=0; b<3; b++) { //  'b' counts from 0 to 2...
      strip.clear();         //   Set all pixels in RAM to 0 (off)
      // 'c' counts up from 'b' to end of strip in steps of 3...
      for(int c=b; c<strip.numPixels(); c += 3) {
        strip.setPixelColor(c, color); // Set pixel 'c' to value 'color'
      }
      strip.show(); // Update strip with new contents
      delay(wait);  // Pause for a moment
    }
  }
}

vongomben avatar Jan 22 '24 19:01 vongomben