Adafruit Library
Public Member Functions | Public Attributes | List of all members
Adafruit_CircuitPlayground Class Reference

Class that stores state and functions for interacting with CircuitPlayground hardware. More...

#include <Adafruit_Circuit_Playground.h>

Public Member Functions

bool begin (uint8_t brightness=20)
 Set up the CircuitPlayground hardware. More...
 
bool slideSwitch (void)
 read the slide switch More...
 
void redLED (bool v)
 turn on or off the red LED on pin #13 More...
 
void playTone (uint16_t freq, uint16_t time, bool wait=true)
 play a tone on the onboard buzzer More...
 
bool leftButton (void)
 read the left button More...
 
bool rightButton (void)
 read the right button More...
 
uint16_t lightSensor (void)
 read the onboard lightsensor More...
 
int16_t soundSensor (void)
 read the onboard sound sensor. A reading of ~0 is silent, and loud audio will result in a reading between -500 and 500 or so. More...
 
float temperature (void)
 read the onboard thermistor. More...
 
float temperatureF (void)
 read the onboard thermistor. More...
 
uint16_t readCap (uint8_t p, uint8_t samples=10)
 read capacitive touch sensor More...
 
float motionX (void)
 read the X parameter of the onboard accelerometer. Value returned is defined by setAccelRange(). More...
 
float motionY (void)
 read the Y parameter of the onboard accelerometer. Value returned is defined by setAccelRange(). More...
 
float motionZ (void)
 read the Z parameter of the onboard accelerometer. Value returned is defined by setAccelRange(). More...
 
void setAccelRange (lis3dh_range_t range)
 set the range of the MEMS accelerometer. More...
 
void setAccelTap (uint8_t c, uint8_t clickthresh)
 turn on tap detection. Tap detection can detect single taps or 'double taps' (like a double-click). More...
 
uint8_t getAccelTap (void)
 test whether or not a tap has been detected More...
 
void clearPixels (void)
 turn off all neopixels on the board
 
void setPixelColor (uint8_t p, uint32_t c)
 set the color of a neopixel on the board More...
 
void setPixelColor (uint8_t p, uint8_t r, uint8_t g, uint8_t b)
 set the color of a neopixel on the board More...
 
void setBrightness (uint16_t b)
 set the global brightness of all neopixels. More...
 
uint8_t sine8 (uint8_t x)
 Get a sinusoidal value from a sine table. More...
 
uint8_t gamma8 (uint8_t x)
 Get a gamma-corrected value from a gamma table. More...
 
uint32_t colorWheel (uint8_t x)
 get a color value from the color wheel. More...
 
void senseColor (uint8_t &red, uint8_t &green, uint8_t &blue)
 detect a color value from the light sensor More...
 
uint32_t senseColor ()
 detect a color using the onboard light sensor More...
 
bool isExpress (void)
 check whether or not this device is a CircuitPlayground Express. More...
 

Public Attributes

Adafruit_CPlay_NeoPixel strip
 the neopixel strip object
 
Adafruit_CPlay_LIS3DH lis
 the accelerometer object
 
Adafruit_CPlay_Mic mic
 the microphone object
 
Adafruit_CPlay_Speaker speaker
 the speaker object
 
Adafruit_CPlay_FreeTouch cap [7]
 the array of capacitive touch sensors
 
IRrecvPCI irReceiver
 the IR receiver object
 
IRdecode irDecoder
 the IR decoder object
 
IRsend irSend
 the IR send object
 

Detailed Description

Class that stores state and functions for interacting with CircuitPlayground hardware.

Member Function Documentation

◆ begin()

bool Adafruit_CircuitPlayground::begin ( uint8_t  brightness = 20)

Set up the CircuitPlayground hardware.

Parameters
brightnessOptional brightness to set the neopixels to
Returns
True if device is set up, false on any failure

◆ slideSwitch()

bool Adafruit_CircuitPlayground::slideSwitch ( void  )

read the slide switch

Returns
true if slide switch in set, false if not

◆ redLED()

void Adafruit_CircuitPlayground::redLED ( bool  v)

turn on or off the red LED on pin #13

Parameters
vpass true to turn LED on, false to turn LED off

◆ playTone()

void Adafruit_CircuitPlayground::playTone ( uint16_t  freq,
uint16_t  time,
bool  wait = true 
)

play a tone on the onboard buzzer

Parameters
freqthe frequency to play
timethe duration of the tone in milliseconds
waitOptional flag to wait for time milliseconds after playing the tone. Defaults to true.
Note
The driver circuitry is an on/off transistor driver, so you will only be able to play square waves. It is also not the same loudness over all frequencies but is designed to be the loudest at around 4 KHz

◆ leftButton()

bool Adafruit_CircuitPlayground::leftButton ( void  )

read the left button

Returns
true if button is pressed, false if not

◆ rightButton()

bool Adafruit_CircuitPlayground::rightButton ( void  )

read the right button

Returns
true if button is pressed, false if not

◆ lightSensor()

uint16_t Adafruit_CircuitPlayground::lightSensor ( void  )

read the onboard lightsensor

Returns
value between 0 and 1023 read from the light sensor
Note
1000 Lux will roughly read as 2 Volts (or about 680 as a raw analog reading). A reading of about 300 is common for most indoor light levels. Note that outdoor daylight is 10,000 Lux or even higher, so this sensor is best suited for indoor light levels!

◆ soundSensor()

