-
Notifications
You must be signed in to change notification settings - Fork 64
/
seesaw_spectrum.cpp
53 lines (48 loc) · 2.05 KB
/
seesaw_spectrum.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "seesaw_spectrum.h"
/**************************************************************************/
/*!
@brief Pull latest audio spectrum data from device.
*/
/**************************************************************************/
void seesaw_Audio_Spectrum::getData(void) {
read(SEESAW_SPECTRUM_BASE, SEESAW_SPECTRUM_RESULTS_LOWER, bins, 32, 0);
read(SEESAW_SPECTRUM_BASE, SEESAW_SPECTRUM_RESULTS_UPPER, &bins[32], 32, 0);
}
/**************************************************************************/
/*!
@brief Set the audio sampling rate.
@param value Sampling rate index, 0-31. Values outside this range
will be clipped on the Seesaw device side.
*/
/**************************************************************************/
void seesaw_Audio_Spectrum::setRate(uint8_t value) {
write8(SEESAW_SPECTRUM_BASE, SEESAW_SPECTRUM_RATE, value);
}
/**************************************************************************/
/*!
@brief Set the analog input channel.
@param value Channel index, 0-TBD (probably 1). Values outside the
valid range will be clipped on the Seesaw device side.
*/
/**************************************************************************/
void seesaw_Audio_Spectrum::setChannel(uint8_t value) {
write8(SEESAW_SPECTRUM_BASE, SEESAW_SPECTRUM_CHANNEL, value);
}
/**************************************************************************/
/*!
@brief Query the current audio sampling rate.
@return Sampling rate index, 0-31.
*/
/**************************************************************************/
uint8_t seesaw_Audio_Spectrum::getRate(void) {
return read8(SEESAW_SPECTRUM_BASE, SEESAW_SPECTRUM_RATE);
}
/**************************************************************************/
/*!
@brief Query the current analog input channel.
@return Active ADC channel, 0-TBD (probably 1).
*/
/**************************************************************************/
uint8_t seesaw_Audio_Spectrum::getChannel(void) {
return read8(SEESAW_SPECTRUM_BASE, SEESAW_SPECTRUM_CHANNEL);
}