-
Notifications
You must be signed in to change notification settings - Fork 789
arduino simpletest for the vcnl4200 #2926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7c66c14
85fc938
3356c6e
31ccb26
3caeb03
025eace
d9ce978
76337d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// 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.setProxShutdown(false); | ||
vcnl4200.setProxHD(false); | ||
vcnl4200.setProxLEDCurrent(VCNL4200_LED_I_200MA); | ||
vcnl4200.setProxIntegrationTime(VCNL4200_PS_IT_8T); | ||
} | ||
|
||
void loop() { | ||
// Read the proximity sensor data | ||
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); | ||
// Read the raw white sensor data | ||
uint16_t whiteData = vcnl4200.readWhiteData(); | ||
Serial.print(", White Data: "); | ||
Serial.println(whiteData); | ||
|
||
delay(100); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)); | ||
} | ||
} | ||
|
||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know we're both just making guesses here but I think this is going to change the result of blur2d. I went back into the fastled history to see how this worked before and after: Previously, blur2d used the XY function provided in the sketch, this was implicit. So the blur would be using the structure of the disco jacket as defined in the Jacket Table. After this change, the XY function is not used by blur (though it is used elsewhere through the file), but instead a serpentine mapping defined by myXYMap would be used. I think that The result of an incorrect pixel map is that values from one area of the jacket would blur into non-adjacent pixels, making the effect look more muddled. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very good catch and i was concerned about that one. i just pushed an update that uses constructWithUserFunction(). i hooked up two neopixel matrices and a button to test and compare to the project video and i believe that functionality has been retained |
||
blur2d(leds, kMatrixWidth, kMatrixHeight, blurAmount, myXYMap); | ||
|
||
// Use two out-of-sync sine waves | ||
uint8_t i = beatsin8( 27, kBorderWidth, kMatrixHeight-kBorderWidth); | ||
|
@@ -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(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment:
// Read the raw white sensor data
to match comment on L39