From 7c66c14506e372e3d52cecd295f185432f7bf140 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 18 Nov 2024 08:39:58 -0500 Subject: [PATCH 1/8] arduino simpletest for the vcnl4200 --- .../Arduino_VCNL4200_simpletest.ino | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino diff --git a/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino b/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino new file mode 100644 index 000000000..2bd3184fb --- /dev/null +++ b/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino @@ -0,0 +1,64 @@ +// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries +// +// SPDX-License-Identifier: MIT + +#include "Adafruit_VCNL4200.h" + +Adafruit_VCNL4200 vcnl4200; + +void setup() { + Serial.begin(115200); + while (!Serial) { + delay(10); // wait for native USB + } + + Serial.println("Adafruit VCNL4200 ALS simple test"); + + if (!vcnl4200.begin()) { + Serial.println("Could not find a valid VCNL4200 sensor, check wiring!"); + while (1) { + delay(10); + } + } + Serial.println("VCNL4200 found!"); + + vcnl4200.setALSshutdown(false); + vcnl4200.setALSIntegrationTime(VCNL4200_ALS_IT_100MS); + vcnl4200.setALSPersistence(VCNL4200_ALS_PERS_2); + vcnl4200.setALSthresholdLow(100); + vcnl4200.setALSthresholdHigh(20000); + vcnl4200.setInterrupt(true, false); // activate int on ALS chan + + vcnl4200.setProxShutdown(false); + vcnl4200.setProxHD(false); + vcnl4200.setProxLEDCurrent(VCNL4200_LED_I_200MA); + vcnl4200.setProxIntegrationTime(VCNL4200_PS_IT_8T); +} + +void loop() { + uint16_t proxData = vcnl4200.readProxData(); + Serial.print("Prox Data: "); + Serial.println(proxData); + // Read the ambient light sensor (ALS) data + uint16_t alsData = vcnl4200.readALSdata(); + Serial.print("ALS Data: "); + Serial.print(alsData); + uint16_t whiteData = vcnl4200.readWhiteData(); + Serial.print(", White Data: "); + Serial.println(whiteData); + + uint8_t flags = vcnl4200.getInterruptFlags(); + if (flags != 0 && flags != 0xFF) { + Serial.print("Interrupt flags: 0x"); + Serial.println(flags, HEX); + + if (flags & VCNL4200_INTFLAG_ALS_HIGH) { + Serial.println("ALS high threshold interrupt triggered."); + } + if (flags & VCNL4200_INTFLAG_ALS_LOW) { + Serial.println("ALS low threshold interrupt triggered."); + } + } + + delay(100); +} From 85fc938f4af74cd79611d4ab16740e11fafa0eb6 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 18 Nov 2024 08:42:12 -0500 Subject: [PATCH 2/8] take out interrupts --- .../Arduino_VCNL4200_simpletest.ino | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino b/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino index 2bd3184fb..e728614fe 100644 --- a/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino +++ b/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino @@ -25,9 +25,6 @@ void setup() { vcnl4200.setALSshutdown(false); vcnl4200.setALSIntegrationTime(VCNL4200_ALS_IT_100MS); vcnl4200.setALSPersistence(VCNL4200_ALS_PERS_2); - vcnl4200.setALSthresholdLow(100); - vcnl4200.setALSthresholdHigh(20000); - vcnl4200.setInterrupt(true, false); // activate int on ALS chan vcnl4200.setProxShutdown(false); vcnl4200.setProxHD(false); @@ -47,18 +44,5 @@ void loop() { Serial.print(", White Data: "); Serial.println(whiteData); - uint8_t flags = vcnl4200.getInterruptFlags(); - if (flags != 0 && flags != 0xFF) { - Serial.print("Interrupt flags: 0x"); - Serial.println(flags, HEX); - - if (flags & VCNL4200_INTFLAG_ALS_HIGH) { - Serial.println("ALS high threshold interrupt triggered."); - } - if (flags & VCNL4200_INTFLAG_ALS_LOW) { - Serial.println("ALS low threshold interrupt triggered."); - } - } - delay(100); } From 3356c6e10d2b71109f2eed6951e171da05d5da78 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 18 Nov 2024 08:49:17 -0500 Subject: [PATCH 3/8] add vcnl4200 to library depends --- library.deps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.deps b/library.deps index da6757ba4..681b8cd0d 100644 --- a/library.deps +++ b/library.deps @@ -1 +1 @@ -depends=Adafruit ILI9341, Adafruit BusIO, SD, Adafruit NeoPixel, Adafruit VS1053 Library, Adafruit BluefruitLE nRF51, Adafruit seesaw Library, Ethernet, Adafruit IO Arduino, FastLED, Adafruit LiquidCrystal, Adafruit SoftServo, TinyWireM, Adafruit AM radio library, WaveHC, Adafruit LED Backpack Library, MAX31850 OneWire, Adafruit VC0706 Serial Camera Library, RTClib, Adafruit SleepyDog Library, Adafruit Thermal Printer Library, Adafruit Zero I2S Library, Adafruit EPD, Adafruit SSD1351 library, Adafruit FONA Library, Adafruit Motor Shield V2 Library, Adafruit NeoMatrix, Adafruit Soundboard library, Adafruit Circuit Playground, ArduinoJson, Adafruit TCS34725, Adafruit Pixie, Adafruit GPS Library, TinyGPS, WiFi101, Adafruit DotStar, Adafruit Si7021 Library, Adafruit WS2801 Library, Mouse, Keyboard, Time, IRremote, Adafruit LSM9DS0 Library, Adafruit Arcada Library, MIDIUSB, PubSubClient, Adafruit LIS2MDL, Adafruit NeoPXL8, Adafruit MCP23017 Arduino Library, Adafruit MLX90640, LiquidCrystal, Adafruit NeoTrellis M4 Library, RGB matrix Panel, Adafruit MLX90614 Library, Adafruit RGB LCD Shield Library, MAX6675 library, Adafruit MP3, Adafruit Keypad, Adafruit Arcada GifDecoder, Keypad, Neosegment, Encoder, Adafruit TiCoServo, Adafruit Trellis Library, FauxmoESP, Adafruit LSM303 Accel, Adafruit LSM303DLH Mag, Adafruit LSM303DLHC, CapacitiveSensor, Adafruit Zero PDM Library, Adafruit DMA neopixel library, elapsedMillis, DST RTC, Adafruit SHARP Memory Display, Adafruit SPIFlash, BSEC Software Library, WiiChuck, Adafruit DPS310, Adafruit AHTX0, RotaryEncoder, Adafruit MCP9808 Library, LSM303, Adafruit Protomatter, Adafruit IS31FL3741 Library, Sensirion I2C SCD4x, Adafruit TestBed, Bounce2, Adafruit AHRS, Adafruit DRV2605 Library, STM32duino VL53L4CD, PicoDVI - Adafruit Fork, Adafruit MMA8451 Library, Adafruit TSC2007, GFX Library for Arduino, Adafruit PyCamera Library, Adafruit ADG72x, Adafruit BNO055, Adafruit SHT4x Library +depends=Adafruit ILI9341, Adafruit BusIO, SD, Adafruit NeoPixel, Adafruit VS1053 Library, Adafruit BluefruitLE nRF51, Adafruit seesaw Library, Ethernet, Adafruit IO Arduino, FastLED, Adafruit LiquidCrystal, Adafruit SoftServo, TinyWireM, Adafruit AM radio library, WaveHC, Adafruit LED Backpack Library, MAX31850 OneWire, Adafruit VC0706 Serial Camera Library, RTClib, Adafruit SleepyDog Library, Adafruit Thermal Printer Library, Adafruit Zero I2S Library, Adafruit EPD, Adafruit SSD1351 library, Adafruit FONA Library, Adafruit Motor Shield V2 Library, Adafruit NeoMatrix, Adafruit Soundboard library, Adafruit Circuit Playground, ArduinoJson, Adafruit TCS34725, Adafruit Pixie, Adafruit GPS Library, TinyGPS, WiFi101, Adafruit DotStar, Adafruit Si7021 Library, Adafruit WS2801 Library, Mouse, Keyboard, Time, IRremote, Adafruit LSM9DS0 Library, Adafruit Arcada Library, MIDIUSB, PubSubClient, Adafruit LIS2MDL, Adafruit NeoPXL8, Adafruit MCP23017 Arduino Library, Adafruit MLX90640, LiquidCrystal, Adafruit NeoTrellis M4 Library, RGB matrix Panel, Adafruit MLX90614 Library, Adafruit RGB LCD Shield Library, MAX6675 library, Adafruit MP3, Adafruit Keypad, Adafruit Arcada GifDecoder, Keypad, Neosegment, Encoder, Adafruit TiCoServo, Adafruit Trellis Library, FauxmoESP, Adafruit LSM303 Accel, Adafruit LSM303DLH Mag, Adafruit LSM303DLHC, CapacitiveSensor, Adafruit Zero PDM Library, Adafruit DMA neopixel library, elapsedMillis, DST RTC, Adafruit SHARP Memory Display, Adafruit SPIFlash, BSEC Software Library, WiiChuck, Adafruit DPS310, Adafruit AHTX0, RotaryEncoder, Adafruit MCP9808 Library, LSM303, Adafruit Protomatter, Adafruit IS31FL3741 Library, Sensirion I2C SCD4x, Adafruit TestBed, Bounce2, Adafruit AHRS, Adafruit DRV2605 Library, STM32duino VL53L4CD, PicoDVI - Adafruit Fork, Adafruit MMA8451 Library, Adafruit TSC2007, GFX Library for Arduino, Adafruit PyCamera Library, Adafruit ADG72x, Adafruit BNO055, Adafruit SHT4x Library, Adafruit VCNL4200 Library From 31ccb26ecc7f0aa569ef1cd9aaa920dc8a038343 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 18 Nov 2024 09:05:15 -0500 Subject: [PATCH 4/8] Create .uno.test.only --- Arduino_VCNL4200_simpletest/.uno.test.only | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Arduino_VCNL4200_simpletest/.uno.test.only diff --git a/Arduino_VCNL4200_simpletest/.uno.test.only b/Arduino_VCNL4200_simpletest/.uno.test.only new file mode 100644 index 000000000..e69de29bb From 3caeb03f56dcc4ac9a65e1c6fbef8fa093f0a109 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 18 Nov 2024 09:42:55 -0500 Subject: [PATCH 5/8] fixes for fastled refactor TProgmemRGBGradientPalettePtr was replaced with TProgmemRGBGradientPaletteRef --- GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h | 4 ++++ GemmaM0_Band_Jacket/DiscoBandCamp/effects.h | 2 +- .../Programmable_12v_Outdoor_Cafe_Lights.ino | 6 +++--- simple_strand_palettes/simple_strand_palettes.ino | 7 +++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h b/GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h index 07c80b997..9f6228cae 100644 --- a/GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h +++ b/GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h @@ -23,6 +23,7 @@ // XY(x,y) takes x and y coordinates and returns an LED index number, // for use like this: leds[ XY(x,y) ] == CRGB::Red; +#include // Parameters for width and height const uint8_t kMatrixWidth = 24; @@ -79,3 +80,6 @@ uint8_t XY( uint8_t x, uint8_t y) uint8_t j = JacketTable[i]; return j; } + +// Instantiate an XYMap object +XYMap myXYMap(kMatrixWidth, kMatrixHeight); diff --git a/GemmaM0_Band_Jacket/DiscoBandCamp/effects.h b/GemmaM0_Band_Jacket/DiscoBandCamp/effects.h index ff0e32ea1..1dba49f93 100644 --- a/GemmaM0_Band_Jacket/DiscoBandCamp/effects.h +++ b/GemmaM0_Band_Jacket/DiscoBandCamp/effects.h @@ -286,7 +286,7 @@ void swirly() // blur it repeatedly. Since the blurring is 'lossy', there's // an automatic trend toward black -- by design. uint8_t blurAmount = beatsin8(2,10,255); - blur2d( leds, kMatrixWidth, kMatrixHeight, blurAmount); + blur2d(leds, kMatrixWidth, kMatrixHeight, blurAmount, myXYMap); // Use two out-of-sync sine waves uint8_t i = beatsin8( 27, kBorderWidth, kMatrixHeight-kBorderWidth); diff --git a/Programmable_12v_Outdoor_Cafe_Lights/Programmable_12v_Outdoor_Cafe_Lights.ino b/Programmable_12v_Outdoor_Cafe_Lights/Programmable_12v_Outdoor_Cafe_Lights.ino index 805ae6afa..24a46d888 100644 --- a/Programmable_12v_Outdoor_Cafe_Lights/Programmable_12v_Outdoor_Cafe_Lights.ino +++ b/Programmable_12v_Outdoor_Cafe_Lights/Programmable_12v_Outdoor_Cafe_Lights.ino @@ -43,7 +43,7 @@ void setup() { // Forward declarations of an array of cpt-city gradient palettes, and // a count of how many there are. The actual color palette definitions // are at the bottom of this file. -extern const TProgmemRGBGradientPalettePtr gGradientPalettes[]; +extern const TProgmemRGBGradientPaletteRef gGradientPalettes[]; extern const uint8_t gGradientPaletteCount; // Current palette number from the 'playlist' of color palettes @@ -265,7 +265,7 @@ DEFINE_GRADIENT_PALETTE( bhw3_32_gp ) { // // This list of color palettes acts as a "playlist"; you can // add or delete, or re-arrange as you wish. -const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { +const TProgmemRGBGradientPaletteRef gGradientPalettes[] = { bhw3_32_gp, bhw1_01_gp, bhw1_07_gp, @@ -281,7 +281,7 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { // Count of how many cpt-city gradients are defined: const uint8_t gGradientPaletteCount = - sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr ); + sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPaletteRef ); void loop() { EVERY_N_SECONDS( SECONDS_PER_PALETTE ) { diff --git a/simple_strand_palettes/simple_strand_palettes.ino b/simple_strand_palettes/simple_strand_palettes.ino index fbdf5f777..6054840ca 100644 --- a/simple_strand_palettes/simple_strand_palettes.ino +++ b/simple_strand_palettes/simple_strand_palettes.ino @@ -48,7 +48,7 @@ void setup() { // Forward declarations of an array of cpt-city gradient palettes, and // a count of how many there are. The actual color palette definitions // are at the bottom of this file. -extern const TProgmemRGBGradientPalettePtr gGradientPalettes[]; +extern const TProgmemRGBGradientPaletteRef gGradientPalettes[]; extern const uint8_t gGradientPaletteCount; // Current palette number from the 'playlist' of color palettes @@ -618,7 +618,7 @@ DEFINE_GRADIENT_PALETTE( bhw1_28_gp ) { // // This list of color palettes acts as a "playlist"; you can // add or delete, or re-arrange as you wish. -const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { +const TProgmemRGBGradientPaletteRef gGradientPalettes[] = { bhw1_28_gp, Sunset_Real_gp, es_rivendell_15_gp, @@ -657,7 +657,7 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = { // Count of how many cpt-city gradients are defined: const uint8_t gGradientPaletteCount = - sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr ); + sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPaletteRef ); @@ -677,4 +677,3 @@ const uint8_t gGradientPaletteCount = FastLED.show(); FastLED.delay(20); } - From 025eace36e7e8ae927d21a2c041d3bf26bb27343 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 18 Nov 2024 11:12:23 -0500 Subject: [PATCH 6/8] Update Arduino_VCNL4200_simpletest.ino --- Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino b/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino index e728614fe..2579fdd45 100644 --- a/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino +++ b/Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino @@ -33,6 +33,7 @@ void setup() { } void loop() { + // Read the proximity sensor data uint16_t proxData = vcnl4200.readProxData(); Serial.print("Prox Data: "); Serial.println(proxData); @@ -40,6 +41,7 @@ void loop() { uint16_t alsData = vcnl4200.readALSdata(); Serial.print("ALS Data: "); Serial.print(alsData); + // Read the raw white sensor data uint16_t whiteData = vcnl4200.readWhiteData(); Serial.print(", White Data: "); Serial.println(whiteData); From d9ce978dc7f606274aa4dc3f284a0a706eabddfe Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 18 Nov 2024 12:06:58 -0500 Subject: [PATCH 7/8] switch to constructWithUserFunction --- .../DiscoBandCamp/DiscoBandCamp.ino | 7 ++-- GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h | 6 ++-- GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h | 3 +- GemmaM0_Band_Jacket/DiscoBandCamp/effects.h | 32 +++++++++---------- GemmaM0_Band_Jacket/DiscoBandCamp/utils.h | 4 +-- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino b/GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino index 828d99035..06270273c 100644 --- a/GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino +++ b/GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino @@ -20,9 +20,9 @@ // Pins on Adafruit Gemma M0 -#define LEFT_PIN 1 // Visual Left (LEDs on the wearers right) connected to D1 +#define LEFT_PIN PIN_EXTERNAL_NEOPIXELS // Visual Left (LEDs on the wearers right) connected to D1 #define NUM_LEFT 60 // number of LEDs connected on the Left -#define RIGHT_PIN 0 // Visual Right (LEDs on the wearers left) connected to D0 +#define RIGHT_PIN 4 // Visual Right (LEDs on the wearers left) connected to D0 #define NUM_RIGHT 60 // number of LEDs connected on the Right // Color order (Green/Red/Blue) @@ -62,7 +62,8 @@ const byte numEffects = (sizeof(effectList)/sizeof(effectList[0])); // Runs one time at the start of the program (power up or reset) void setup() { - + pinMode(PIN_EXTERNAL_POWER, OUTPUT); + digitalWrite(PIN_EXTERNAL_POWER, HIGH); //Add the onboard Strip on the Right and Left to create a single array FastLED.addLeds(leds, 0, NUM_LEFT); FastLED.addLeds(leds, NUM_LEFT, NUM_RIGHT); diff --git a/GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h b/GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h index 9f6228cae..1355be492 100644 --- a/GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h +++ b/GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h @@ -38,8 +38,10 @@ CRGB leds[ NUM_LEDS ]; // This code, plus the supporting 80-byte table is much smaller // and much faster than trying to calculate the pixel ID with code. #define LAST_VISIBLE_LED 119 -uint8_t XY( uint8_t x, uint8_t y) +uint16_t XY(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { + (void)width; + (void)height; // any out of bounds address maps to the first hidden pixel if( (x >= kMatrixWidth) || (y >= kMatrixHeight) ) { return (LAST_VISIBLE_LED + 1); @@ -82,4 +84,4 @@ uint8_t XY( uint8_t x, uint8_t y) } // Instantiate an XYMap object -XYMap myXYMap(kMatrixWidth, kMatrixHeight); +XYMap myXYMap = XYMap::constructWithUserFunction(kMatrixWidth, kMatrixHeight, XY); diff --git a/GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h b/GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h index d756d6f17..b8dce971a 100644 --- a/GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h +++ b/GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h @@ -6,8 +6,7 @@ // Retained button code from RGB Shades though just using one button #define NUMBUTTONS 1 -#define MODEBUTTON 2 //define the pin the button is connected to - +#define MODEBUTTON PIN_EXTERNAL_BUTTON //define the pin the button is connected to #define BTNIDLE 0 #define BTNDEBOUNCING 1 #define BTNPRESSED 2 diff --git a/GemmaM0_Band_Jacket/DiscoBandCamp/effects.h b/GemmaM0_Band_Jacket/DiscoBandCamp/effects.h index 1dba49f93..d72f53196 100644 --- a/GemmaM0_Band_Jacket/DiscoBandCamp/effects.h +++ b/GemmaM0_Band_Jacket/DiscoBandCamp/effects.h @@ -26,7 +26,7 @@ void threeSine() { byte sinDistanceG = qmul8(abs(y * (255 / kMatrixHeight) - sin8(sineOffset * 10 + x * 16)), 2); byte sinDistanceB = qmul8(abs(y * (255 / kMatrixHeight) - sin8(sineOffset * 11 + x * 16)), 2); - leds[XY(x, y)] = CRGB(255 - sinDistanceR, 255 - sinDistanceG, 255 - sinDistanceB); + leds[XY(x, y, 0, 0)] = CRGB(255 - sinDistanceR, 255 - sinDistanceG, 255 - sinDistanceB); } } @@ -70,7 +70,7 @@ void plasma() { for (int x = 0; x < kMatrixWidth; x++) { for (int y = 0; y < kMatrixHeight; y++) { byte color = sin8(sqrt(sq(((float)x - 7.5) * 10 + xOffset - 127) + sq(((float)y - 2) * 10 + yOffset - 127)) + offset); - leds[XY(x, y)] = CHSV(color, 255, 255); + leds[XY(x, y, 0, 0)] = CHSV(color, 255, 255); } } @@ -100,7 +100,7 @@ void rider() { brightness = 255 - brightness; CRGB riderColor = CHSV(cycleHue, 255, brightness); for (byte y = 0; y < kMatrixHeight; y++) { - leds[XY(x, y)] = riderColor; + leds[XY(x, y, 0, 0)] = riderColor; } } @@ -133,7 +133,7 @@ void colorFill() { for (byte x = 0; x < kMatrixWidth; x++) { byte y = currentRow; if (currentDirection == 2) y = kMatrixHeight - 1 - currentRow; - leds[XY(x, y)] = currentPalette[currentColor]; + leds[XY(x, y, 0, 0)] = currentPalette[currentColor]; } } @@ -143,7 +143,7 @@ void colorFill() { for (byte y = 0; y < kMatrixHeight; y++) { byte x = currentRow; if (currentDirection == 3) x = kMatrixWidth - 1 - currentRow; - leds[XY(x, y)] = currentPalette[currentColor]; + leds[XY(x, y, 0, 0)] = currentPalette[currentColor]; } } @@ -174,8 +174,8 @@ void sideRain() { scrollArray(rainDir); byte randPixel = random8(kMatrixHeight); - for (byte y = 0; y < kMatrixHeight; y++) leds[XY((kMatrixWidth - 1) * rainDir, y)] = CRGB::Black; - leds[XY((kMatrixWidth - 1)*rainDir, randPixel)] = CHSV(cycleHue, 255, 255); + for (byte y = 0; y < kMatrixHeight; y++) leds[XY((kMatrixWidth - 1) * rainDir, y, 0, 0)] = CRGB::Black; + leds[XY((kMatrixWidth - 1)*rainDir, randPixel, 0, 0)] = CHSV(cycleHue, 255, 255); } @@ -194,7 +194,7 @@ void confetti() { // scatter random colored pixels at several random coordinates for (byte i = 0; i < 4; i++) { - leds[XY(random16(kMatrixWidth), random16(kMatrixHeight))] = ColorFromPalette(currentPalette, random16(255), 255); //CHSV(random16(255), 255, 255); + leds[XY(random16(kMatrixWidth), random16(kMatrixHeight), 0, 0)] = ColorFromPalette(currentPalette, random16(255), 255); //CHSV(random16(255), 255, 255); random16_add_entropy(1); } } @@ -233,7 +233,7 @@ void myConfetti() { // scatter random colored pixels at several random coordinates for (byte i = 0; i < 4; i++) { - leds[XY(random16(kMatrixWidth), random16(kMatrixHeight))] = ColorFromPalette(MyColors_p, random16(255), 255); //CHSV(random16(255), 255, 255); + leds[XY(random16(kMatrixWidth), random16(kMatrixHeight), 0, 0)] = ColorFromPalette(MyColors_p, random16(255), 255); //CHSV(random16(255), 255, 255); random16_add_entropy(1); } @@ -263,7 +263,7 @@ void slantBars() { for (byte x = 0; x < kMatrixWidth; x++) { for (byte y = 0; y < kMatrixHeight; y++) { - leds[XY(x, y)] = CHSV(cycleHue, 255, quadwave8(x * 32 + y * 32 + slantPos)); + leds[XY(x, y, 0, 0)] = CHSV(cycleHue, 255, quadwave8(x * 32 + y * 32 + slantPos)); } } @@ -297,12 +297,12 @@ void swirly() // The color of each point shifts over time, each at a different speed. uint16_t ms = millis(); - leds[XY( i, j)] += CHSV( ms / 11, 200, 255); - leds[XY( j, i)] += CHSV( ms / 13, 200, 255); - leds[XY(ni,nj)] += CHSV( ms / 17, 200, 255); - leds[XY(nj,ni)] += CHSV( ms / 29, 200, 255); - leds[XY( i,nj)] += CHSV( ms / 37, 200, 255); - leds[XY(ni, j)] += CHSV( ms / 41, 200, 255); + leds[XY(i, j, 0, 0)] += CHSV( ms / 11, 200, 255); + leds[XY(j, i, 0, 0)] += CHSV( ms / 13, 200, 255); + leds[XY(ni,nj, 0, 0)] += CHSV( ms / 17, 200, 255); + leds[XY(nj,ni, 0, 0)] += CHSV( ms / 29, 200, 255); + leds[XY(i,nj, 0, 0)] += CHSV( ms / 37, 200, 255); + leds[XY(ni, j, 0, 0)] += CHSV( ms / 41, 200, 255); FastLED.show(); } diff --git a/GemmaM0_Band_Jacket/DiscoBandCamp/utils.h b/GemmaM0_Band_Jacket/DiscoBandCamp/utils.h index 4891c342f..b41f5b7ed 100644 --- a/GemmaM0_Band_Jacket/DiscoBandCamp/utils.h +++ b/GemmaM0_Band_Jacket/DiscoBandCamp/utils.h @@ -68,7 +68,7 @@ void scrollArray(byte scrollDir) { } for (byte y = 0; y < kMatrixHeight; y++) { - leds[XY(scrollX,y)] = leds[XY(scrollX + scrollDir*2 - 1,y)]; + leds[XY(scrollX,y,0,0)] = leds[XY(scrollX + scrollDir*2 - 1,y,0,0)]; } } @@ -177,7 +177,7 @@ void mapNoiseToLEDsUsingPalette() } CRGB color = ColorFromPalette( currentPalette, index, bri); - leds[XY(i,j)] = color; + leds[XY(i,j,0,0)] = color; } } From 76337d24b748b2a5aeb1ff16395736e99d84021f Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 18 Nov 2024 12:10:19 -0500 Subject: [PATCH 8/8] switch pins back to guide pins change pins that were used for testing back to documented pins --- GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino | 7 +++---- GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino b/GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino index 06270273c..828d99035 100644 --- a/GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino +++ b/GemmaM0_Band_Jacket/DiscoBandCamp/DiscoBandCamp.ino @@ -20,9 +20,9 @@ // Pins on Adafruit Gemma M0 -#define LEFT_PIN PIN_EXTERNAL_NEOPIXELS // Visual Left (LEDs on the wearers right) connected to D1 +#define LEFT_PIN 1 // Visual Left (LEDs on the wearers right) connected to D1 #define NUM_LEFT 60 // number of LEDs connected on the Left -#define RIGHT_PIN 4 // Visual Right (LEDs on the wearers left) connected to D0 +#define RIGHT_PIN 0 // Visual Right (LEDs on the wearers left) connected to D0 #define NUM_RIGHT 60 // number of LEDs connected on the Right // Color order (Green/Red/Blue) @@ -62,8 +62,7 @@ const byte numEffects = (sizeof(effectList)/sizeof(effectList[0])); // Runs one time at the start of the program (power up or reset) void setup() { - pinMode(PIN_EXTERNAL_POWER, OUTPUT); - digitalWrite(PIN_EXTERNAL_POWER, HIGH); + //Add the onboard Strip on the Right and Left to create a single array FastLED.addLeds(leds, 0, NUM_LEFT); FastLED.addLeds(leds, NUM_LEFT, NUM_RIGHT); diff --git a/GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h b/GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h index b8dce971a..d756d6f17 100644 --- a/GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h +++ b/GemmaM0_Band_Jacket/DiscoBandCamp/buttons.h @@ -6,7 +6,8 @@ // Retained button code from RGB Shades though just using one button #define NUMBUTTONS 1 -#define MODEBUTTON PIN_EXTERNAL_BUTTON //define the pin the button is connected to +#define MODEBUTTON 2 //define the pin the button is connected to + #define BTNIDLE 0 #define BTNDEBOUNCING 1 #define BTNPRESSED 2