Skip to content

Commit 815e584

Browse files
authored
Merge pull request #2926 from adafruit/arduino_vcnl4200
arduino simpletest for the vcnl4200
2 parents b0c1fa1 + 76337d2 commit 815e584

File tree

8 files changed

+83
-28
lines changed

8 files changed

+83
-28
lines changed

Arduino_VCNL4200_simpletest/.uno.test.only

Whitespace-only changes.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include "Adafruit_VCNL4200.h"
6+
7+
Adafruit_VCNL4200 vcnl4200;
8+
9+
void setup() {
10+
Serial.begin(115200);
11+
while (!Serial) {
12+
delay(10); // wait for native USB
13+
}
14+
15+
Serial.println("Adafruit VCNL4200 ALS simple test");
16+
17+
if (!vcnl4200.begin()) {
18+
Serial.println("Could not find a valid VCNL4200 sensor, check wiring!");
19+
while (1) {
20+
delay(10);
21+
}
22+
}
23+
Serial.println("VCNL4200 found!");
24+
25+
vcnl4200.setALSshutdown(false);
26+
vcnl4200.setALSIntegrationTime(VCNL4200_ALS_IT_100MS);
27+
vcnl4200.setALSPersistence(VCNL4200_ALS_PERS_2);
28+
29+
vcnl4200.setProxShutdown(false);
30+
vcnl4200.setProxHD(false);
31+
vcnl4200.setProxLEDCurrent(VCNL4200_LED_I_200MA);
32+
vcnl4200.setProxIntegrationTime(VCNL4200_PS_IT_8T);
33+
}
34+
35+
void loop() {
36+
// Read the proximity sensor data
37+
uint16_t proxData = vcnl4200.readProxData();
38+
Serial.print("Prox Data: ");
39+
Serial.println(proxData);
40+
// Read the ambient light sensor (ALS) data
41+
uint16_t alsData = vcnl4200.readALSdata();
42+
Serial.print("ALS Data: ");
43+
Serial.print(alsData);
44+
// Read the raw white sensor data
45+
uint16_t whiteData = vcnl4200.readWhiteData();
46+
Serial.print(", White Data: ");
47+
Serial.println(whiteData);
48+
49+
delay(100);
50+
}

GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// XY(x,y) takes x and y coordinates and returns an LED index number,
2424
// for use like this: leds[ XY(x,y) ] == CRGB::Red;
2525

26+
#include <FastLED.h>
2627

