Skip to content

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

Merged
merged 8 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
48 changes: 48 additions & 0 deletions Arduino_VCNL4200_simpletest/Arduino_VCNL4200_simpletest.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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() {
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();
Copy link
Member

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

Serial.print(", White Data: ");
Serial.println(whiteData);

delay(100);
}
4 changes: 4 additions & 0 deletions GemmaM0_Band_Jacket/DiscoBandCamp/XYmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <FastLED.h>

// Parameters for width and height
const uint8_t kMatrixWidth = 24;
Expand Down Expand Up @@ -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);
2 changes: 1 addition & 1 deletion GemmaM0_Band_Jacket/DiscoBandCamp/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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:
FastLED/FastLED@b02a481#diff-6b91d9b6efd432b06dc6eb73a57f6a29d64d6b6983c760779f9e86099d8ddafdL465

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 constructWithUserFunction() probably needs to be used, something like: XYMap myXYMap = XYMap::constructWithUserFunction(kMatrixWidth, kMatrixHeight, XY)

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion library.deps
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
7 changes: 3 additions & 4 deletions simple_strand_palettes/simple_strand_palettes.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 );



Expand All @@ -677,4 +677,3 @@ const uint8_t gGradientPaletteCount =
FastLED.show();
FastLED.delay(20);
}

Loading