From 3bcc9975970ed38a4de6255749b38f01d11af3ad Mon Sep 17 00:00:00 2001 From: Richard Bailey Date: Wed, 21 Sep 2016 17:33:48 -0700 Subject: [PATCH 1/8] Create README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b07d86c --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Fork of Adafruit_CircuitPlayground +library for Circuit Playground board that will disable the neopixel portions if FastLED is included before it. + +To use FastLED make sure the #include is before this library From d088b1bf2c2225afddef6ad3e2726d5e1c937890 Mon Sep 17 00:00:00 2001 From: Richard Bailey Date: Wed, 21 Sep 2016 17:45:08 -0700 Subject: [PATCH 2/8] Update Adafruit_CircuitPlayground.h hack to see if I can selectively disable neopixel code --- Adafruit_CircuitPlayground.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Adafruit_CircuitPlayground.h b/Adafruit_CircuitPlayground.h index febfae3..648ae91 100644 --- a/Adafruit_CircuitPlayground.h +++ b/Adafruit_CircuitPlayground.h @@ -14,8 +14,9 @@ You should have received a copy of the GNU Lesser General Public License along with DotStar. If not, see . ------------------------------------------------------------------------*/ - +#ifndef __INC_FASTSPI_LED2_H #include "utility/Adafruit_CPlay_NeoPixel.h" +#endif #include "utility/Adafruit_CPlay_LIS3DH.h" #include "utility/Adafruit_CPlay_Mic.h" #include "utility/Adafruit_CPlay_Speaker.h" @@ -30,7 +31,11 @@ #endif #define CPLAY_REDLED 13 + +#ifndef __INC_FASTSPI_LED2_H #define CPLAY_NEOPIXELPIN 17 +#endif + #define CPLAY_SLIDESWITCHPIN 21 #define CPLAY_LEFTBUTTON 4 #define CPLAY_RIGHTBUTTON 19 @@ -65,9 +70,11 @@ class Adafruit_CircuitPlayground { public: +#ifndef __INC_FASTSPI_LED2_H boolean begin(uint8_t brightness=20); Adafruit_CPlay_NeoPixel strip; +#endif Adafruit_CPlay_LIS3DH lis; Adafruit_CPlay_Mic mic; Adafruit_CPlay_Speaker speaker; @@ -94,7 +101,7 @@ class Adafruit_CircuitPlayground { { lis.setClick(c, clickthresh, 10, 20, 255); } uint8_t getAccelTap(void) { return (lis.getClick() >> 8) & 0x3; } - +#ifndef __INC_FASTSPI_LED2_H // neopixels void clearPixels(void) { strip.clear(); strip.show(); } void setPixelColor(uint8_t p, uint32_t c) {strip.setPixelColor(p, c); strip.show();} @@ -114,6 +121,7 @@ class Adafruit_CircuitPlayground { senseColor(red, green, blue); return ((uint32_t)red << 16) | ((uint32_t)green << 8) | blue; } +#endif private: From b7cb3a980f3f16771e5923621a3e18e97e62bcdb Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 21 Sep 2016 18:50:31 -0700 Subject: [PATCH 3/8] Add code to disable Neopixel code if FastLED is included first I added code to disable the NeoPixel code within the library if the FastLED library is included before it. Thsi should be regression tested for side effects, it is working for me. --- Adafruit_CircuitPlayground.h | 4 ++-- README.md | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Adafruit_CircuitPlayground.h b/Adafruit_CircuitPlayground.h index 648ae91..91f5183 100644 --- a/Adafruit_CircuitPlayground.h +++ b/Adafruit_CircuitPlayground.h @@ -70,9 +70,9 @@ class Adafruit_CircuitPlayground { public: -#ifndef __INC_FASTSPI_LED2_H boolean begin(uint8_t brightness=20); +#ifndef __INC_FASTSPI_LED2_H Adafruit_CPlay_NeoPixel strip; #endif Adafruit_CPlay_LIS3DH lis; @@ -97,7 +97,7 @@ class Adafruit_CircuitPlayground { float motionY(void); float motionZ(void); void setAccelRange(lis3dh_range_t range) { lis.setRange(range); } - void setAccelTap(uint8_t c, uint8_t clickthresh) + void setAccelTap(uint8_t c, uint8_t clickthresh) { lis.setClick(c, clickthresh, 10, 20, 255); } uint8_t getAccelTap(void) { return (lis.getClick() >> 8) & 0x3; } diff --git a/README.md b/README.md index b07d86c..432fa40 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # Fork of Adafruit_CircuitPlayground library for Circuit Playground board that will disable the neopixel portions if FastLED is included before it. +### If this library is included before FastLED, you will have both available to use and possibly conflict in setting color, brightness, etc. + +## I created this fork because I perfer to use FastLED to control addressable leds. + To use FastLED make sure the #include is before this library From 607e933a6a9d6b2a8fe0f02840d6e3b4707e703b Mon Sep 17 00:00:00 2001 From: Richard Date: Sat, 11 Mar 2017 16:08:12 -0800 Subject: [PATCH 4/8] fix naming change --- ...uit_CircuitPlayground.cpp => Adafruit_Circuit_Playground.cpp | 2 +- Adafruit_CircuitPlayground.h => Adafruit_Circuit_Playground.h | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename Adafruit_CircuitPlayground.cpp => Adafruit_Circuit_Playground.cpp (99%) rename Adafruit_CircuitPlayground.h => Adafruit_Circuit_Playground.h (100%) diff --git a/Adafruit_CircuitPlayground.cpp b/Adafruit_Circuit_Playground.cpp similarity index 99% rename from Adafruit_CircuitPlayground.cpp rename to Adafruit_Circuit_Playground.cpp index b065578..9d5ea8f 100644 --- a/Adafruit_CircuitPlayground.cpp +++ b/Adafruit_Circuit_Playground.cpp @@ -1,4 +1,4 @@ -#include +#include boolean Adafruit_CircuitPlayground::begin(uint8_t brightness) { diff --git a/Adafruit_CircuitPlayground.h b/Adafruit_Circuit_Playground.h similarity index 100% rename from Adafruit_CircuitPlayground.h rename to Adafruit_Circuit_Playground.h From 7606e5e2be3264aadea992346f198ff815588eb9 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 27 Mar 2017 13:05:12 -0700 Subject: [PATCH 5/8] fix broken name --- ...uit_Circuit_Playground.cpp => Adafruit_CircuitPlayground.cpp | 2 +- Adafruit_Circuit_Playground.h => Adafruit_CircuitPlayground.h | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename Adafruit_Circuit_Playground.cpp => Adafruit_CircuitPlayground.cpp (99%) rename Adafruit_Circuit_Playground.h => Adafruit_CircuitPlayground.h (100%) diff --git a/Adafruit_Circuit_Playground.cpp b/Adafruit_CircuitPlayground.cpp similarity index 99% rename from Adafruit_Circuit_Playground.cpp rename to Adafruit_CircuitPlayground.cpp index 9d5ea8f..b065578 100644 --- a/Adafruit_Circuit_Playground.cpp +++ b/Adafruit_CircuitPlayground.cpp @@ -1,4 +1,4 @@ -#include +#include boolean Adafruit_CircuitPlayground::begin(uint8_t brightness) { diff --git a/Adafruit_Circuit_Playground.h b/Adafruit_CircuitPlayground.h similarity index 100% rename from Adafruit_Circuit_Playground.h rename to Adafruit_CircuitPlayground.h From b6c779b032a4c6010eee33175dbb801580d76de5 Mon Sep 17 00:00:00 2001 From: Richard Bailey Date: Tue, 19 Dec 2017 21:46:58 -0800 Subject: [PATCH 6/8] fix files --- Adafruit_CircuitPlayground.h | 170 ------------------ Adafruit_Circuit_Playground.h | 321 +++++++++++++++++----------------- 2 files changed, 165 insertions(+), 326 deletions(-) diff --git a/Adafruit_CircuitPlayground.h b/Adafruit_CircuitPlayground.h index 8f2881c..c72cd31 100644 --- a/Adafruit_CircuitPlayground.h +++ b/Adafruit_CircuitPlayground.h @@ -1,173 +1,3 @@ // this is a placeholder file. dont undo or delete this 'clever hack' :) -<<<<<<< HEAD - Adafruit Dot Star is free software: you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License - as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - Adafruit Dot Star is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with DotStar. If not, see . - ------------------------------------------------------------------------*/ -#ifndef _ADAFRUIT_CIRCUITPLAYGROUND_H_ -#define _ADAFRUIT_CIRCUITPLAYGROUND_H_ - -#include -#ifndef __INC_FASTSPI_LED2_H -#include "utility/Adafruit_CPlay_NeoPixel.h" -#endif -#include "utility/Adafruit_CPlay_LIS3DH.h" -#include "utility/Adafruit_CPlay_Mic.h" -#include "utility/Adafruit_CPlay_Speaker.h" -#include "utility/CP_Firmata.h" - -#ifdef __AVR__ // Circuit Playground 'classic' - #include "utility/CPlay_CapacitiveSensor.h" -#else - #include "utility/Adafruit_CPlay_FreeTouch.h" - #include "utility/IRLibCPE.h" -#endif - -#ifndef NOT_AN_INTERRUPT // Not defined in Arduino 1.0.5 - #define NOT_AN_INTERRUPT -1 -#endif - -#ifdef __AVR__ // Circuit Playground 'classic' - #define CPLAY_CAPSENSE_SHARED 30 - #define CPLAY_REDLED 13 -#ifndef __INC_FASTSPI_LED2_H - #define CPLAY_NEOPIXELPIN 17 -#endif - #define CPLAY_SLIDESWITCHPIN 21 - #define CPLAY_LEFTBUTTON 4 - #define CPLAY_RIGHTBUTTON 19 - #define CPLAY_LIGHTSENSOR A5 - #define CPLAY_THERMISTORPIN A0 - #define CPLAY_SOUNDSENSOR A4 - #define CPLAY_BUZZER 5 - #define CPLAY_LIS3DH_CS 8 - #define CPLAY_LIS3DH_INTERRUPT 7 - #define CPLAY_LIS3DH_ADDRESS 0x18 -#else // Circuit Playground Express -<<<<<<< HEAD - #define CPLAY_REDLED 13 - #ifndef __INC_FASTSPI_LED2_H - #define CPLAY_NEOPIXELPIN 8 -#endif - #define CPLAY_SLIDESWITCHPIN 7 -======= ->>>>>>> refs/heads/pr/2 - #define CPLAY_LEFTBUTTON 4 - #define CPLAY_RIGHTBUTTON 5 - #define CPLAY_SLIDESWITCHPIN 7 - #define CPLAY_NEOPIXELPIN 8 - #define CPLAY_REDLED 13 - #define CPLAY_IR_EMITTER 25 - #define CPLAY_IR_RECEIVER 26 - #define CPLAY_BUZZER A0 - #define CPLAY_LIGHTSENSOR A8 - #define CPLAY_THERMISTORPIN A9 - #define CPLAY_SOUNDSENSOR A4 // TBD I2S - #define CPLAY_LIS3DH_CS -1 // I2C - #define CPLAY_LIS3DH_INTERRUPT 27 - #define CPLAY_LIS3DH_ADDRESS 0x19 -#endif - -#define SERIESRESISTOR 10000 -// resistance at 25 degrees C -#define THERMISTORNOMINAL 10000 -// temp. for nominal resistance (almost always 25 C) -#define TEMPERATURENOMINAL 25 - -// The beta coefficient of the thermistor (usually 3000-4000) -#define BCOEFFICIENT 3380 -// the value of the 'other' resistor - -// Configuration to tune the color sensing logic: -#define LIGHT_SETTLE_MS 100 // Amount of time (in milliseconds) to wait between - // changing the pixel color and reading the light - // sensor. - - -class Adafruit_CircuitPlayground { - public: - boolean begin(uint8_t brightness=20); - -#ifndef __INC_FASTSPI_LED2_H - Adafruit_CPlay_NeoPixel strip; -#endif - Adafruit_CPlay_LIS3DH lis; - Adafruit_CPlay_Mic mic; - Adafruit_CPlay_Speaker speaker; - -#ifdef __AVR__ // Circuit Playground 'classic' - CPlay_CapacitiveSensor cap[8]; -#else - Adafruit_CPlay_FreeTouch cap[7]; - IRrecvPCI irReceiver; - IRdecode irDecoder; - IRsend irSend; -#endif - - boolean slideSwitch(void); - void redLED(boolean v); - void playTone(uint16_t freq, uint16_t time, boolean wait=true); - boolean leftButton(void); - boolean rightButton(void); - uint16_t lightSensor(void); - uint16_t soundSensor(void); - float temperature(void); - float temperatureF(void); - - uint16_t readCap(uint8_t p, uint8_t samples=10); - - // Accelerometer - float motionX(void); - float motionY(void); - float motionZ(void); - void setAccelRange(lis3dh_range_t range) { lis.setRange(range); } - void setAccelTap(uint8_t c, uint8_t clickthresh) - { lis.setClick(c, clickthresh, 10, 20, 255); } - uint8_t getAccelTap(void) { return (lis.getClick() >> 8) & 0x3; } - -#ifndef __INC_FASTSPI_LED2_H - // neopixels - void clearPixels(void) { strip.clear(); strip.show(); } - void setPixelColor(uint8_t p, uint32_t c) {strip.setPixelColor(p, c); strip.show();} - void setPixelColor(uint8_t p, uint8_t r, uint8_t g, uint8_t b) {strip.setPixelColor(p, r, g, b); strip.show();} - void setBrightness(uint16_t b){strip.setBrightness(b);} - - uint32_t colorWheel(uint8_t x); - - // Basic RGB color sensing with the light sensor and nearby neopixel. - // Both functions do the same thing and just differ in how they return the - // result, either as explicit RGB bytes or a 24-bit RGB color value. - void senseColor(uint8_t& red, uint8_t& green, uint8_t& blue); - uint32_t senseColor() { - // Use the individual color component color sense function and then recombine - // tbe components into a 24-bit color value. - uint8_t red, green, blue; - senseColor(red, green, blue); - return ((uint32_t)red << 16) | ((uint32_t)green << 8) | blue; - } -#endif - - boolean isExpress(void); - - private: - - -}; - - -extern Adafruit_CircuitPlayground CircuitPlayground; - -#endif -======= #include ->>>>>>> refs/heads/pr/4 diff --git a/Adafruit_Circuit_Playground.h b/Adafruit_Circuit_Playground.h index bc844ae..1beceb4 100644 --- a/Adafruit_Circuit_Playground.h +++ b/Adafruit_Circuit_Playground.h @@ -1,156 +1,165 @@ -/*------------------------------------------------------------------------ - This file is part of the Adafruit Dot Star library. - - Adafruit Dot Star is free software: you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License - as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - Adafruit Dot Star is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with DotStar. If not, see . - ------------------------------------------------------------------------*/ - -#ifndef _ADAFRUIT_CIRCUITPLAYGROUND_H_ -#define _ADAFRUIT_CIRCUITPLAYGROUND_H_ - -#include -#include "utility/Adafruit_CPlay_NeoPixel.h" -#include "utility/Adafruit_CPlay_LIS3DH.h" -#include "utility/Adafruit_CPlay_Mic.h" -#include "utility/Adafruit_CPlay_Speaker.h" -#include "utility/CP_Firmata.h" - -#ifdef __AVR__ // Circuit Playground 'classic' - #include "utility/CPlay_CapacitiveSensor.h" -#else - #include "utility/Adafruit_CPlay_FreeTouch.h" - #include "utility/IRLibCPE.h" -#endif - -#ifndef NOT_AN_INTERRUPT // Not defined in Arduino 1.0.5 - #define NOT_AN_INTERRUPT -1 -#endif - -#ifdef __AVR__ // Circuit Playground 'classic' - #define CPLAY_CAPSENSE_SHARED 30 - #define CPLAY_REDLED 13 - #define CPLAY_NEOPIXELPIN 17 - #define CPLAY_SLIDESWITCHPIN 21 - #define CPLAY_LEFTBUTTON 4 - #define CPLAY_RIGHTBUTTON 19 - #define CPLAY_LIGHTSENSOR A5 - #define CPLAY_THERMISTORPIN A0 - #define CPLAY_SOUNDSENSOR A4 - #define CPLAY_BUZZER 5 - #define CPLAY_LIS3DH_CS 8 - #define CPLAY_LIS3DH_INTERRUPT 7 - #define CPLAY_LIS3DH_ADDRESS 0x18 -#else // Circuit Playground Express - #define CPLAY_LEFTBUTTON 4 - #define CPLAY_RIGHTBUTTON 5 - #define CPLAY_SLIDESWITCHPIN 7 - #define CPLAY_NEOPIXELPIN 8 - #define CPLAY_REDLED 13 - #define CPLAY_IR_EMITTER 25 - #define CPLAY_IR_RECEIVER 26 - #define CPLAY_BUZZER A0 - #define CPLAY_LIGHTSENSOR A8 - #define CPLAY_THERMISTORPIN A9 - #define CPLAY_SOUNDSENSOR A4 // TBD I2S - #define CPLAY_LIS3DH_CS -1 // I2C - #define CPLAY_LIS3DH_INTERRUPT 27 - #define CPLAY_LIS3DH_ADDRESS 0x19 -#endif - -#define SERIESRESISTOR 10000 -// resistance at 25 degrees C -#define THERMISTORNOMINAL 10000 -// temp. for nominal resistance (almost always 25 C) -#define TEMPERATURENOMINAL 25 - -// The beta coefficient of the thermistor (usually 3000-4000) -#define BCOEFFICIENT 3380 -// the value of the 'other' resistor - -// Configuration to tune the color sensing logic: -#define LIGHT_SETTLE_MS 100 // Amount of time (in milliseconds) to wait between - // changing the pixel color and reading the light - // sensor. - - -class Adafruit_CircuitPlayground { - public: - boolean begin(uint8_t brightness=20); - - Adafruit_CPlay_NeoPixel strip; - Adafruit_CPlay_LIS3DH lis; - Adafruit_CPlay_Mic mic; - Adafruit_CPlay_Speaker speaker; - -#ifdef __AVR__ // Circuit Playground 'classic' - CPlay_CapacitiveSensor cap[8]; -#else - Adafruit_CPlay_FreeTouch cap[7]; - IRrecvPCI irReceiver; - IRdecode irDecoder; - IRsend irSend; -#endif - - boolean slideSwitch(void); - void redLED(boolean v); - void playTone(uint16_t freq, uint16_t time, boolean wait=true); - boolean leftButton(void); - boolean rightButton(void); - uint16_t lightSensor(void); - uint16_t soundSensor(void); - float temperature(void); - float temperatureF(void); - - uint16_t readCap(uint8_t p, uint8_t samples=10); - - // Accelerometer - float motionX(void); - float motionY(void); - float motionZ(void); - void setAccelRange(lis3dh_range_t range) { lis.setRange(range); } - void setAccelTap(uint8_t c, uint8_t clickthresh) - { lis.setClick(c, clickthresh, 10, 20, 255); } - uint8_t getAccelTap(void) { return (lis.getClick() >> 8) & 0x3; } - - - // neopixels - void clearPixels(void) { strip.clear(); strip.show(); } - void setPixelColor(uint8_t p, uint32_t c) {strip.setPixelColor(p, c); strip.show();} - void setPixelColor(uint8_t p, uint8_t r, uint8_t g, uint8_t b) {strip.setPixelColor(p, r, g, b); strip.show();} - void setBrightness(uint16_t b){strip.setBrightness(b);} - - uint32_t colorWheel(uint8_t x); - - // Basic RGB color sensing with the light sensor and nearby neopixel. - // Both functions do the same thing and just differ in how they return the - // result, either as explicit RGB bytes or a 24-bit RGB color value. - void senseColor(uint8_t& red, uint8_t& green, uint8_t& blue); - uint32_t senseColor() { - // Use the individual color component color sense function and then recombine - // tbe components into a 24-bit color value. - uint8_t red, green, blue; - senseColor(red, green, blue); - return ((uint32_t)red << 16) | ((uint32_t)green << 8) | blue; - } - - boolean isExpress(void); - - private: - - -}; - - -extern Adafruit_CircuitPlayground CircuitPlayground; - -#endif +/*------------------------------------------------------------------------ + This file is part of the Adafruit Dot Star library. + + Adafruit Dot Star is free software: you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + Adafruit Dot Star is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with DotStar. If not, see . + ------------------------------------------------------------------------*/ + +#ifndef _ADAFRUIT_CIRCUITPLAYGROUND_H_ +#define _ADAFRUIT_CIRCUITPLAYGROUND_H_ + +#include +#ifndef __INC_FASTSPI_LED2_H +#include "utility/Adafruit_CPlay_NeoPixel.h" +#endif +#include "utility/Adafruit_CPlay_LIS3DH.h" +#include "utility/Adafruit_CPlay_Mic.h" +#include "utility/Adafruit_CPlay_Speaker.h" +#include "utility/CP_Firmata.h" + +#ifdef __AVR__ // Circuit Playground 'classic' + #include "utility/CPlay_CapacitiveSensor.h" +#else + #include "utility/Adafruit_CPlay_FreeTouch.h" + #include "utility/IRLibCPE.h" +#endif + +#ifndef NOT_AN_INTERRUPT // Not defined in Arduino 1.0.5 + #define NOT_AN_INTERRUPT -1 +#endif + +#ifdef __AVR__ // Circuit Playground 'classic' + #define CPLAY_CAPSENSE_SHARED 30 + #define CPLAY_REDLED 13 +#ifndef __INC_FASTSPI_LED2_H + #define CPLAY_NEOPIXELPIN 17 +#endif + #define CPLAY_SLIDESWITCHPIN 21 + #define CPLAY_LEFTBUTTON 4 + #define CPLAY_RIGHTBUTTON 19 + #define CPLAY_LIGHTSENSOR A5 + #define CPLAY_THERMISTORPIN A0 + #define CPLAY_SOUNDSENSOR A4 + #define CPLAY_BUZZER 5 + #define CPLAY_LIS3DH_CS 8 + #define CPLAY_LIS3DH_INTERRUPT 7 + #define CPLAY_LIS3DH_ADDRESS 0x18 +#else // Circuit Playground Express + #define CPLAY_LEFTBUTTON 4 + #define CPLAY_RIGHTBUTTON 5 + #define CPLAY_SLIDESWITCHPIN 7 +#ifndef __INC_FASTSPI_LED2_H + #define CPLAY_NEOPIXELPIN 8 +#endif + #define CPLAY_REDLED 13 + #define CPLAY_IR_EMITTER 25 + #define CPLAY_IR_RECEIVER 26 + #define CPLAY_BUZZER A0 + #define CPLAY_LIGHTSENSOR A8 + #define CPLAY_THERMISTORPIN A9 + #define CPLAY_SOUNDSENSOR A4 // TBD I2S + #define CPLAY_LIS3DH_CS -1 // I2C + #define CPLAY_LIS3DH_INTERRUPT 27 + #define CPLAY_LIS3DH_ADDRESS 0x19 +#endif + +#define SERIESRESISTOR 10000 +// resistance at 25 degrees C +#define THERMISTORNOMINAL 10000 +// temp. for nominal resistance (almost always 25 C) +#define TEMPERATURENOMINAL 25 + +// The beta coefficient of the thermistor (usually 3000-4000) +#define BCOEFFICIENT 3380 +// the value of the 'other' resistor + +// Configuration to tune the color sensing logic: +#define LIGHT_SETTLE_MS 100 // Amount of time (in milliseconds) to wait between + // changing the pixel color and reading the light + // sensor. + + +class Adafruit_CircuitPlayground { + public: + boolean begin(uint8_t brightness=20); + +#ifndef __INC_FASTSPI_LED2_H + Adafruit_CPlay_NeoPixel strip; +#endif + Adafruit_CPlay_LIS3DH lis; + Adafruit_CPlay_Mic mic; + Adafruit_CPlay_Speaker speaker; + +#ifdef __AVR__ // Circuit Playground 'classic' + CPlay_CapacitiveSensor cap[8]; +#else + Adafruit_CPlay_FreeTouch cap[7]; + IRrecvPCI irReceiver; + IRdecode irDecoder; + IRsend irSend; +#endif + + boolean slideSwitch(void); + void redLED(boolean v); + void playTone(uint16_t freq, uint16_t time, boolean wait=true); + boolean leftButton(void); + boolean rightButton(void); + uint16_t lightSensor(void); + uint16_t soundSensor(void); + float temperature(void); + float temperatureF(void); + + uint16_t readCap(uint8_t p, uint8_t samples=10); + + // Accelerometer + float motionX(void); + float motionY(void); + float motionZ(void); + void setAccelRange(lis3dh_range_t range) { lis.setRange(range); } + void setAccelTap(uint8_t c, uint8_t clickthresh) + { lis.setClick(c, clickthresh, 10, 20, 255); } + uint8_t getAccelTap(void) { return (lis.getClick() >> 8) & 0x3; } + +#ifndef __INC_FASTSPI_LED2_H + // neopixels + void clearPixels(void) { strip.clear(); strip.show(); } + void setPixelColor(uint8_t p, uint32_t c) {strip.setPixelColor(p, c); strip.show();} + void setPixelColor(uint8_t p, uint8_t r, uint8_t g, uint8_t b) {strip.setPixelColor(p, r, g, b); strip.show();} + void setBrightness(uint16_t b){strip.setBrightness(b);} + + uint32_t colorWheel(uint8_t x); + + // Basic RGB color sensing with the light sensor and nearby neopixel. + // Both functions do the same thing and just differ in how they return the + // result, either as explicit RGB bytes or a 24-bit RGB color value. + void senseColor(uint8_t& red, uint8_t& green, uint8_t& blue); + uint32_t senseColor() { + // Use the individual color component color sense function and then recombine + // tbe components into a 24-bit color value. + uint8_t red, green, blue; + senseColor(red, green, blue); + return ((uint32_t)red << 16) | ((uint32_t)green << 8) | blue; + } +#endif + + boolean isExpress(void); + + private: + + +}; + + +extern Adafruit_CircuitPlayground CircuitPlayground; + +#endif From d051a82522117796ff8884cb3ad9fa3d61474377 Mon Sep 17 00:00:00 2001 From: Richard Bailey Date: Sat, 2 Feb 2019 20:59:43 -0800 Subject: [PATCH 7/8] Update Adafruit_Circuit_Playground.h --- Adafruit_Circuit_Playground.h | 72 +++++++++++++++++------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Adafruit_Circuit_Playground.h b/Adafruit_Circuit_Playground.h index f25a1ec..becb05d 100644 --- a/Adafruit_Circuit_Playground.h +++ b/Adafruit_Circuit_Playground.h @@ -1,31 +1,31 @@ /*! * @file Adafruit_Circuit_Playground.h - + * * This is part of Adafruit's CircuitPlayground driver for the Arduino platform. It is - + * designed specifically to work with the Adafruit CircuitPlayground boards. - + * - + * Adafruit invests time and resources providing this open source code, - + * please support Adafruit and open-source hardware by purchasing - + * products from Adafruit! - + * - + * Written by Ladyada and others for Adafruit Industries. - + * - + * BSD license, all text here must be included in any redistribution. - + * - + */ @@ -52,7 +52,7 @@ #ifdef __AVR__ // Circuit Playground 'classic' - + #include "utility/CPlay_CapacitiveSensor.h" #else @@ -149,22 +149,22 @@ -/*! +/*! @brief Configuration to tune the color sensing logic: Amount of time (in milliseconds) to wait between - + changing the pixel color and reading the light sensor. */ -#define LIGHT_SETTLE_MS 100 +#define LIGHT_SETTLE_MS 100 /**************************************************************************/ - /*! + /*! @brief Class that stores state and functions for interacting with CircuitPlayground hardware */ @@ -174,7 +174,7 @@ class Adafruit_CircuitPlayground { public: - boolean begin(uint8_t brightness=20); + bool begin(uint8_t brightness=20); #ifndef __INC_FASTSPI_LED2_H @@ -206,15 +206,15 @@ class Adafruit_CircuitPlayground { #endif - boolean slideSwitch(void); + bool slideSwitch(void); - void redLED(boolean v); + void redLED(bool v); - void playTone(uint16_t freq, uint16_t time, boolean wait=true); + void playTone(uint16_t freq, uint16_t time, bool wait=true); - boolean leftButton(void); + bool leftButton(void); - boolean rightButton(void); + bool rightButton(void); uint16_t lightSensor(void); @@ -241,7 +241,7 @@ class Adafruit_CircuitPlayground { /**************************************************************************/ -/*! +/*! @brief set the range of the MEMS accelerometer. @param range the range to set the accelerometer to. LIS3DH_RANGE_2_G @@ -259,12 +259,12 @@ class Adafruit_CircuitPlayground { /**************************************************************************/ -/*! +/*! @brief turn on tap detection. Tap detection can detect single taps or 'double taps' - + (like a double-click). @param c If c is 1 you will only detect single taps, one at a time. - + If c is 2, you will be able to detect both single taps and double taps. @param clickthresh the threshold over which to register a tap @@ -273,18 +273,18 @@ class Adafruit_CircuitPlayground { /**************************************************************************/ - void setAccelTap(uint8_t c, uint8_t clickthresh) + void setAccelTap(uint8_t c, uint8_t clickthresh) { lis.setClick(c, clickthresh, 10, 20, 255); } /**************************************************************************/ -/*! +/*! @brief test whether or not a tap has been detected @return 0 if no tap is detected, 1 if a single tap is detected, - and 2 or 3 if double tap is detected. + and 2 or 3 if double tap is detected. */ @@ -299,7 +299,7 @@ class Adafruit_CircuitPlayground { /**************************************************************************/ -/*! +/*! @brief turn off all neopixels on the board */ @@ -311,7 +311,7 @@ class Adafruit_CircuitPlayground { /**************************************************************************/ -/*! +/*! @brief set the color of a neopixel on the board @param p the pixel to set. Pixel 0 is above the pad labeled 'GND' right next to the @@ -332,7 +332,7 @@ class Adafruit_CircuitPlayground { /**************************************************************************/ /*! - + @brief set the color of a neopixel on the board @param p the pixel to set. Pixel 0 is above the pad labeled 'GND' right next to the @@ -345,7 +345,7 @@ class Adafruit_CircuitPlayground { @param g a 0 to 255 value corresponding to the green component of the desired color. - @param b a 0 to 255 value corresponding to the blue component of the desired color. + @param b a 0 to 255 value corresponding to the blue component of the desired color. */ @@ -401,7 +401,7 @@ class Adafruit_CircuitPlayground { /**************************************************************************/ -/*! +/*! @brief detect a color using the onboard light sensor @return a 24 bit color. The most significant byte is red, followed by green, and @@ -430,7 +430,7 @@ class Adafruit_CircuitPlayground { #endif - boolean isExpress(void); + bool isExpress(void); From 1b56a89834258a534c0483a436fcd695ccb99f47 Mon Sep 17 00:00:00 2001 From: Richard Bailey Date: Thu, 12 Mar 2020 18:18:46 -0700 Subject: [PATCH 8/8] update readme.md --- README.md | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 122 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8077aca..c85c644 100644 --- a/README.md +++ b/README.md @@ -6,17 +6,134 @@ library for Circuit Playground board that will disable the neopixel portions if ## I created this fork because I perfer to use FastLED to control addressable leds. To use FastLED make sure the #include is before this library - +# Adafruit CircuitPlayground Library [![Build Status](https://travis-ci.com/adafruit/Adafruit_CircuitPlayground.svg?branch=master)](https://travis-ci.com/adafruit/Adafruit_CircuitPlayground) +## Description + +All in one library to control Adafruit's Circuit Playground board. Requires no other dependencies and exposes all Circuit Playground components in a simple to use class. Adafruit Circuit Playground Express is a high-level library that provides objects that represent CircuitPlayground hardware. + +## Installation + +### First Method + +![image](https://user-images.githubusercontent.com/36513474/68966019-f1521f00-07fe-11ea-97b6-78b621e5e2e4.png) + +1. In the Arduino IDE, navigate to Sketch > Include Library > Manage Libraries +1. Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation. +1. Then search for Circuit playground using the search bar. +1. Click on the text area and then select the specific version and install it. + +### Second Method + +1. Navigate to the [Releases page](https://github.com/adafruit/Adafruit_CircuitPlayground/releases). +1. Download the latest release. +1. Extract the zip file +1. In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library + +## Features + +- ### Complete Package + + Everything that is needed to run Arduino code on Circuit Playground is wrapped up into a tidy library that integrates all the sensing and lighting. + +- ### Self-contained + + Requires no other dependencies and exposes all Circuit Playground components in a simple to use class. + +- ### High-Level Library + + This high-level library provides objects that represent CircuitPlayground hardware. + +- ### Give back + + The library is free; you don’t have to pay for anything. However, if you want to support the development, or just thank the author of the library by purchasing products from Adafruit! + Not only you’ll encourage the development of the library, but you’ll also learn how to best use the library and probably some C++ too + +- ### MIT License + + Adafruit playground library is open-source and uses one of the most permissive licenses so you can use it on any project. + + - Commercial use + - Modification + - Distribution + - Private use + +## Functions + +- begin() +- readCap() +- redLED() +- slideSwitch() +- leftButton() +- rightButton() +- playTone() +- lightSensor() +- soundSensor() +- motionX() +- motionY() +- motionZ() +- temperature() +- temperatureF() +- colorWheel() +- sensorColor() +- isExpress() + +## Examples + + There are many examples implemented in this library. One of the examples is below. You can find other examples [here](https://github.com/adafruit/Adafruit_CircuitPlayground/tree/master/examples) + + soundPressureLevel.ino + +```C++ +#include +void setup() { + CircuitPlayground.begin(); + Serial.begin(115200); +} +void loop() { + Serial.println(CircuitPlayground.mic.soundPressureLevel(50)); +} +``` + +## Contributing + +If you want to contribute to this project: + +- Report bugs and errors +- Ask for enhancements +- Create issues and pull requests +- Tell others about this library +- Contribute new protocols + +Please read [CONTRIBUTING.md](https://github.com/adafruit/Adafruit_CircuitPlayground/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. + +## Credits + +The author and maintainer of this library are Limor Fried/Ladyada and others for Adafruit Industries . + +Based on previous work by: + +- T. DiCola +- P. Y. Dragon +- deanm1278 +- C. Nelson +- E. Saadia +- per1234 +- driveblock +- C. Young +- D. Cogliano + This is a library for the Adafruit CircuitPlayground boards: - * https://www.adafruit.com/products/3333 - * https://www.adafruit.com/product/3000 + +- [Circuit Playground Express](https://www.adafruit.com/products/3333) +- [Circuit Playground Classic](https://www.adafruit.com/product/3000) Check out the links above for our tutorials and wiring diagrams. Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! -Written by Limor Fried/Ladyada and others for Adafruit Industries. -MIT license, all text above must be included in any redistribution +## License + +This library is licensed under [MIT license](https://opensource.org/licenses/MIT). All text above must be included in any redistribution.