int16_t Adafruit_CircuitPlayground::soundSensor ( void  )

read the onboard sound sensor. A reading of ~0 is silent, and loud audio will result in a reading between -500 and 500 or so.

Returns
value of the sound sensor

◆ temperature()

float Adafruit_CircuitPlayground::temperature ( void  )

read the onboard thermistor.

Returns
temperature reading in Centigrade.

◆ temperatureF()

float Adafruit_CircuitPlayground::temperatureF ( void  )

read the onboard thermistor.

Returns
temperature reading in Farenheight.

◆ readCap()

uint16_t Adafruit_CircuitPlayground::readCap ( uint8_t  p,
uint8_t  samples = 10 
)

read capacitive touch sensor

Parameters
pthe pin to read. Must be a captouch enabled pin.
samplesOptional number of samples to take. Defaults to 10.
Returns
measured captouch value

◆ motionX()

float Adafruit_CircuitPlayground::motionX ( void  )

read the X parameter of the onboard accelerometer. Value returned is defined by setAccelRange().

Returns
X value of the accelerometer

◆ motionY()

float Adafruit_CircuitPlayground::motionY ( void  )

read the Y parameter of the onboard accelerometer. Value returned is defined by setAccelRange().

Returns
Y value of the accelerometer

◆ motionZ()

float Adafruit_CircuitPlayground::motionZ ( void  )

read the Z parameter of the onboard accelerometer. Value returned is defined by setAccelRange().

Returns
the Z value of the onboard accelerometer

◆ setAccelRange()

void Adafruit_CircuitPlayground::setAccelRange ( lis3dh_range_t  range)
inline

set the range of the MEMS accelerometer.

Parameters
rangethe range to set the accelerometer to. LIS3DH_RANGE_2_G is the smallest (+-2G) but will give the greatest precision, while LIS3DH_RANGE_8_G is the largest (+-8G) but with the lease precision. LIS3DH_RANGE_4_G is in the middle.

◆ setAccelTap()

void Adafruit_CircuitPlayground::setAccelTap ( uint8_t  c,
uint8_t  clickthresh 
)
inline

turn on tap detection. Tap detection can detect single taps or 'double taps' (like a double-click).

Parameters
cIf 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.
clickthreshthe threshold over which to register a tap

◆ getAccelTap()

uint8_t Adafruit_CircuitPlayground::getAccelTap ( void  )
inline

test whether or not a tap has been detected

Returns
0 if no tap is detected, 1 if a single tap is detected, and 2 or 3 if double tap is detected.

◆ setPixelColor() [1/2]

void Adafruit_CircuitPlayground::setPixelColor ( uint8_t  p,
uint32_t  c 
)
inline

set the color of a neopixel on the board

Parameters
pthe pixel to set. Pixel 0 is above the pad labeled 'GND' right next to the USB connector, while pixel 9 is above the pad labeled '3.3V' on the other side of the USB connector.
ca 24bit color value to set the pixel to

◆ setPixelColor() [2/2]

void Adafruit_CircuitPlayground::setPixelColor ( uint8_t  p,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inline

set the color of a neopixel on the board

Parameters
pthe pixel to set. Pixel 0 is above the pad labeled 'GND' right next to the USB connector, while pixel 9 is above the pad labeled '3.3V' on the other side of the USB connector.
ra 0 to 255 value corresponding to the red component of the desired color.
ga 0 to 255 value corresponding to the green component of the desired color.
ba 0 to 255 value corresponding to the blue component of the desired color.

◆ setBrightness()

void Adafruit_CircuitPlayground::setBrightness ( uint16_t  b)
inline

set the global brightness of all neopixels.

Parameters
ba 0 to 255 value corresponding to the desired brightness. The default brightness of all neopixels is 30.

◆ sine8()

uint8_t Adafruit_CircuitPlayground::sine8 ( uint8_t  x)
inline

Get a sinusoidal value from a sine table.

Parameters
xa 0 to 255 value corresponding to an index to the sine table
Returns
An 8-bit sinusoidal value back

◆ gamma8()

uint8_t Adafruit_CircuitPlayground::gamma8 ( uint8_t  x)
inline

Get a gamma-corrected value from a gamma table.

Parameters
xa 0 to 255 value corresponding to an index to the gamma table
Returns
An 8-bit gamma-corrected value back

◆ colorWheel()

uint32_t Adafruit_CircuitPlayground::colorWheel ( uint8_t  WheelPos)

get a color value from the color wheel.

Parameters
WheelPosa value 0 to 255
Returns
a color value. The colours are a transition r - g - b - back to r.

◆ senseColor() [1/2]

void Adafruit_CircuitPlayground::senseColor ( uint8_t &  red,
uint8_t &  green,
uint8_t &  blue 
)

detect a color value from the light sensor

Parameters
redthe pointer to where the red component should be stored.
greenthe pointer to where the green component should be stored.
bluethe pointer to where the blue component should be stored.

◆ senseColor() [2/2]

uint32_t Adafruit_CircuitPlayground::senseColor ( )
inline

detect a color using the onboard light sensor

Returns
a 24 bit color. The most significant byte is red, followed by green, and the least significant byte is blue.

◆ isExpress()

bool Adafruit_CircuitPlayground::isExpress ( void  )

check whether or not this device is a CircuitPlayground Express.

Returns
True if the device is a CircuitPlayground Express, false if it is a 'classic'.

The documentation for this class was generated from the following files: