From 0b717286f2809133a24513ae2676a33aa7068e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 21 Mar 2023 15:08:31 +0100 Subject: [PATCH 1/2] Add Documentation Add docs for the ArduinoAdvanced library, including: - DAC class - ADC class - SampleBuffer class --- docs/api.md | 403 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/readme.md | 12 ++ 2 files changed, 415 insertions(+) create mode 100644 docs/api.md create mode 100644 docs/readme.md diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..a67bf97 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,403 @@ +# Arduino Advanced Analog Library + +## AdvancedADC + +### `AdvancedADC` + +Creates an object associated to a specific pin. + +#### Syntax + +``` +AdvancedADC adc(analogPin); +``` + +#### Parameters + +- Pin `A0` through `A11` can be associated. + +#### Returns + +Nothing. + +### `begin()` + + +Initialises the DAC with the specific parameters. The `begin()` method is firstly used to initialize the library. + +If reconfigured during program execution, use `stop()` first. + +#### Syntax + +``` +adc0.begin(resolution, sample_rate, n_samples, n_buffers) +``` + +#### Parameters + +- `enum` - resolution (choose from 8, 10, 12, 14, 16 bit) + - `AN_RESOLUTION_8` + - `AN_RESOLUTION_10` + - `AN_RESOLUTION_12` + - `AN_RESOLUTION_14` + - `AN_RESOLUTION_16` +- `int` - frequency +- `int` - n_samples +- `int` - n_buffers + +#### Returns + +1 on success, 0 on failure. + +### `available()` + +Bool to check if there's any available data on the ADC channel. + +#### Syntax + +``` +if(adc0.available()){} +``` + +#### Parameters + +None. + +#### Returns + +1 on success, 0 on failure. + +### `read()` + +Reads the first available byte in the buffer. + +### `stop()` + +Stops the ADC and buffer transfer, and releases any memory allocated for the buffer array. + +#### Syntax + +``` +dac.stop() +``` + +#### Returns + +- `1` + +## AdvancedDAC + +### `AdvancedDAC` + + +Creates a DAC object on a specific pin. + +#### Syntax + +``` +AdvancedDAC dac0(A12); +AdvancedDAC dac1(A13); +``` + +#### Parameters + +- `A12` or `A13` (DAC0 or DAC1 channels). + +#### Returns + +Nothing. + +### `begin()` + + +Initialises the DAC with the specific parameters. The `begin()` method is firstly used to initialize the library. + +If reconfigured during program execution, use `stop()` first. + +#### Syntax + +``` +dac0.begin(resolution, frequency, n_samples, n_buffers) +``` + +#### Parameters + +- `enum` - resolution (choose from 8, 10, 12 bit) + - `AN_RESOLUTION_8` + - `AN_RESOLUTION_10` + - `AN_RESOLUTION_12` +- `int` - frequency +- `int` - n_samples +- `int` - n_buffers + +#### Returns + +1 on success, 0 on failure. + +### `available()` + +Checks if the DAC channel is available to write to. + +#### Syntax + +``` +if(dac0.available()){} +``` + +#### Parameters + +None. + +#### Returns + +1 on success, 0 on failure. + + +### `dequeue()` + + +Creates a buffer object and waits until a buffer to become available. + +#### Syntax + +``` +SampleBuffer buf = dac.dequeue(); + +for (size_t i=0; i +``` + From e7edcdd49c27a7b8328bcf56370f41d692a2c8e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20S=C3=B6derby?= <35461661+karlsoderby@users.noreply.github.com> Date: Tue, 21 Mar 2023 15:13:23 +0100 Subject: [PATCH 2/2] spellchk + fix typos --- docs/api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api.md b/docs/api.md index a67bf97..fa82b7e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -23,7 +23,7 @@ Nothing. ### `begin()` -Initialises the DAC with the specific parameters. The `begin()` method is firstly used to initialize the library. +Initializes the ADC with the specific parameters. The `begin()` method is firstly used to initialize the library. If reconfigured during program execution, use `stop()` first. @@ -78,7 +78,7 @@ Stops the ADC and buffer transfer, and releases any memory allocated for the buf #### Syntax ``` -dac.stop() +adc.stop() ``` #### Returns @@ -110,7 +110,7 @@ Nothing. ### `begin()` -Initialises the DAC with the specific parameters. The `begin()` method is firstly used to initialize the library. +Initializes the DAC with the specific parameters. The `begin()` method is firstly used to initialize the library. If reconfigured during program execution, use `stop()` first.