diff options
Diffstat (limited to '.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples')
27 files changed, 2185 insertions, 0 deletions
diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/RGBWstrandtest/.esp8266.test.skip b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/RGBWstrandtest/.esp8266.test.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/RGBWstrandtest/.esp8266.test.skip diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/RGBWstrandtest/.trinket.test.skip b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/RGBWstrandtest/.trinket.test.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/RGBWstrandtest/.trinket.test.skip diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino new file mode 100644 index 0000000..95335cd --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/RGBWstrandtest/RGBWstrandtest.ino @@ -0,0 +1,177 @@ +// NeoPixel test program showing use of the WHITE channel for RGBW +// pixels only (won't look correct on regular RGB NeoPixel strips). + +#include <Adafruit_NeoPixel.h> +#ifdef __AVR__ + #include <avr/power.h> // Required for 16 MHz Adafruit Trinket +#endif + +// Which pin on the Arduino is connected to the NeoPixels? +// On a Trinket or Gemma we suggest changing this to 1: +#define LED_PIN 6 + +// How many NeoPixels are attached to the Arduino? +#define LED_COUNT 60 + +// NeoPixel brightness, 0 (min) to 255 (max) +#define BRIGHTNESS 50 // Set BRIGHTNESS to about 1/5 (max = 255) + +// Declare our NeoPixel strip object: +Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800); +// Argument 1 = Number of pixels in NeoPixel strip +// Argument 2 = Arduino pin number (most are valid) +// Argument 3 = Pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + +void setup() { + // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. + // Any other board, you can remove this part (but no harm leaving it): +#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) + clock_prescale_set(clock_div_1); +#endif + // END of Trinket-specific code. + + strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) + strip.show(); // Turn OFF all pixels ASAP + strip.setBrightness(BRIGHTNESS); +} + +void loop() { + // Fill along the length of the strip in various colors... + colorWipe(strip.Color(255, 0, 0) , 50); // Red + colorWipe(strip.Color( 0, 255, 0) , 50); // Green + colorWipe(strip.Color( 0, 0, 255) , 50); // Blue + colorWipe(strip.Color( 0, 0, 0, 255), 50); // True white (not RGB white) + + whiteOverRainbow(75, 5); + + pulseWhite(5); + + rainbowFade2White(3, 3, 1); +} + +// Fill strip pixels one after another with a color. Strip is NOT cleared +// first; anything there will be covered pixel by pixel. Pass in color +// (as a single 'packed' 32-bit value, which you can get by calling +// strip.Color(red, green, blue) as shown in the loop() function above), +// and a delay time (in milliseconds) between pixels. +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 + } +} + +void whiteOverRainbow(int whiteSpeed, int whiteLength) { + + if(whiteLength >= strip.numPixels()) whiteLength = strip.numPixels() - 1; + + int head = whiteLength - 1; + int tail = 0; + int loops = 3; + int loopNum = 0; + uint32_t lastTime = millis(); + uint32_t firstPixelHue = 0; + + for(;;) { // Repeat forever (or until a 'break' or 'return') + for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip... + if(((i >= tail) && (i <= head)) || // If between head & tail... + ((tail > head) && ((i >= tail) || (i <= head)))) { + strip.setPixelColor(i, strip.Color(0, 0, 0, 255)); // Set white + } else { // else set rainbow + int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); + strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue))); + } + } + + strip.show(); // Update strip with new contents + // There's no delay here, it just runs full-tilt until the timer and + // counter combination below runs out. + + firstPixelHue += 40; // Advance just a little along the color wheel + + if((millis() - lastTime) > whiteSpeed) { // Time to update head/tail? + if(++head >= strip.numPixels()) { // Advance head, wrap around + head = 0; + if(++loopNum >= loops) return; + } + if(++tail >= strip.numPixels()) { // Advance tail, wrap around + tail = 0; + } + lastTime = millis(); // Save time of last movement + } + } +} + +void pulseWhite(uint8_t wait) { + for(int j=0; j<256; j++) { // Ramp up from 0 to 255 + // Fill entire strip with white at gamma-corrected brightness level 'j': + strip.fill(strip.Color(0, 0, 0, strip.gamma8(j))); + strip.show(); + delay(wait); + } + + for(int j=255; j>=0; j--) { // Ramp down from 255 to 0 + strip.fill(strip.Color(0, 0, 0, strip.gamma8(j))); + strip.show(); + delay(wait); + } +} + +void rainbowFade2White(int wait, int rainbowLoops, int whiteLoops) { + int fadeVal=0, fadeMax=100; + + // Hue of first pixel runs 'rainbowLoops' complete loops through the color + // wheel. Color wheel has a range of 65536 but it's OK if we roll over, so + // just count from 0 to rainbowLoops*65536, using steps of 256 so we + // advance around the wheel at a decent clip. + for(uint32_t firstPixelHue = 0; firstPixelHue < rainbowLoops*65536; + firstPixelHue += 256) { + + for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip... + + // Offset pixel hue by an amount to make one full revolution of the + // color wheel (range of 65536) along the length of the strip + // (strip.numPixels() steps): + uint32_t pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); + + // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or + // optionally add saturation and value (brightness) (each 0 to 255). + // Here we're using just the three-argument variant, though the + // second value (saturation) is a constant 255. + strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue, 255, + 255 * fadeVal / fadeMax))); + } + + strip.show(); + delay(wait); + + if(firstPixelHue < 65536) { // First loop, + if(fadeVal < fadeMax) fadeVal++; // fade in + } else if(firstPixelHue >= ((rainbowLoops-1) * 65536)) { // Last loop, + if(fadeVal > 0) fadeVal--; // fade out + } else { + fadeVal = fadeMax; // Interim loop, make sure fade is at max + } + } + + for(int k=0; k<whiteLoops; k++) { + for(int j=0; j<256; j++) { // Ramp up 0 to 255 + // Fill entire strip with white at gamma-corrected brightness level 'j': + strip.fill(strip.Color(0, 0, 0, strip.gamma8(j))); + strip.show(); + } + delay(1000); // Pause 1 second + for(int j=255; j>=0; j--) { // Ramp down 255 to 0 + strip.fill(strip.Color(0, 0, 0, strip.gamma8(j))); + strip.show(); + } + } + + delay(500); // Pause 1/2 second +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLE/.none.test.only b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLE/.none.test.only new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLE/.none.test.only diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLE/StrandtestArduinoBLE.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLE/StrandtestArduinoBLE.ino new file mode 100644 index 0000000..80e02d2 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLE/StrandtestArduinoBLE.ino @@ -0,0 +1,231 @@ +/**************************************************************************** + * This example is based on StrandtestBLE example and adapts it to use + * the new ArduinoBLE library. + * + * https://github.com/arduino-libraries/ArduinoBLE + * + * Supported boards: + * Arduino MKR WiFi 1010, Arduino Uno WiFi Rev2 board, Arduino Nano 33 IoT, + Arduino Nano 33 BLE, or Arduino Nano 33 BLE Sense board. + * + * You can use a generic BLE central app, like LightBlue (iOS and Android) or + * nRF Connect (Android), to interact with the services and characteristics + * created in this sketch. + * + * This example code is in the public domain. + * + */ +#include <Adafruit_NeoPixel.h> + +#define PIN 15 // Pin where NeoPixels are connected + +// Declare our NeoPixel strip object: +Adafruit_NeoPixel strip(64, PIN, NEO_GRB + NEO_KHZ800); +// Argument 1 = Number of pixels in NeoPixel strip +// Argument 2 = Arduino pin number (most are valid) +// Argument 3 = Pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + +// NEOPIXEL BEST PRACTICES for most reliable operation: +// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. +// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. +// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. +// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS +// connect GROUND (-) first, then +, then data. +// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, +// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. +// (Skipping these may work OK on your workbench but can fail in the field) + +uint8_t rgb_values[3]; + +#include <ArduinoBLE.h> + +BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service + +// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central +BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite); + +void setup() +{ + Serial.begin(115200); + Serial.println("Hello World!"); + + // custom services and characteristics can be added as well + // begin initialization + if (!BLE.begin()) + { + Serial.println("starting BLE failed!"); + + while (1) + ; + } + + Serial.print("Peripheral address: "); + Serial.println(BLE.address()); + + // set advertised local name and service UUID: + BLE.setLocalName("LED"); + BLE.setAdvertisedService(ledService); + + // add the characteristic to the service + ledService.addCharacteristic(switchCharacteristic); + + // add service + BLE.addService(ledService); + + // set the initial value for the characeristic: + switchCharacteristic.writeValue(0); + + // start advertising + BLE.advertise(); + + strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) + strip.show(); // Turn OFF all pixels ASAP + + pinMode(PIN, OUTPUT); + digitalWrite(PIN, LOW); + +} + +void loop() +{ + BLEDevice central = BLE.central(); + + // if a central is connected to peripheral: + if (central) + { + Serial.print("Connected to central: "); + // print the central's MAC address: + Serial.println(central.address()); + + // while the central is still connected to peripheral: + while (central.connected()) + { + // if the remote device wrote to the characteristic, + // use the value to control the LED: + if (switchCharacteristic.written()) + { + switch (switchCharacteristic.value()) + { + case 'a': + colorWipe(strip.Color(255, 0, 0), 20); // Red + break; + case 'b': + colorWipe(strip.Color(0, 255, 0), 20); // Green + break; + case 'c': + colorWipe(strip.Color(0, 0, 255), 20); // Blue + break; + case 'd': + theaterChase(strip.Color(255, 0, 0), 20); // Red + break; + case 'e': + theaterChase(strip.Color(0, 255, 0), 20); // Green + break; + case 'f': + theaterChase(strip.Color(255, 0, 255), 20); // Cyan + break; + case 'g': + rainbow(10); + break; + case 'h': + theaterChaseRainbow(20); + break; + } + } + } + } +} + +// Fill strip pixels one after another with a color. Strip is NOT cleared +// first; anything there will be covered pixel by pixel. Pass in color +// (as a single 'packed' 32-bit value, which you can get by calling +// strip.Color(red, green, blue) as shown in the loop() function above), +// and a delay time (in milliseconds) between pixels. +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 + } +} + +// Theater-marquee-style chasing lights. Pass in a color (32-bit value, +// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms) +// between frames. +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 + } + } +} + +// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. +void rainbow(int wait) +{ + // Hue of first pixel runs 5 complete loops through the color wheel. + // Color wheel has a range of 65536 but it's OK if we roll over, so + // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time + // means we'll make 5*65536/256 = 1280 passes through this outer loop: + for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) + { + for (int i = 0; i < strip.numPixels(); i++) + { // For each pixel in strip... + // Offset pixel hue by an amount to make one full revolution of the + // color wheel (range of 65536) along the length of the strip + // (strip.numPixels() steps): + int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); + // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or + // optionally add saturation and value (brightness) (each 0 to 255). + // Here we're using just the single-argument hue variant. The result + // is passed through strip.gamma32() to provide 'truer' colors + // before assigning to each pixel: + strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue))); + } + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + } +} + +// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames. +void theaterChaseRainbow(int wait) +{ + int firstPixelHue = 0; // First pixel starts at red (hue 0) + for (int a = 0; a < 30; a++) + { // Repeat 30 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 increments of 3... + for (int c = b; c < strip.numPixels(); c += 3) + { + // hue of pixel 'c' is offset by an amount to make one full + // revolution of the color wheel (range 65536) along the length + // of the strip (strip.numPixels() steps): + int hue = firstPixelHue + c * 65536L / strip.numPixels(); + uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB + strip.setPixelColor(c, color); // Set pixel 'c' to value 'color' + } + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames + } + } +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/.none.test.only b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/.none.test.only new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/.none.test.only diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/StrandtestArduinoBLECallback.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/StrandtestArduinoBLECallback.ino new file mode 100644 index 0000000..b986943 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestArduinoBLECallback/StrandtestArduinoBLECallback.ino @@ -0,0 +1,239 @@ +/**************************************************************************** + * This example is based on StrandtestArduinoBLE example to make use of + * callbacks features of the ArduinoBLE library. + * + * https://github.com/arduino-libraries/ArduinoBLE + * + * Supported boards: + * Arduino MKR WiFi 1010, Arduino Uno WiFi Rev2 board, Arduino Nano 33 IoT, + Arduino Nano 33 BLE, or Arduino Nano 33 BLE Sense board. + * + * You can use a generic BLE central app, like LightBlue (iOS and Android) or + * nRF Connect (Android), to interact with the services and characteristics + * created in this sketch. + * + * This example code is in the public domain. + * + */ +#include <Adafruit_NeoPixel.h> + +#define PIN 15 // Pin where NeoPixels are connected + +// Declare our NeoPixel strip object: +Adafruit_NeoPixel strip(64, PIN, NEO_GRB + NEO_KHZ800); +// Argument 1 = Number of pixels in NeoPixel strip +// Argument 2 = Arduino pin number (most are valid) +// Argument 3 = Pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + +// NEOPIXEL BEST PRACTICES for most reliable operation: +// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. +// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. +// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. +// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS +// connect GROUND (-) first, then +, then data. +// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, +// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. +// (Skipping these may work OK on your workbench but can fail in the field) + +uint8_t rgb_values[3]; + +#include <ArduinoBLE.h> + +BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service + +// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central +BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite); + +void setup() +{ + Serial.begin(115200); + Serial.println("Hello World!"); + + // custom services and characteristics can be added as well + // begin initialization + if (!BLE.begin()) + { + Serial.println("starting BLE failed!"); + + while (1) + ; + } + + Serial.print("Peripheral address: "); + Serial.println(BLE.address()); + + // set advertised local name and service UUID: + BLE.setLocalName("LEDCallback"); + BLE.setAdvertisedService(ledService); + + // add the characteristic to the service + ledService.addCharacteristic(switchCharacteristic); + + // add service + BLE.addService(ledService); + // assign event handlers for connected, disconnected to peripheral + BLE.setEventHandler(BLEConnected, blePeripheralConnectHandler); + BLE.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler); + + // assign event handlers for characteristic + switchCharacteristic.setEventHandler(BLEWritten, switchCharacteristicWritten); + // set the initial value for the characeristic: + switchCharacteristic.writeValue(0); + + // start advertising + BLE.advertise(); + + strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) + strip.show(); // Turn OFF all pixels ASAP + + pinMode(PIN, OUTPUT); + digitalWrite(PIN, LOW); +} + +void loop() +{ + // poll for BLE events + BLE.poll(); +} + +void blePeripheralConnectHandler(BLEDevice central) +{ + // central connected event handler + Serial.print("Connected event, central: "); + Serial.println(central.address()); +} + +void blePeripheralDisconnectHandler(BLEDevice central) +{ + // central disconnected event handler + Serial.print("Disconnected event, central: "); + Serial.println(central.address()); +} + +void switchCharacteristicWritten(BLEDevice central, BLECharacteristic characteristic) +{ + // central wrote new value to characteristic, update LED + Serial.print("Characteristic event, written: "); + + switch (switchCharacteristic.value()) + { + case 'a': + colorWipe(strip.Color(255, 0, 0), 20); // Red + break; + case 'b': + colorWipe(strip.Color(0, 255, 0), 20); // Green + break; + case 'c': + colorWipe(strip.Color(0, 0, 255), 20); // Blue + break; + case 'd': + theaterChase(strip.Color(255, 0, 0), 20); // Red + break; + case 'e': + theaterChase(strip.Color(0, 255, 0), 20); // Green + break; + case 'f': + theaterChase(strip.Color(255, 0, 255), 20); // Cyan + break; + case 'g': + rainbow(10); + break; + case 'h': + theaterChaseRainbow(20); + break; + } +} + +// Fill strip pixels one after another with a color. Strip is NOT cleared +// first; anything there will be covered pixel by pixel. Pass in color +// (as a single 'packed' 32-bit value, which you can get by calling +// strip.Color(red, green, blue) as shown in the loop() function above), +// and a delay time (in milliseconds) between pixels. +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 + } +} + +// Theater-marquee-style chasing lights. Pass in a color (32-bit value, +// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms) +// between frames. +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 + } + } +} + +// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. +void rainbow(int wait) +{ + // Hue of first pixel runs 5 complete loops through the color wheel. + // Color wheel has a range of 65536 but it's OK if we roll over, so + // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time + // means we'll make 5*65536/256 = 1280 passes through this outer loop: + for (long firstPixelHue = 0; firstPixelHue < 5 * 65536; firstPixelHue += 256) + { + for (int i = 0; i < strip.numPixels(); i++) + { // For each pixel in strip... + // Offset pixel hue by an amount to make one full revolution of the + // color wheel (range of 65536) along the length of the strip + // (strip.numPixels() steps): + int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); + // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or + // optionally add saturation and value (brightness) (each 0 to 255). + // Here we're using just the single-argument hue variant. The result + // is passed through strip.gamma32() to provide 'truer' colors + // before assigning to each pixel: + strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue))); + } + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + } +} + +// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames. +void theaterChaseRainbow(int wait) +{ + int firstPixelHue = 0; // First pixel starts at red (hue 0) + for (int a = 0; a < 30; a++) + { // Repeat 30 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 increments of 3... + for (int c = b; c < strip.numPixels(); c += 3) + { + // hue of pixel 'c' is offset by an amount to make one full + // revolution of the color wheel (range 65536) along the length + // of the strip (strip.numPixels() steps): + int hue = firstPixelHue + c * 65536L / strip.numPixels(); + uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB + strip.setPixelColor(c, color); // Set pixel 'c' to value 'color' + } + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames + } + } +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/.none.test.only b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/.none.test.only new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/.none.test.only diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.cpp b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.cpp new file mode 100644 index 0000000..20d2a0c --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.cpp @@ -0,0 +1,141 @@ +#include "BLESerial.h" + +// #define BLE_SERIAL_DEBUG + +BLESerial *BLESerial::_instance = NULL; + +BLESerial::BLESerial(unsigned char req, unsigned char rdy, unsigned char rst) + : BLEPeripheral(req, rdy, rst) { + this->_txCount = 0; + this->_rxHead = this->_rxTail = 0; + this->_flushed = 0; + BLESerial::_instance = this; + + addAttribute(this->_uartService); + addAttribute(this->_uartNameDescriptor); + setAdvertisedServiceUuid(this->_uartService.uuid()); + addAttribute(this->_rxCharacteristic); + addAttribute(this->_rxNameDescriptor); + this->_rxCharacteristic.setEventHandler(BLEWritten, BLESerial::_received); + addAttribute(this->_txCharacteristic); + addAttribute(this->_txNameDescriptor); +} + +void BLESerial::begin(...) { + BLEPeripheral::begin(); +#ifdef BLE_SERIAL_DEBUG + Serial.println(F("BLESerial::begin()")); +#endif +} + +void BLESerial::poll() { + if (millis() < this->_flushed + 100) { + BLEPeripheral::poll(); + } else { + flush(); + } +} + +void BLESerial::end() { + this->_rxCharacteristic.setEventHandler(BLEWritten, NULL); + this->_rxHead = this->_rxTail = 0; + flush(); + BLEPeripheral::disconnect(); +} + +int BLESerial::available(void) { + BLEPeripheral::poll(); + int retval = (this->_rxHead - this->_rxTail + sizeof(this->_rxBuffer)) % + sizeof(this->_rxBuffer); +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::available() = ")); + Serial.println(retval); +#endif + return retval; +} + +int BLESerial::peek(void) { + BLEPeripheral::poll(); + if (this->_rxTail == this->_rxHead) + return -1; + uint8_t byte = this->_rxBuffer[this->_rxTail]; +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::peek() = ")); + Serial.print((char)byte); + Serial.print(F(" 0x")); + Serial.println(byte, HEX); +#endif + return byte; +} + +int BLESerial::read(void) { + BLEPeripheral::poll(); + if (this->_rxTail == this->_rxHead) + return -1; + this->_rxTail = (this->_rxTail + 1) % sizeof(this->_rxBuffer); + uint8_t byte = this->_rxBuffer[this->_rxTail]; +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::read() = ")); + Serial.print((char)byte); + Serial.print(F(" 0x")); + Serial.println(byte, HEX); +#endif + return byte; +} + +void BLESerial::flush(void) { + if (this->_txCount == 0) + return; + this->_txCharacteristic.setValue(this->_txBuffer, this->_txCount); + this->_flushed = millis(); + this->_txCount = 0; + BLEPeripheral::poll(); +#ifdef BLE_SERIAL_DEBUG + Serial.println(F("BLESerial::flush()")); +#endif +} + +size_t BLESerial::write(uint8_t byte) { + BLEPeripheral::poll(); + if (this->_txCharacteristic.subscribed() == false) + return 0; + this->_txBuffer[this->_txCount++] = byte; + if (this->_txCount == sizeof(this->_txBuffer)) + flush(); +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::write(")); + Serial.print((char)byte); + Serial.print(F(" 0x")); + Serial.print(byte, HEX); + Serial.println(F(") = 1")); +#endif + return 1; +} + +BLESerial::operator bool() { + bool retval = BLEPeripheral::connected(); +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::operator bool() = ")); + Serial.println(retval); +#endif + return retval; +} + +void BLESerial::_received(const uint8_t *data, size_t size) { + for (int i = 0; i < size; i++) { + this->_rxHead = (this->_rxHead + 1) % sizeof(this->_rxBuffer); + this->_rxBuffer[this->_rxHead] = data[i]; + } +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::received(")); + for (int i = 0; i < size; i++) + Serial.print((char)data[i]); + Serial.println(F(")")); +#endif +} + +void BLESerial::_received(BLECentral & /*central*/, + BLECharacteristic &rxCharacteristic) { + BLESerial::_instance->_received(rxCharacteristic.value(), + rxCharacteristic.valueLength()); +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.h b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.h new file mode 100644 index 0000000..950bfb0 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/BLESerial.h @@ -0,0 +1,53 @@ +#ifndef _BLE_SERIAL_H_ +#define _BLE_SERIAL_H_ + +#include <Arduino.h> +#include <BLEPeripheral.h> + +class BLESerial : public BLEPeripheral, public Stream { + public: + BLESerial(unsigned char req, unsigned char rdy, unsigned char rst); + + void begin(...); + void poll(); + void end(); + + virtual int available(void); + virtual int peek(void); + virtual int read(void); + virtual void flush(void); + virtual size_t write(uint8_t byte); + using Print::write; + virtual operator bool(); + + private: + unsigned long _flushed; + static BLESerial *_instance; + + size_t _rxHead; + size_t _rxTail; + size_t _rxCount() const; + uint8_t _rxBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; + size_t _txCount; + uint8_t _txBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; + + BLEService _uartService = + BLEService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"); + BLEDescriptor _uartNameDescriptor = BLEDescriptor("2901", "UART"); + BLECharacteristic _rxCharacteristic = BLECharacteristic( + "6E400002-B5A3-F393-E0A9-E50E24DCCA9E", BLEWriteWithoutResponse, + BLE_ATTRIBUTE_MAX_VALUE_LENGTH); + BLEDescriptor _rxNameDescriptor = + BLEDescriptor("2901", "RX - Receive Data (Write)"); + BLECharacteristic _txCharacteristic = + BLECharacteristic("6E400003-B5A3-F393-E0A9-E50E24DCCA9E", BLENotify, + BLE_ATTRIBUTE_MAX_VALUE_LENGTH); + BLEDescriptor _txNameDescriptor = + BLEDescriptor("2901", "TX - Transfer Data (Notify)"); + + void _received(const uint8_t *data, size_t size); + static void _received(BLECentral & /*central*/, + BLECharacteristic &rxCharacteristic); +}; + +#endif diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/StrandtestBLE.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/StrandtestBLE.ino new file mode 100644 index 0000000..593b35b --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE/StrandtestBLE.ino @@ -0,0 +1,192 @@ +/**************************************************************************** + * This example was developed by the Hackerspace San Salvador to demonstrate + * the simultaneous use of the NeoPixel library and the Bluetooth SoftDevice. + * To compile this example you'll need to add support for the NRF52 based + * following the instructions at: + * https://github.com/sandeepmistry/arduino-nRF5 + * Or adding the following URL to the board manager URLs on Arduino preferences: + * https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json + * Then you can install the BLEPeripheral library avaiable at: + * https://github.com/sandeepmistry/arduino-BLEPeripheral + * To test it, compile this example and use the UART module from the nRF + * Toolbox App for Android. Edit the interface and send the characters + * 'a' to 'i' to switch the animation. + * There is a delay because this example blocks the thread of execution but + * the change will be shown after the current animation ends. (This might + * take a couple of seconds) + * For more info write us at: info _at- teubi.co + */ +#include <SPI.h> +#include <BLEPeripheral.h> +#include "BLESerial.h" +#include <Adafruit_NeoPixel.h> + +#define PIN 15 // Pin where NeoPixels are connected + +// Declare our NeoPixel strip object: +Adafruit_NeoPixel strip(64, PIN, NEO_GRB + NEO_KHZ800); +// Argument 1 = Number of pixels in NeoPixel strip +// Argument 2 = Arduino pin number (most are valid) +// Argument 3 = Pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + +// NEOPIXEL BEST PRACTICES for most reliable operation: +// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. +// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. +// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. +// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS +// connect GROUND (-) first, then +, then data. +// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, +// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. +// (Skipping these may work OK on your workbench but can fail in the field) + +// define pins (varies per shield/board) +#define BLE_REQ 10 +#define BLE_RDY 2 +#define BLE_RST 9 + +// create ble serial instance, see pinouts above +BLESerial BLESerial(BLE_REQ, BLE_RDY, BLE_RST); + +uint8_t current_state = 0; +uint8_t rgb_values[3]; + +void setup() { + Serial.begin(115200); + Serial.println("Hello World!"); + // custom services and characteristics can be added as well + BLESerial.setLocalName("UART_HS"); + BLESerial.begin(); + + strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) + strip.show(); // Turn OFF all pixels ASAP + + //pinMode(PIN, OUTPUT); + //digitalWrite(PIN, LOW); + + current_state = 'a'; +} + +void loop() { + while(BLESerial.available()) { + uint8_t character = BLESerial.read(); + switch(character) { + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + current_state = character; + break; + }; + } + switch(current_state) { + case 'a': + colorWipe(strip.Color(255, 0, 0), 20); // Red + break; + case 'b': + colorWipe(strip.Color( 0, 255, 0), 20); // Green + break; + case 'c': + colorWipe(strip.Color( 0, 0, 255), 20); // Blue + break; + case 'd': + theaterChase(strip.Color(255, 0, 0), 20); // Red + break; + case 'e': + theaterChase(strip.Color( 0, 255, 0), 20); // Green + break; + case 'f': + theaterChase(strip.Color(255, 0, 255), 20); // Cyan + break; + case 'g': + rainbow(10); + break; + case 'h': + theaterChaseRainbow(20); + break; + } +} + +// Fill strip pixels one after another with a color. Strip is NOT cleared +// first; anything there will be covered pixel by pixel. Pass in color +// (as a single 'packed' 32-bit value, which you can get by calling +// strip.Color(red, green, blue) as shown in the loop() function above), +// and a delay time (in milliseconds) between pixels. +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 + } +} + +// Theater-marquee-style chasing lights. Pass in a color (32-bit value, +// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms) +// between frames. +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 + } + } +} + +// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. +void rainbow(int wait) { + // Hue of first pixel runs 5 complete loops through the color wheel. + // Color wheel has a range of 65536 but it's OK if we roll over, so + // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time + // means we'll make 5*65536/256 = 1280 passes through this outer loop: + for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { + for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip... + // Offset pixel hue by an amount to make one full revolution of the + // color wheel (range of 65536) along the length of the strip + // (strip.numPixels() steps): + int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); + // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or + // optionally add saturation and value (brightness) (each 0 to 255). + // Here we're using just the single-argument hue variant. The result + // is passed through strip.gamma32() to provide 'truer' colors + // before assigning to each pixel: + strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue))); + } + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + } +} + +// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames. +void theaterChaseRainbow(int wait) { + int firstPixelHue = 0; // First pixel starts at red (hue 0) + for(int a=0; a<30; a++) { // Repeat 30 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 increments of 3... + for(int c=b; c<strip.numPixels(); c += 3) { + // hue of pixel 'c' is offset by an amount to make one full + // revolution of the color wheel (range 65536) along the length + // of the strip (strip.numPixels() steps): + int hue = firstPixelHue + c * 65536L / strip.numPixels(); + uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB + strip.setPixelColor(c, color); // Set pixel 'c' to value 'color' + } + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames + } + } +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/.none.test.only b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/.none.test.only new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/.none.test.only @@ -0,0 +1 @@ + diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.cpp b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.cpp new file mode 100644 index 0000000..20d2a0c --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.cpp @@ -0,0 +1,141 @@ +#include "BLESerial.h" + +// #define BLE_SERIAL_DEBUG + +BLESerial *BLESerial::_instance = NULL; + +BLESerial::BLESerial(unsigned char req, unsigned char rdy, unsigned char rst) + : BLEPeripheral(req, rdy, rst) { + this->_txCount = 0; + this->_rxHead = this->_rxTail = 0; + this->_flushed = 0; + BLESerial::_instance = this; + + addAttribute(this->_uartService); + addAttribute(this->_uartNameDescriptor); + setAdvertisedServiceUuid(this->_uartService.uuid()); + addAttribute(this->_rxCharacteristic); + addAttribute(this->_rxNameDescriptor); + this->_rxCharacteristic.setEventHandler(BLEWritten, BLESerial::_received); + addAttribute(this->_txCharacteristic); + addAttribute(this->_txNameDescriptor); +} + +void BLESerial::begin(...) { + BLEPeripheral::begin(); +#ifdef BLE_SERIAL_DEBUG + Serial.println(F("BLESerial::begin()")); +#endif +} + +void BLESerial::poll() { + if (millis() < this->_flushed + 100) { + BLEPeripheral::poll(); + } else { + flush(); + } +} + +void BLESerial::end() { + this->_rxCharacteristic.setEventHandler(BLEWritten, NULL); + this->_rxHead = this->_rxTail = 0; + flush(); + BLEPeripheral::disconnect(); +} + +int BLESerial::available(void) { + BLEPeripheral::poll(); + int retval = (this->_rxHead - this->_rxTail + sizeof(this->_rxBuffer)) % + sizeof(this->_rxBuffer); +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::available() = ")); + Serial.println(retval); +#endif + return retval; +} + +int BLESerial::peek(void) { + BLEPeripheral::poll(); + if (this->_rxTail == this->_rxHead) + return -1; + uint8_t byte = this->_rxBuffer[this->_rxTail]; +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::peek() = ")); + Serial.print((char)byte); + Serial.print(F(" 0x")); + Serial.println(byte, HEX); +#endif + return byte; +} + +int BLESerial::read(void) { + BLEPeripheral::poll(); + if (this->_rxTail == this->_rxHead) + return -1; + this->_rxTail = (this->_rxTail + 1) % sizeof(this->_rxBuffer); + uint8_t byte = this->_rxBuffer[this->_rxTail]; +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::read() = ")); + Serial.print((char)byte); + Serial.print(F(" 0x")); + Serial.println(byte, HEX); +#endif + return byte; +} + +void BLESerial::flush(void) { + if (this->_txCount == 0) + return; + this->_txCharacteristic.setValue(this->_txBuffer, this->_txCount); + this->_flushed = millis(); + this->_txCount = 0; + BLEPeripheral::poll(); +#ifdef BLE_SERIAL_DEBUG + Serial.println(F("BLESerial::flush()")); +#endif +} + +size_t BLESerial::write(uint8_t byte) { + BLEPeripheral::poll(); + if (this->_txCharacteristic.subscribed() == false) + return 0; + this->_txBuffer[this->_txCount++] = byte; + if (this->_txCount == sizeof(this->_txBuffer)) + flush(); +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::write(")); + Serial.print((char)byte); + Serial.print(F(" 0x")); + Serial.print(byte, HEX); + Serial.println(F(") = 1")); +#endif + return 1; +} + +BLESerial::operator bool() { + bool retval = BLEPeripheral::connected(); +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::operator bool() = ")); + Serial.println(retval); +#endif + return retval; +} + +void BLESerial::_received(const uint8_t *data, size_t size) { + for (int i = 0; i < size; i++) { + this->_rxHead = (this->_rxHead + 1) % sizeof(this->_rxBuffer); + this->_rxBuffer[this->_rxHead] = data[i]; + } +#ifdef BLE_SERIAL_DEBUG + Serial.print(F("BLESerial::received(")); + for (int i = 0; i < size; i++) + Serial.print((char)data[i]); + Serial.println(F(")")); +#endif +} + +void BLESerial::_received(BLECentral & /*central*/, + BLECharacteristic &rxCharacteristic) { + BLESerial::_instance->_received(rxCharacteristic.value(), + rxCharacteristic.valueLength()); +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.h b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.h new file mode 100644 index 0000000..950bfb0 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/BLESerial.h @@ -0,0 +1,53 @@ +#ifndef _BLE_SERIAL_H_ +#define _BLE_SERIAL_H_ + +#include <Arduino.h> +#include <BLEPeripheral.h> + +class BLESerial : public BLEPeripheral, public Stream { + public: + BLESerial(unsigned char req, unsigned char rdy, unsigned char rst); + + void begin(...); + void poll(); + void end(); + + virtual int available(void); + virtual int peek(void); + virtual int read(void); + virtual void flush(void); + virtual size_t write(uint8_t byte); + using Print::write; + virtual operator bool(); + + private: + unsigned long _flushed; + static BLESerial *_instance; + + size_t _rxHead; + size_t _rxTail; + size_t _rxCount() const; + uint8_t _rxBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; + size_t _txCount; + uint8_t _txBuffer[BLE_ATTRIBUTE_MAX_VALUE_LENGTH]; + + BLEService _uartService = + BLEService("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"); + BLEDescriptor _uartNameDescriptor = BLEDescriptor("2901", "UART"); + BLECharacteristic _rxCharacteristic = BLECharacteristic( + "6E400002-B5A3-F393-E0A9-E50E24DCCA9E", BLEWriteWithoutResponse, + BLE_ATTRIBUTE_MAX_VALUE_LENGTH); + BLEDescriptor _rxNameDescriptor = + BLEDescriptor("2901", "RX - Receive Data (Write)"); + BLECharacteristic _txCharacteristic = + BLECharacteristic("6E400003-B5A3-F393-E0A9-E50E24DCCA9E", BLENotify, + BLE_ATTRIBUTE_MAX_VALUE_LENGTH); + BLEDescriptor _txNameDescriptor = + BLEDescriptor("2901", "TX - Transfer Data (Notify)"); + + void _received(const uint8_t *data, size_t size); + static void _received(BLECentral & /*central*/, + BLECharacteristic &rxCharacteristic); +}; + +#endif diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/StrandtestBLE_nodelay.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/StrandtestBLE_nodelay.ino new file mode 100644 index 0000000..20c924d --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/StrandtestBLE_nodelay/StrandtestBLE_nodelay.ino @@ -0,0 +1,198 @@ +/**************************************************************************** + * This example was developed by the Hackerspace San Salvador to demonstrate + * the simultaneous use of the NeoPixel library and the Bluetooth SoftDevice. + * To compile this example you'll need to add support for the NRF52 based + * following the instructions at: + * https://github.com/sandeepmistry/arduino-nRF5 + * Or adding the following URL to the board manager URLs on Arduino preferences: + * https://sandeepmistry.github.io/arduino-nRF5/package_nRF5_boards_index.json + * Then you can install the BLEPeripheral library avaiable at: + * https://github.com/sandeepmistry/arduino-BLEPeripheral + * To test it, compile this example and use the UART module from the nRF + * Toolbox App for Android. Edit the interface and send the characters + * 'a' to 'i' to switch the animation. + * There is a no delay because this example does not block the threads execution + * so the change will be shown immediately and will not need to wait for the current + * animation to end. + * For more info write us at: info _at- teubi.co + */ +#include <SPI.h> +#include <BLEPeripheral.h> +#include "BLESerial.h" +#include <Adafruit_NeoPixel.h> + +#define PIN 15 // Pin where NeoPixels are connected + +// Declare our NeoPixel strip object: +Adafruit_NeoPixel strip(64, PIN, NEO_GRB + NEO_KHZ800); +// Argument 1 = Number of pixels in NeoPixel strip +// Argument 2 = Arduino pin number (most are valid) +// Argument 3 = Pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + +// NEOPIXEL BEST PRACTICES for most reliable operation: +// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. +// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. +// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. +// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS +// connect GROUND (-) first, then +, then data. +// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, +// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. +// (Skipping these may work OK on your workbench but can fail in the field) + +// define pins (varies per shield/board) +#define BLE_REQ 10 +#define BLE_RDY 2 +#define BLE_RST 9 + +// create ble serial instance, see pinouts above +BLESerial BLESerial(BLE_REQ, BLE_RDY, BLE_RST); + +uint8_t current_state = 0; +uint8_t rgb_values[3]; + +void setup() { + Serial.begin(115200); + Serial.println("Hello World!"); + // custom services and characteristics can be added as well + BLESerial.setLocalName("UART_HS"); + BLESerial.begin(); + + strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) + strip.show(); // Turn OFF all pixels ASAP + + //pinMode(PIN, OUTPUT); + //digitalWrite(PIN, LOW); + + current_state = 'a'; +} + +void loop() { + while(BLESerial.available()) { + uint8_t character = BLESerial.read(); + switch(character) { + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + current_state = character; + break; + }; + } + switch(current_state) { + case 'a': + colorWipe(strip.Color(255, 0, 0), 20); // Red + break; + case 'b': + colorWipe(strip.Color( 0, 255, 0), 20); // Green + break; + case 'c': + colorWipe(strip.Color( 0, 0, 255), 20); // Blue + break; + case 'd': + theaterChase(strip.Color(255, 0, 0), 20); // Red + break; + case 'e': + theaterChase(strip.Color( 0, 255, 0), 20); // Green + break; + case 'f': + theaterChase(strip.Color(255, 0, 255), 20); // Cyan + break; + case 'g': + rainbow(10); + break; + case 'h': + theaterChaseRainbow(20); + break; + } +} + +// Some functions of our own for creating animated effects ----------------- + +// Fill strip pixels one after another with a color. Strip is NOT cleared +// first; anything there will be covered pixel by pixel. Pass in color +// (as a single 'packed' 32-bit value, which you can get by calling +// strip.Color(red, green, blue) as shown in the loop() function above), +// and a delay time (in milliseconds) between pixels. +void colorWipe(uint32_t color, int wait) { + if(pixelInterval != wait) + pixelInterval = wait; // Update delay time + strip.setPixelColor(pixelCurrent, color); // Set pixel's color (in RAM) + strip.show(); // Update strip to match + pixelCurrent++; // Advance current pixel + if(pixelCurrent >= pixelNumber) // Loop the pattern from the first LED + pixelCurrent = 0; +} + +// Theater-marquee-style chasing lights. Pass in a color (32-bit value, +// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms) +// between frames. +void theaterChase(uint32_t color, int wait) { + if(pixelInterval != wait) + pixelInterval = wait; // Update delay time + for(int i = 0; i < pixelNumber; i++) { + strip.setPixelColor(i + pixelQueue, color); // Set pixel's color (in RAM) + } + strip.show(); // Update strip to match + for(int i=0; i < pixelNumber; i+3) { + strip.setPixelColor(i + pixelQueue, strip.Color(0, 0, 0)); // Set pixel's color (in RAM) + } + pixelQueue++; // Advance current pixel + if(pixelQueue >= 3) + pixelQueue = 0; // Loop the pattern from the first LED +} + +// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. +void rainbow(uint8_t wait) { + if(pixelInterval != wait) + pixelInterval = wait; + for(uint16_t i=0; i < pixelNumber; i++) { + strip.setPixelColor(i, Wheel((i + pixelCycle) & 255)); // Update delay time + } + strip.show(); // Update strip to match + pixelCycle++; // Advance current cycle + if(pixelCycle >= 256) + pixelCycle = 0; // Loop the cycle back to the begining +} + +//Theatre-style crawling lights with rainbow effect +void theaterChaseRainbow(uint8_t wait) { + if(pixelInterval != wait) + pixelInterval = wait; // Update delay time + for(int i=0; i < pixelNumber; i+3) { + strip.setPixelColor(i + pixelQueue, Wheel((i + pixelCycle) % 255)); // Update delay time + } + strip.show(); + for(int i=0; i < pixelNumber; i+3) { + strip.setPixelColor(i + pixelQueue, strip.Color(0, 0, 0)); // Update delay time + } + pixelQueue++; // Advance current queue + pixelCycle++; // Advance current cycle + if(pixelQueue >= 3) + pixelQueue = 0; // Loop + if(pixelCycle >= 256) + pixelCycle = 0; // Loop +} + +// Input a value 0 to 255 to get a color value. +// The colours are a transition r - g - b - back to r. +uint32_t Wheel(byte WheelPos) { + WheelPos = 255 - WheelPos; + if(WheelPos < 85) { + return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); + } + if(WheelPos < 170) { + WheelPos -= 85; + return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); + } + WheelPos -= 170; + return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/buttoncycler/.esp8266.test.skip b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/buttoncycler/.esp8266.test.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/buttoncycler/.esp8266.test.skip diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/buttoncycler/buttoncycler.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/buttoncycler/buttoncycler.ino new file mode 100644 index 0000000..f6d87ed --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/buttoncycler/buttoncycler.ino @@ -0,0 +1,164 @@ +// Simple demonstration on using an input device to trigger changes on your +// NeoPixels. Wire a momentary push button to connect from ground to a +// digital IO pin. When the button is pressed it will change to a new pixel +// animation. Initial state has all pixels off -- press the button once to +// start the first animation. As written, the button does not interrupt an +// animation in-progress, it works only when idle. + +#include <Adafruit_NeoPixel.h> +#ifdef __AVR__ + #include <avr/power.h> // Required for 16 MHz Adafruit Trinket +#endif + +// Digital IO pin connected to the button. This will be driven with a +// pull-up resistor so the switch pulls the pin to ground momentarily. +// On a high -> low transition the button press logic will execute. +#define BUTTON_PIN 2 + +#define PIXEL_PIN 6 // Digital IO pin connected to the NeoPixels. + +#define PIXEL_COUNT 16 // Number of NeoPixels + +// Declare our NeoPixel strip object: +Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800); +// Argument 1 = Number of pixels in NeoPixel strip +// Argument 2 = Arduino pin number (most are valid) +// Argument 3 = Pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + +boolean oldState = HIGH; +int mode = 0; // Currently-active animation mode, 0-9 + +void setup() { + pinMode(BUTTON_PIN, INPUT_PULLUP); + strip.begin(); // Initialize NeoPixel strip object (REQUIRED) + strip.show(); // Initialize all pixels to 'off' +} + +void loop() { + // Get current button state. + boolean newState = digitalRead(BUTTON_PIN); + + // Check if state changed from high to low (button press). + if((newState == LOW) && (oldState == HIGH)) { + // Short delay to debounce button. + delay(20); + // Check if button is still low after debounce. + newState = digitalRead(BUTTON_PIN); + if(newState == LOW) { // Yes, still low + if(++mode > 8) mode = 0; // Advance to next mode, wrap around after #8 + switch(mode) { // Start the new animation... + case 0: + colorWipe(strip.Color( 0, 0, 0), 50); // Black/off + break; + case 1: + colorWipe(strip.Color(255, 0, 0), 50); // Red + break; + case 2: + colorWipe(strip.Color( 0, 255, 0), 50); // Green + break; + case 3: + colorWipe(strip.Color( 0, 0, 255), 50); // Blue + break; + case 4: + theaterChase(strip.Color(127, 127, 127), 50); // White + break; + case 5: + theaterChase(strip.Color(127, 0, 0), 50); // Red + break; + case 6: + theaterChase(strip.Color( 0, 0, 127), 50); // Blue + break; + case 7: + rainbow(10); + break; + case 8: + theaterChaseRainbow(50); + break; + } + } + } + + // Set the last-read button state to the old state. + oldState = newState; +} + +// Fill strip pixels one after another with a color. Strip is NOT cleared +// first; anything there will be covered pixel by pixel. Pass in color +// (as a single 'packed' 32-bit value, which you can get by calling +// strip.Color(red, green, blue) as shown in the loop() function above), +// and a delay time (in milliseconds) between pixels. +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 + } +} + +// Theater-marquee-style chasing lights. Pass in a color (32-bit value, +// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms) +// between frames. +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 + } + } +} + +// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. +void rainbow(int wait) { + // Hue of first pixel runs 3 complete loops through the color wheel. + // Color wheel has a range of 65536 but it's OK if we roll over, so + // just count from 0 to 3*65536. Adding 256 to firstPixelHue each time + // means we'll make 3*65536/256 = 768 passes through this outer loop: + for(long firstPixelHue = 0; firstPixelHue < 3*65536; firstPixelHue += 256) { + for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip... + // Offset pixel hue by an amount to make one full revolution of the + // color wheel (range of 65536) along the length of the strip + // (strip.numPixels() steps): + int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels()); + // strip.ColorHSV() can take 1 or 3 arguments: a hue (0 to 65535) or + // optionally add saturation and value (brightness) (each 0 to 255). + // Here we're using just the single-argument hue variant. The result + // is passed through strip.gamma32() to provide 'truer' colors + // before assigning to each pixel: + strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue))); + } + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + } +} + +// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames. +void theaterChaseRainbow(int wait) { + int firstPixelHue = 0; // First pixel starts at red (hue 0) + for(int a=0; a<30; a++) { // Repeat 30 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 increments of 3... + for(int c=b; c<strip.numPixels(); c += 3) { + // hue of pixel 'c' is offset by an amount to make one full + // revolution of the color wheel (range 65536) along the length + // of the strip (strip.numPixels() steps): + int hue = firstPixelHue + c * 65536L / strip.numPixels(); + uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB + strip.setPixelColor(c, color); // Set pixel 'c' to value 'color' + } + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames + } + } +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple/.esp8266.test.skip b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple/.esp8266.test.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple/.esp8266.test.skip diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple/simple.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple/simple.ino new file mode 100644 index 0000000..09f458e --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple/simple.ino @@ -0,0 +1,50 @@ +// NeoPixel Ring simple sketch (c) 2013 Shae Erisson +// Released under the GPLv3 license to match the rest of the +// Adafruit NeoPixel library + +#include <Adafruit_NeoPixel.h> +#ifdef __AVR__ + #include <avr/power.h> // Required for 16 MHz Adafruit Trinket +#endif + +// Which pin on the Arduino is connected to the NeoPixels? +#define PIN 6 // On Trinket or Gemma, suggest changing this to 1 + +// How many NeoPixels are attached to the Arduino? +#define NUMPIXELS 16 // Popular NeoPixel ring size + +// When setting up the NeoPixel library, we tell it how many pixels, +// and which pin to use to send signals. Note that for older NeoPixel +// strips you might need to change the third parameter -- see the +// strandtest example for more information on possible values. +Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); + +#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels + +void setup() { + // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. + // Any other board, you can remove this part (but no harm leaving it): +#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) + clock_prescale_set(clock_div_1); +#endif + // END of Trinket-specific code. + + pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) +} + +void loop() { + pixels.clear(); // Set all pixel colors to 'off' + + // The first NeoPixel in a strand is #0, second is 1, all the way up + // to the count of pixels minus one. + for(int i=0; i<NUMPIXELS; i++) { // For each pixel... + + // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255 + // Here we're using a moderately bright green color: + pixels.setPixelColor(i, pixels.Color(0, 150, 0)); + + pixels.show(); // Send the updated pixel colors to the hardware. + + delay(DELAYVAL); // Pause before next pass through loop + } +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple_new_operator/.esp8266.test.skip b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple_new_operator/.esp8266.test.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple_new_operator/.esp8266.test.skip diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple_new_operator/simple_new_operator.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple_new_operator/simple_new_operator.ino new file mode 100644 index 0000000..60e5aa1 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/simple_new_operator/simple_new_operator.ino @@ -0,0 +1,67 @@ +// NeoPixel Ring simple sketch (c) 2013 Shae Erisson +// Released under the GPLv3 license to match the rest of the +// Adafruit NeoPixel library +// This sketch shows use of the "new" operator with Adafruit_NeoPixel. +// It's helpful if you don't know NeoPixel settings at compile time or +// just want to store this settings in EEPROM or a file on an SD card. + +#include <Adafruit_NeoPixel.h> +#ifdef __AVR__ + #include <avr/power.h> // Required for 16 MHz Adafruit Trinket +#endif + +// Which pin on the Arduino is connected to the NeoPixels? +int pin = 6; // On Trinket or Gemma, suggest changing this to 1 + +// How many NeoPixels are attached to the Arduino? +int numPixels = 16; // Popular NeoPixel ring size + +// NeoPixel color format & data rate. See the strandtest example for +// information on possible values. +int pixelFormat = NEO_GRB + NEO_KHZ800; + +// Rather than declaring the whole NeoPixel object here, we just create +// a pointer for one, which we'll then allocate later... +Adafruit_NeoPixel *pixels; + +#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels + +void setup() { + // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. + // Any other board, you can remove this part (but no harm leaving it): +#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) + clock_prescale_set(clock_div_1); +#endif + // END of Trinket-specific code. + + // Right about here is where we could read 'pin', 'numPixels' and/or + // 'pixelFormat' from EEPROM or a file on SD or whatever. This is a simple + // example and doesn't do that -- those variables are just set to fixed + // values at the top of this code -- but this is where it would happen. + + // Then create a new NeoPixel object dynamically with these values: + pixels = new Adafruit_NeoPixel(numPixels, pin, pixelFormat); + + // Going forward from here, code works almost identically to any other + // NeoPixel example, but instead of the dot operator on function calls + // (e.g. pixels.begin()), we instead use pointer indirection (->) like so: + pixels->begin(); // INITIALIZE NeoPixel strip object (REQUIRED) + // You'll see more of this in the loop() function below. +} + +void loop() { + pixels->clear(); // Set all pixel colors to 'off' + + // The first NeoPixel in a strand is #0, second is 1, all the way up + // to the count of pixels minus one. + for(int i=0; i<numPixels; i++) { // For each pixel... + + // pixels->Color() takes RGB values, from 0,0,0 up to 255,255,255 + // Here we're using a moderately bright green color: + pixels->setPixelColor(i, pixels->Color(0, 150, 0)); + + pixels->show(); // Send the updated pixel colors to the hardware. + + delay(DELAYVAL); // Pause before next pass through loop + } +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest/.esp8266.test.skip b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest/.esp8266.test.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest/.esp8266.test.skip diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest/strandtest.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest/strandtest.ino new file mode 100644 index 0000000..f4554cc --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest/strandtest.ino @@ -0,0 +1,143 @@ +// A basic everyday NeoPixel strip test program. + +// NEOPIXEL BEST PRACTICES for most reliable operation: +// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. +// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. +// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. +// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS +// connect GROUND (-) first, then +, then data. +// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, +// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. +// (Skipping these may work OK on your workbench but can fail in the field) + +#include <Adafruit_NeoPixel.h> +#ifdef __AVR__ + #include <avr/power.h> // Required for 16 MHz Adafruit Trinket +#endif + +// Which pin on the Arduino is connected to the NeoPixels? +// On a Trinket or Gemma we suggest changing this to 1: +#define LED_PIN 6 + +// How many NeoPixels are attached to the Arduino? +#define LED_COUNT 60 + +// Declare our NeoPixel strip object: +Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); +// Argument 1 = Number of pixels in NeoPixel strip +// Argument 2 = Arduino pin number (most are valid) +// Argument 3 = Pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + + +// setup() function -- runs once at startup -------------------------------- + +void setup() { + // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. + // Any other board, you can remove this part (but no harm leaving it): +#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) + clock_prescale_set(clock_div_1); +#endif + // END of Trinket-specific code. + + 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) +} + + +// loop() function -- runs repeatedly as long as board is on --------------- + +void loop() { + // Fill along the length of the strip in various colors... + colorWipe(strip.Color(255, 0, 0), 50); // Red + colorWipe(strip.Color( 0, 255, 0), 50); // Green + colorWipe(strip.Color( 0, 0, 255), 50); // Blue + + // Do a theater marquee effect in various colors... + theaterChase(strip.Color(127, 127, 127), 50); // White, half brightness + theaterChase(strip.Color(127, 0, 0), 50); // Red, half brightness + theaterChase(strip.Color( 0, 0, 127), 50); // Blue, half brightness + + rainbow(10); // Flowing rainbow cycle along the whole strip + theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant +} + + +// Some functions of our own for creating animated effects ----------------- + +// Fill strip pixels one after another with a color. Strip is NOT cleared +// first; anything there will be covered pixel by pixel. Pass in color +// (as a single 'packed' 32-bit value, which you can get by calling +// strip.Color(red, green, blue) as shown in the loop() function above), +// and a delay time (in milliseconds) between pixels. +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 + } +} + +// Theater-marquee-style chasing lights. Pass in a color (32-bit value, +// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms) +// between frames. +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 + } + } +} + +// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. +void rainbow(int wait) { + // Hue of first pixel runs 5 complete loops through the color wheel. + // Color wheel has a range of 65536 but it's OK if we roll over, so + // just count from 0 to 5*65536. Adding 256 to firstPixelHue each time + // means we'll make 5*65536/256 = 1280 passes through this loop: + for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { + // strip.rainbow() can take a single argument (first pixel hue) or + // optionally a few extras: number of rainbow repetitions (default 1), + // saturation and value (brightness) (both 0-255, similar to the + // ColorHSV() function, default 255), and a true/false flag for whether + // to apply gamma correction to provide 'truer' colors (default true). + strip.rainbow(firstPixelHue); + // Above line is equivalent to: + // strip.rainbow(firstPixelHue, 1, 255, 255, true); + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + } +} + +// Rainbow-enhanced theater marquee. Pass delay time (in ms) between frames. +void theaterChaseRainbow(int wait) { + int firstPixelHue = 0; // First pixel starts at red (hue 0) + for(int a=0; a<30; a++) { // Repeat 30 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 increments of 3... + for(int c=b; c<strip.numPixels(); c += 3) { + // hue of pixel 'c' is offset by an amount to make one full + // revolution of the color wheel (range 65536) along the length + // of the strip (strip.numPixels() steps): + int hue = firstPixelHue + c * 65536L / strip.numPixels(); + uint32_t color = strip.gamma32(strip.ColorHSV(hue)); // hue -> RGB + strip.setPixelColor(c, color); // Set pixel 'c' to value 'color' + } + strip.show(); // Update strip with new contents + delay(wait); // Pause for a moment + firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames + } + } +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_nodelay/.esp8266.test.skip b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_nodelay/.esp8266.test.skip new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_nodelay/.esp8266.test.skip @@ -0,0 +1 @@ + diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_nodelay/strandtest_nodelay.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_nodelay/strandtest_nodelay.ino new file mode 100644 index 0000000..1fb8888 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_nodelay/strandtest_nodelay.ino @@ -0,0 +1,200 @@ +// A non-blocking everyday NeoPixel strip test program. + +// NEOPIXEL BEST PRACTICES for most reliable operation: +// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. +// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. +// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. +// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS +// connect GROUND (-) first, then +, then data. +// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, +// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. +// (Skipping these may work OK on your workbench but can fail in the field) + +#include <Adafruit_NeoPixel.h> +#ifdef __AVR__ + #include <avr/power.h> // Required for 16 MHz Adafruit Trinket +#endif + +// Which pin on the Arduino is connected to the NeoPixels? +// On a Trinket or Gemma we suggest changing this to 1: +#ifdef ESP32 +// Cannot use 6 as output for ESP. Pins 6-11 are connected to SPI flash. Use 16 instead. +#define LED_PIN 16 +#else +#define LED_PIN 6 +#endif + +// How many NeoPixels are attached to the Arduino? +#define LED_COUNT 60 + +// Declare our NeoPixel strip object: +Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); +// Argument 1 = Number of pixels in NeoPixel strip +// Argument 2 = Arduino pin number (most are valid) +// Argument 3 = Pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) + +unsigned long pixelPrevious = 0; // Previous Pixel Millis +unsigned long patternPrevious = 0; // Previous Pattern Millis +int patternCurrent = 0; // Current Pattern Number +int patternInterval = 5000; // Pattern Interval (ms) +bool patternComplete = false; + +int pixelInterval = 50; // Pixel Interval (ms) +int pixelQueue = 0; // Pattern Pixel Queue +int pixelCycle = 0; // Pattern Pixel Cycle +uint16_t pixelNumber = LED_COUNT; // Total Number of Pixels + +// setup() function -- runs once at startup -------------------------------- +void setup() { + // These lines are specifically to support the Adafruit Trinket 5V 16 MHz. + // Any other board, you can remove this part (but no harm leaving it): +#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) + clock_prescale_set(clock_div_1); +#endif + // END of Trinket-specific code. + + 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) +} + +// loop() function -- runs repeatedly as long as board is on --------------- +void loop() { + unsigned long currentMillis = millis(); // Update current time + if( patternComplete || (currentMillis - patternPrevious) >= patternInterval) { // Check for expired time + patternComplete = false; + patternPrevious = currentMillis; + patternCurrent++; // Advance to next pattern + if(patternCurrent >= 7) + patternCurrent = 0; + } + + if(currentMillis - pixelPrevious >= pixelInterval) { // Check for expired time + pixelPrevious = currentMillis; // Run current frame + switch (patternCurrent) { + case 7: + theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant + break; + case 6: + rainbow(10); // Flowing rainbow cycle along the whole strip + break; + case 5: + theaterChase(strip.Color(0, 0, 127), 50); // Blue + break; + case 4: + theaterChase(strip.Color(127, 0, 0), 50); // Red + break; + case 3: + theaterChase(strip.Color(127, 127, 127), 50); // White + break; + case 2: + colorWipe(strip.Color(0, 0, 255), 50); // Blue + break; + case 1: + colorWipe(strip.Color(0, 255, 0), 50); // Green + break; + default: + colorWipe(strip.Color(255, 0, 0), 50); // Red + break; + } + } +} + +// Some functions of our own for creating animated effects ----------------- + +// Fill strip pixels one after another with a color. Strip is NOT cleared +// first; anything there will be covered pixel by pixel. Pass in color +// (as a single 'packed' 32-bit value, which you can get by calling +// strip.Color(red, green, blue) as shown in the loop() function above), +// and a delay time (in milliseconds) between pixels. +void colorWipe(uint32_t color, int wait) { + static uint16_t current_pixel = 0; + pixelInterval = wait; // Update delay time + strip.setPixelColor(current_pixel++, color); // Set pixel's color (in RAM) + strip.show(); // Update strip to match + if(current_pixel >= pixelNumber) { // Loop the pattern from the first LED + current_pixel = 0; + patternComplete = true; + } +} + +// Theater-marquee-style chasing lights. Pass in a color (32-bit value, +// a la strip.Color(r,g,b) as mentioned above), and a delay time (in ms) +// between frames. +void theaterChase(uint32_t color, int wait) { + static uint32_t loop_count = 0; + static uint16_t current_pixel = 0; + + pixelInterval = wait; // Update delay time + + strip.clear(); + + for(int c=current_pixel; c < pixelNumber; c += 3) { + strip.setPixelColor(c, color); + } + strip.show(); + + current_pixel++; + if (current_pixel >= 3) { + current_pixel = 0; + loop_count++; + } + + if (loop_count >= 10) { + current_pixel = 0; + loop_count = 0; + patternComplete = true; + } +} + +// Rainbow cycle along whole strip. Pass delay time (in ms) between frames. +void rainbow(uint8_t wait) { + if(pixelInterval != wait) + pixelInterval = wait; + for(uint16_t i=0; i < pixelNumber; i++) { + strip.setPixelColor(i, Wheel((i + pixelCycle) & 255)); // Update delay time + } + strip.show(); // Update strip to match + pixelCycle++; // Advance current cycle + if(pixelCycle >= 256) + pixelCycle = 0; // Loop the cycle back to the begining +} + +//Theatre-style crawling lights with rainbow effect +void theaterChaseRainbow(uint8_t wait) { + if(pixelInterval != wait) + pixelInterval = wait; // Update delay time + for(int i=0; i < pixelNumber; i+=3) { + strip.setPixelColor(i + pixelQueue, Wheel((i + pixelCycle) % 255)); // Update delay time + } + strip.show(); + for(int i=0; i < pixelNumber; i+=3) { + strip.setPixelColor(i + pixelQueue, strip.Color(0, 0, 0)); // Update delay time + } + pixelQueue++; // Advance current queue + pixelCycle++; // Advance current cycle + if(pixelQueue >= 3) + pixelQueue = 0; // Loop + if(pixelCycle >= 256) + pixelCycle = 0; // Loop +} + +// Input a value 0 to 255 to get a color value. +// The colours are a transition r - g - b - back to r. +uint32_t Wheel(byte WheelPos) { + WheelPos = 255 - WheelPos; + if(WheelPos < 85) { + return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); + } + if(WheelPos < 170) { + WheelPos -= 85; + return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); + } + WheelPos -= 170; + return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); +} diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_wheel/.esp8266.test.skip b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_wheel/.esp8266.test.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_wheel/.esp8266.test.skip diff --git a/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_wheel/strandtest_wheel.ino b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_wheel/strandtest_wheel.ino new file mode 100644 index 0000000..c0ca41e --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/Adafruit NeoPixel/examples/strandtest_wheel/strandtest_wheel.ino @@ -0,0 +1,134 @@ +#include <Adafruit_NeoPixel.h> +#ifdef __AVR__ + #include <avr/power.h> +#endif + +#define PIN 6 + +// Parameter 1 = number of pixels in strip +// Parameter 2 = Arduino pin number (most are valid) +// Parameter 3 = pixel type flags, add together as needed: +// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) +// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) +// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) +// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) +// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) +Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800); + +// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across +// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input +// and minimize distance between Arduino and first pixel. Avoid connecting +// on a live circuit...if you must, connect GND first. + +void setup() { + // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket + #if defined (__AVR_ATtiny85__) + if (F_CPU == 16000000) clock_prescale_set(clock_div_1); + #endif + // End of trinket special code + + strip.begin(); + strip.setBrightness(50); + strip.show(); // Initialize all pixels to 'off' +} + +void loop() { + // Some example procedures showing how to display to the pixels: + colorWipe(strip.Color(255, 0, 0), 50); // Red + colorWipe(strip.Color(0, 255, 0), 50); // Green + colorWipe(strip.Color(0, 0, 255), 50); // Blue +//colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW + // Send a theater pixel chase in... + theaterChase(strip.Color(127, 127, 127), 50); // White + theaterChase(strip.Color(127, 0, 0), 50); // Red + theaterChase(strip.Color(0, 0, 127), 50); // Blue + + rainbow(20); + rainbowCycle(20); + theaterChaseRainbow(50); +} + +// Fill the dots one after the other with a color +void colorWipe(uint32_t c, uint8_t wait) { + for(uint16_t i=0; i<strip.numPixels(); i++) { + strip.setPixelColor(i, c); + strip.show(); + delay(wait); + } +} + +void rainbow(uint8_t wait) { + uint16_t i, j; + + for(j=0; j<256; j++) { + for(i=0; i<strip.numPixels(); i++) { + strip.setPixelColor(i, Wheel((i+j) & 255)); + } + strip.show(); + delay(wait); + } +} + +// Slightly different, this makes the rainbow equally distributed throughout +void rainbowCycle(uint8_t wait) { + uint16_t i, j; + + for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel + for(i=0; i< strip.numPixels(); i++) { + strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); + } + strip.show(); + delay(wait); + } +} + +//Theatre-style crawling lights. +void theaterChase(uint32_t c, uint8_t wait) { + for (int j=0; j<10; j++) { //do 10 cycles of chasing + for (int q=0; q < 3; q++) { + for (uint16_t i=0; i < strip.numPixels(); i=i+3) { + strip.setPixelColor(i+q, c); //turn every third pixel on + } + strip.show(); + + delay(wait); + + for (uint16_t i=0; i < strip.numPixels(); i=i+3) { + strip.setPixelColor(i+q, 0); //turn every third pixel off + } + } + } +} + +//Theatre-style crawling lights with rainbow effect +void theaterChaseRainbow(uint8_t wait) { + for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel + for (int q=0; q < 3; q++) { + for (uint16_t i=0; i < strip.numPixels(); i=i+3) { + strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on + } + strip.show(); + + delay(wait); + + for (uint16_t i=0; i < strip.numPixels(); i=i+3) { + strip.setPixelColor(i+q, 0); //turn every third pixel off + } + } + } +} + +// Input a value 0 to 255 to get a color value. +// The colours are a transition r - g - b - back to r. +uint32_t Wheel(byte WheelPos) { + WheelPos = 255 - WheelPos; + if(WheelPos < 85) { + return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); + } + if(WheelPos < 170) { + WheelPos -= 85; + return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); + } + WheelPos -= 170; + return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); +} |
