You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
5 years ago
|
// Adafruit Circuit Playground speaker library
|
||
|
// by Phil Burgess / Paint Your Dragon.
|
||
|
|
||
|
#ifndef ADAFRUIT_CPLAY_SPEAKER_H
|
||
|
#define ADAFRUIT_CPLAY_SPEAKER_H
|
||
|
|
||
|
#include <Arduino.h>
|
||
|
|
||
|
#ifdef __AVR__
|
||
|
#else // circuit playground express has nicer amp w/shutdown
|
||
|
#define CPLAY_SPEAKER_SHUTDOWN 11 ///< shutdown pin (Express boards only)
|
||
|
#endif
|
||
|
|
||
|
/**************************************************************************/
|
||
|
/*!
|
||
|
@brief Class that stores state and functions for the speaker on CircuitPlayground boards
|
||
|
*/
|
||
|
/**************************************************************************/
|
||
|
class Adafruit_CPlay_Speaker {
|
||
|
public:
|
||
|
Adafruit_CPlay_Speaker(void) { started = false; };
|
||
|
void begin(void),
|
||
|
end(void),
|
||
|
set(uint8_t value),
|
||
|
playSound(const uint8_t *data, uint32_t length, uint16_t sampleRate, boolean tenBit=false),
|
||
|
say(const uint8_t *addr);
|
||
|
|
||
|
void enable(boolean e);
|
||
|
|
||
|
/**************************************************************************/
|
||
|
/*!
|
||
|
@brief disable the speaker.
|
||
|
@note this function only has an effect on 'Express' boards
|
||
|
*/
|
||
|
/**************************************************************************/
|
||
|
void off(void) { enable(false); };
|
||
|
|
||
|
/**************************************************************************/
|
||
|
/*!
|
||
|
@brief enable the speaker.
|
||
|
@note this function only has an effect on 'Express' boards
|
||
|
*/
|
||
|
/**************************************************************************/
|
||
|
void on(void) { enable(true); };
|
||
|
|
||
|
private:
|
||
|
boolean started;
|
||
|
};
|
||
|
|
||
|
#endif // ADAFRUIT_CPLAY_SPEAKER_H
|