2728
// Parameters for width and height
2829
const uint8_t kMatrixWidth = 24;
@@ -37,8 +38,10 @@ CRGB leds[ NUM_LEDS ];
3738
// This code, plus the supporting 80-byte table is much smaller
3839
// and much faster than trying to calculate the pixel ID with code.
3940
#define LAST_VISIBLE_LED 119
40-
uint8_t XY( uint8_t x, uint8_t y)
41+
uint16_t XY(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
4142
{
43+
(void)width;
44+
(void)height;
4245
// any out of bounds address maps to the first hidden pixel
4346
if( (x >= kMatrixWidth) || (y >= kMatrixHeight) ) {
4447
return (LAST_VISIBLE_LED + 1);
@@ -79,3 +82,6 @@ uint8_t XY( uint8_t x, uint8_t y)
7982
uint8_t j = JacketTable[i];
8083
return j;
8184
}
85+
86+
// Instantiate an XYMap object
87+
XYMap myXYMap = XYMap::constructWithUserFunction(kMatrixWidth, kMatrixHeight, XY);

GemmaM0_Band_Jacket/DiscoBandCamp/effects.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void threeSine() {
2626
byte sinDistanceG = qmul8(abs(y * (255 / kMatrixHeight) - sin8(sineOffset * 10 + x * 16)), 2);
2727
byte sinDistanceB = qmul8(abs(y * (255 / kMatrixHeight) - sin8(sineOffset * 11 + x * 16)), 2);
2828

29-
leds[XY(x, y)] = CRGB(255 - sinDistanceR, 255 - sinDistanceG, 255 - sinDistanceB);
29+
leds[XY(x, y, 0, 0)] = CRGB(255 - sinDistanceR, 255 - sinDistanceG, 255 - sinDistanceB);
3030
}
3131
}
3232

@@ -70,7 +70,7 @@ void plasma() {
7070
for (int x = 0; x < kMatrixWidth; x++) {
7171
for (int y = 0; y < kMatrixHeight; y++) {
7272
byte color = sin8(sqrt(sq(((float)x - 7.5) * 10 + xOffset - 127) + sq(((float)y - 2) * 10 + yOffset - 127)) + offset);
73-
leds[XY(x, y)] = CHSV(color, 255, 255);
73+
leds[XY(x, y, 0, 0)] = CHSV(color, 255, 255);
7474
}
7575
}
7676

@@ -100,7 +100,7 @@ void rider() {
100100
brightness = 255 - brightness;
101101
CRGB riderColor = CHSV(cycleHue, 255, brightness);
102102
for (byte y = 0; y < kMatrixHeight; y++) {
103-
leds[XY(x, y)] = riderColor;
103+
leds[XY(x, y, 0, 0)] = riderColor;
104104
}
105105
}
106106

@@ -133,7 +133,7 @@ void colorFill() {
133133
for (byte x = 0; x < kMatrixWidth; x++) {
134134
byte y = currentRow;
135135
if (currentDirection == 2) y = kMatrixHeight - 1 - currentRow;
136-
leds[XY(x, y)] = currentPalette[currentColor];
136+
leds[XY(x, y, 0, 0)] = currentPalette[currentColor];
137137
}
138138
}
139139

@@ -143,7 +143,7 @@ void colorFill() {
143143
for (byte y = 0; y < kMatrixHeight; y++) {
144144
byte x = currentRow;
145145
if (currentDirection == 3) x = kMatrixWidth - 1 - currentRow;
146-
leds[XY(x, y)] = currentPalette[currentColor];
146+
leds[XY(x, y, 0, 0)] = currentPalette[currentColor];
147147
}
148148
}
149149

@@ -174,8 +174,8 @@ void sideRain() {
174174

175175
scrollArray(rainDir);
176176
byte randPixel = random8(kMatrixHeight);
177-
for (byte y = 0; y < kMatrixHeight; y++) leds[XY((kMatrixWidth - 1) * rainDir, y)] = CRGB::Black;
178-
leds[XY((kMatrixWidth - 1)*rainDir, randPixel)] = CHSV(cycleHue, 255, 255);
177+
for (byte y = 0; y < kMatrixHeight; y++) leds[XY((kMatrixWidth - 1) * rainDir, y, 0, 0)] = CRGB::Black;
178+
leds[XY((kMatrixWidth - 1)*rainDir, randPixel, 0, 0)] = CHSV(cycleHue, 255, 255);
179179

180180
}
181181

@@ -194,7 +194,7 @@ void confetti() {
194194

195195
// scatter random colored pixels at several random coordinates
196196
for (byte i = 0; i < 4; i++) {
197-
leds[XY(random16(kMatrixWidth), random16(kMatrixHeight))] = ColorFromPalette(currentPalette, random16(255), 255); //CHSV(random16(255), 255, 255);
197+
leds[XY(random16(kMatrixWidth), random16(kMatrixHeight), 0, 0)] = ColorFromPalette(currentPalette, random16(255), 255); //CHSV(random16(255), 255, 255);
198198
random16_add_entropy(1);
199199
}
200200
}
@@ -233,7 +233,7 @@ void myConfetti() {
233233

234234
// scatter random colored pixels at several random coordinates
235235
for (byte i = 0; i < 4; i++) {
236-
leds[XY(random16(kMatrixWidth), random16(kMatrixHeight))] = ColorFromPalette(MyColors_p, random16(255), 255); //CHSV(random16(255), 255, 255);
236+
leds[XY(random16(kMatrixWidth), random16(kMatrixHeight), 0, 0)] = ColorFromPalette(MyColors_p, random16(255), 255); //CHSV(random16(255), 255, 255);
237237
random16_add_entropy(1);
238238
}
239239

@@ -263,7 +263,7 @@ void slantBars() {
263263

264264
for (byte x = 0; x < kMatrixWidth; x++) {
265265
for (byte y = 0; y < kMatrixHeight; y++) {
266-
leds[XY(x, y)] = CHSV(cycleHue, 255, quadwave8(x * 32 + y * 32 + slantPos));
266+
leds[XY(x, y, 0, 0)] = CHSV(cycleHue, 255, quadwave8(x * 32 + y * 32 + slantPos));
267267
}
268268
}
269269

@@ -286,7 +286,7 @@ void swirly()
286286
// blur it repeatedly. Since the blurring is 'lossy', there's
287287
// an automatic trend toward black -- by design.
288288
uint8_t blurAmount = beatsin8(2,10,255);
289-
blur2d( leds, kMatrixWidth, kMatrixHeight, blurAmount);
289+
blur2d(leds, kMatrixWidth, kMatrixHeight, blurAmount, myXYMap);
290290

291291
// Use two out-of-sync sine waves
292292
uint8_t i = beatsin8( 27, kBorderWidth, kMatrixHeight-kBorderWidth);
@@ -297,12 +297,12 @@ void swirly()
297297

298298
// The color of each point shifts over time, each at a different speed.
299299
uint16_t ms = millis();
300-
leds[XY( i, j)] += CHSV( ms / 11, 200, 255);
301-
leds[XY( j, i)] += CHSV( ms / 13, 200, 255);
302-
leds[XY(ni,nj)] += CHSV( ms / 17, 200, 255);
303-
leds[XY(nj,ni)] += CHSV( ms / 29, 200, 255);
304-
leds[XY( i,nj)] += CHSV( ms / 37, 200, 255);
305-
leds[XY(ni, j)] += CHSV( ms / 41, 200, 255);
300+
leds[XY(i, j, 0, 0)] += CHSV( ms / 11, 200, 255);
301+
leds[XY(j, i, 0, 0)] += CHSV( ms / 13, 200, 255);
302+
leds[XY(ni,nj, 0, 0)] += CHSV( ms / 17, 200, 255);
303+
leds[XY(nj,ni, 0, 0)] += CHSV( ms / 29, 200, 255);
304+
leds[XY(i,nj, 0, 0)] += CHSV( ms / 37, 200, 255);
305+
leds[XY(ni, j, 0, 0)] += CHSV( ms / 41, 200, 255);
306306

307307
FastLED.show();
308308
}

GemmaM0_Band_Jacket/DiscoBandCamp/utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void scrollArray(byte scrollDir) {
6868
}
6969

7070
for (byte y = 0; y < kMatrixHeight; y++) {
71-
leds[XY(scrollX,y)] = leds[XY(scrollX + scrollDir*2 - 1,y)];
71+
leds[XY(scrollX,y,0,0)] = leds[XY(scrollX + scrollDir*2 - 1,y,0,0)];
7272
}
7373
}
7474

@@ -177,7 +177,7 @@ void mapNoiseToLEDsUsingPalette()
177177
}
178178

179179
CRGB color = ColorFromPalette( currentPalette, index, bri);
180-
leds[XY(i,j)] = color;
180+
leds[XY(i,j,0,0)] = color;
181181
}
182182
}
183183

Programmable_12v_Outdoor_Cafe_Lights/Programmable_12v_Outdoor_Cafe_Lights.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void setup() {
4343
// Forward declarations of an array of cpt-city gradient palettes, and
4444
// a count of how many there are. The actual color palette definitions
4545
// are at the bottom of this file.
46-
extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
46+
extern const TProgmemRGBGradientPaletteRef gGradientPalettes[];
4747
extern const uint8_t gGradientPaletteCount;
4848

4949
// Current palette number from the 'playlist' of color palettes
@@ -265,7 +265,7 @@ DEFINE_GRADIENT_PALETTE( bhw3_32_gp ) {
265265
//
266266
// This list of color palettes acts as a "playlist"; you can
267267
// add or delete, or re-arrange as you wish.
268-
const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
268+
const TProgmemRGBGradientPaletteRef gGradientPalettes[] = {
269269
bhw3_32_gp,
270270
bhw1_01_gp,
271271
bhw1_07_gp,
@@ -281,7 +281,7 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
281281

282282
// Count of how many cpt-city gradients are defined:
283283
const uint8_t gGradientPaletteCount =
284-
sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );
284+
sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPaletteRef );
285285
void loop()
286286
{
287287
EVERY_N_SECONDS( SECONDS_PER_PALETTE ) {

library.deps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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
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, Adafruit VCNL4200 Library

simple_strand_palettes/simple_strand_palettes.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void setup() {
4848
// Forward declarations of an array of cpt-city gradient palettes, and
4949
// a count of how many there are. The actual color palette definitions
5050
// are at the bottom of this file.
51-
extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
51+
extern const TProgmemRGBGradientPaletteRef gGradientPalettes[];
5252
extern const uint8_t gGradientPaletteCount;
5353

5454
// Current palette number from the 'playlist' of color palettes
@@ -618,7 +618,7 @@ DEFINE_GRADIENT_PALETTE( bhw1_28_gp ) {
618618
//
619619
// This list of color palettes acts as a "playlist"; you can
620620
// add or delete, or re-arrange as you wish.
621-
const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
621+
const TProgmemRGBGradientPaletteRef gGradientPalettes[] = {
622622
bhw1_28_gp,
623623
Sunset_Real_gp,
624624
es_rivendell_15_gp,
@@ -657,7 +657,7 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
657657

658658
// Count of how many cpt-city gradients are defined:
659659
const uint8_t gGradientPaletteCount =
660-
sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );
660+
sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPaletteRef );
661661

662662

663663

@@ -677,4 +677,3 @@ const uint8_t gGradientPaletteCount =
677677
FastLED.show();
678678
FastLED.delay(20);
679679
}
680-

0 commit comments

Comments
 (0)