Skip to content

Commit 7a77b31

Browse files
authored
Declared new member functions ready(), start(), and clear()
ready() and start() are just the begin() function split into two pieces so you can setup the DMA and ADC without starting until later.
1 parent f7d081c commit 7a77b31

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/AdvancedADC.h

+11
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ class AdvancedADC {
5555
n_channels = n_pins;
5656
return begin(resolution, sample_rate, n_samples, n_buffers);
5757
}
58+
void clear(); //clears any existing DMA buffers from read queue
59+
int ready(uint32_t resolution, uint32_t sample_rate, size_t n_samples, size_t n_buffers);
60+
int ready(uint32_t resolution, uint32_t sample_rate, size_t n_samples, size_t n_buffers, size_t n_pins, pin_size_t *pins) {
61+
if (n_pins > AN_MAX_ADC_CHANNELS) n_pins = AN_MAX_ADC_CHANNELS;
62+
for (size_t i = 0; i < n_pins; ++i) {
63+
adc_pins[i] = analogPinToPinName(pins[i]);
64+
}
65+
n_channels = n_pins;
66+
return ready(resolution, sample_rate, n_samples, n_buffers);
67+
}
68+
int start(uint32_t sample_rate);
5869
int stop();
5970
};
6071

0 commit comments

Comments
 (0)