Adafruit Library
seesaw_spectrum.h
1 #ifndef _SEESAW_SPECTRUM_H
2 #define _SEESAW_SPECTRUM_H
3 
4 #include "Adafruit_seesaw.h"
5 #include <Arduino.h>
6 
7 /**************************************************************************/
12 /**************************************************************************/
14 public:
15  /**************************************************************************/
20  /**************************************************************************/
21  seesaw_Audio_Spectrum(TwoWire *Wi = NULL) : Adafruit_seesaw(Wi) {}
22 
24 
25  /**************************************************************************/
33  /**************************************************************************/
34  bool begin(uint8_t addr = SEESAW_ADDRESS, int8_t flow = -1) {
35  if (Adafruit_seesaw::begin(addr, flow)) {
36  memset(bins, 0, sizeof bins);
37  return true;
38  }
39  return false;
40  }
41 
42  void getData(void); // Fetch latest audio spectrum data
43  void setRate(uint8_t value); // Set audio sampling rate 0-31
44  void setChannel(uint8_t value); // Set ADC input channel
45  uint8_t getRate(void); // Query current audio sampling rate 0-31
46  uint8_t getChannel(void); // Query current ADC channel
47 
48  /**************************************************************************/
55  /**************************************************************************/
56  uint8_t getLevel(uint8_t idx) const { return bins[idx < 64 ? idx : 63]; }
57 
58  /**************************************************************************/
63  /**************************************************************************/
64  uint8_t *getBuffer(void) const { return (uint8_t *)bins; }
65 
66 private:
67  uint8_t bins[64]; // Audio spectrum "bins"
68 };
69 
70 #endif // end _SEESAW_SPECTRUM_H
uint8_t getLevel(uint8_t idx) const
Get value of individual spectrum bin, as determined during most recent get_data() call...
Definition: seesaw_spectrum.h:56
bool begin(uint8_t addr=SEESAW_ADDRESS, int8_t flow=-1)
Begin communication with Seesaw audio spectrum device.
Definition: seesaw_spectrum.h:34
uint8_t getChannel(void)
Query the current analog input channel.
Definition: seesaw_spectrum.cpp:51
Class that stores state and functions for interacting with seesaw helper IC.
Definition: Adafruit_seesaw.h:235
uint8_t getRate(void)
Query the current audio sampling rate.
Definition: seesaw_spectrum.cpp:41
bool begin(uint8_t addr=SEESAW_ADDRESS, int8_t flow=-1, bool reset=true)
Start the seesaw.
Definition: Adafruit_seesaw.cpp:62
#define SEESAW_ADDRESS
Default Seesaw I2C address.
Definition: Adafruit_seesaw.h:31
void setChannel(uint8_t value)
Set the analog input channel.
Definition: seesaw_spectrum.cpp:31
seesaw_Audio_Spectrum(TwoWire *Wi=NULL)
seesaw_Audio_Spectrum class constructor.
Definition: seesaw_spectrum.h:21
void setRate(uint8_t value)
Set the audio sampling rate.
Definition: seesaw_spectrum.cpp:20
Class that stores state and functions for seesaw audio spectrum interface.
Definition: seesaw_spectrum.h:13
uint8_t * getBuffer(void) const
Get pointer to spectrum bin buffer directly. Use with caution!
Definition: seesaw_spectrum.h:64
void getData(void)
Pull latest audio spectrum data from device.
Definition: seesaw_spectrum.cpp:8