Seeed-Studio / CodeCraft

Codecraft is a graphical programming software which is based on Scratch 3.0
https://ide.tinkergen.com/
Apache License 2.0
18 stars 3 forks source link

Add Neopixel WS2813 #13

Open vongomben opened 5 months ago

vongomben commented 5 months ago

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

vongomben commented 5 months ago

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 commented 5 months ago

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

setPixelColor

vongomben commented 5 months ago

strip.show strip-show

vongomben commented 5 months ago

strip.clear();

strip-clear

vongomben commented 5 months ago

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 commented 5 months ago

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
    }
  }
}