Skip to content

Commit e2e5cf3

Browse files
committed
Documentation add used Arduino Classes
1 parent 839ff62 commit e2e5cf3

File tree

9 files changed

+327
-6
lines changed

9 files changed

+327
-6
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Doxyfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ EXTRACT_PACKAGE = NO
510510
# included in the documentation.
511511
# The default value is: NO.
512512

513-
EXTRACT_STATIC = NO
513+
EXTRACT_STATIC = YES
514514

515515
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
516516
# locally in source files will be included in the documentation. If set to NO,
@@ -535,7 +535,7 @@ EXTRACT_LOCAL_METHODS = NO
535535
# are hidden.
536536
# The default value is: NO.
537537

538-
EXTRACT_ANON_NSPACES = NO
538+
EXTRACT_ANON_NSPACES = YES
539539

540540
# If this flag is set to YES, the name of an unnamed parameter in a declaration
541541
# will be determined by the corresponding definition. By default unnamed
@@ -865,7 +865,7 @@ WARN_LOGFILE =
865865
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
866866
# Note: If this tag is empty the current directory is searched.
867867

868-
INPUT = README.md src examples
868+
INPUT = README.md docs/ext src examples
869869

870870
# This tag can be used to specify the character encoding of the source files
871871
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

docs/.DS_Store

2 KB
Binary file not shown.

docs/ext/Print.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
Copyright (c) 2016 Arduino LLC. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#pragma once
20+
21+
#include <inttypes.h>
22+
#include <stdio.h> // for size_t
23+
24+
#include "WString.h"
25+
#include "Printable.h"
26+
27+
#define DEC 10
28+
#define HEX 16
29+
#define OCT 8
30+
#define BIN 2
31+
32+
33+
class Print
34+
{
35+
private:
36+
int write_error;
37+
size_t printNumber(unsigned long, uint8_t);
38+
size_t printULLNumber(unsigned long long, uint8_t);
39+
size_t printFloat(double, int);
40+
protected:
41+
void setWriteError(int err = 1) { write_error = err; }
42+
public:
43+
Print() : write_error(0) {}
44+
45+
int getWriteError() { return write_error; }
46+
void clearWriteError() { setWriteError(0); }
47+
48+
virtual size_t write(uint8_t) = 0;
49+
size_t write(const char *str) {
50+
if (str == NULL) return 0;
51+
return write((const uint8_t *)str, ::strlen(str));
52+
}
53+
virtual size_t write(const uint8_t *buffer, size_t size);
54+
size_t write(const char *buffer, size_t size) {
55+
return write((const uint8_t *)buffer, size);
56+
}
57+
58+
// default to zero, meaning "a single write may block"
59+
// should be overriden by subclasses with buffering
60+
virtual int availableForWrite() { return 0; }
61+
62+
size_t print(const __FlashStringHelper *);
63+
size_t print(const String &);
64+
size_t print(const char[]);
65+
size_t print(char);
66+
size_t print(unsigned char, int = DEC);
67+
size_t print(int, int = DEC);
68+
size_t print(unsigned int, int = DEC);
69+
size_t print(long, int = DEC);
70+
size_t print(unsigned long, int = DEC);
71+
size_t print(long long, int = DEC);
72+
size_t print(unsigned long long, int = DEC);
73+
size_t print(double, int = 2);
74+
size_t print(const Printable&);
75+
76+
size_t println(const __FlashStringHelper *);
77+
size_t println(const String &s);
78+
size_t println(const char[]);
79+
size_t println(char);
80+
size_t println(unsigned char, int = DEC);
81+
size_t println(int, int = DEC);
82+
size_t println(unsigned int, int = DEC);
83+
size_t println(long, int = DEC);
84+
size_t println(unsigned long, int = DEC);
85+
size_t println(long long, int = DEC);
86+
size_t println(unsigned long long, int = DEC);
87+
size_t println(double, int = 2);
88+
size_t println(const Printable&);
89+
size_t println(void);
90+
91+
virtual void flush() { /* Empty implementation for backward compatibility */ }
92+
};
93+

docs/ext/Printable.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright (c) 2016 Arduino LLC. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#pragma once
20+
21+
#include <stdlib.h>
22+
23+
24+
class Print;
25+
26+
/** The Printable class provides a way for new classes to allow themselves to be printed.
27+
By deriving from Printable and implementing the printTo method, it will then be possible
28+
for users to print out instances of this class by passing them into the usual
29+
Print::print and Print::println methods.
30+
*/
31+
32+
class Printable
33+
{
34+
public:
35+
virtual size_t printTo(Print& p) const = 0;
36+
};
37+

docs/ext/Stream.h

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
Stream.h - base class for character-based streams.
3+
Copyright (c) 2010 David A. Mellis. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
19+
parsing functions based on TextFinder library by Michael Margolis
20+
*/
21+
22+
#pragma once
23+
24+
#include <inttypes.h>
25+
#include "Print.h"
26+
27+
// compatability macros for testing
28+
/*
29+
#define getInt() parseInt()
30+
#define getInt(ignore) parseInt(ignore)
31+
#define getFloat() parseFloat()
32+
#define getFloat(ignore) parseFloat(ignore)
33+
#define getString( pre_string, post_string, buffer, length)
34+
readBytesBetween( pre_string, terminator, buffer, length)
35+
*/
36+
37+
// This enumeration provides the lookahead options for parseInt(), parseFloat()
38+
// The rules set out here are used until either the first valid character is found
39+
// or a time out occurs due to lack of input.
40+
enum LookaheadMode{
41+
SKIP_ALL, // All invalid characters are ignored.
42+
SKIP_NONE, // Nothing is skipped, and the stream is not touched unless the first waiting character is valid.
43+
SKIP_WHITESPACE // Only tabs, spaces, line feeds & carriage returns are skipped.
44+
};
45+
46+
#define NO_IGNORE_CHAR '\x01' // a char not found in a valid ASCII numeric field
47+
48+
class Stream : public Print
49+
{
50+
protected:
51+
unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read
52+
unsigned long _startMillis; // used for timeout measurement
53+
int timedRead(); // private method to read stream with timeout
54+
int timedPeek(); // private method to peek stream with timeout
55+
int peekNextDigit(LookaheadMode lookahead, bool detectDecimal); // returns the next numeric digit in the stream or -1 if timeout
56+
57+
public:
58+
virtual int available() = 0;
59+
virtual int read() = 0;
60+
virtual int peek() = 0;
61+
62+
Stream() {_timeout=1000;}
63+
64+
// parsing methods
65+
66+
void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
67+
unsigned long getTimeout(void) { return _timeout; }
68+
69+
bool find(const char *target); // reads data from the stream until the target string is found
70+
bool find(const uint8_t *target) { return find ((const char *)target); }
71+
// returns true if target string is found, false if timed out (see setTimeout)
72+
73+
bool find(const char *target, size_t length); // reads data from the stream until the target string of given length is found
74+
bool find(const uint8_t *target, size_t length) { return find ((const char *)target, length); }
75+
// returns true if target string is found, false if timed out
76+
77+
bool find(char target) { return find (&target, 1); }
78+
79+
bool findUntil(const char *target, const char *terminator); // as find but search ends if the terminator string is found
80+
bool findUntil(const uint8_t *target, const char *terminator) { return findUntil((const char *)target, terminator); }
81+
82+
bool findUntil(const char *target, size_t targetLen, const char *terminate, size_t termLen); // as above but search ends if the terminate string is found
83+
bool findUntil(const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) {return findUntil((const char *)target, targetLen, terminate, termLen); }
84+
85+
long parseInt(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR);
86+
// returns the first valid (long) integer value from the current position.
87+
// lookahead determines how parseInt looks ahead in the stream.
88+
// See LookaheadMode enumeration at the top of the file.
89+
// Lookahead is terminated by the first character that is not a valid part of an integer.
90+
// Once parsing commences, 'ignore' will be skipped in the stream.
91+
92+
float parseFloat(LookaheadMode lookahead = SKIP_ALL, char ignore = NO_IGNORE_CHAR);
93+
// float version of parseInt
94+
95+
size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer
96+
size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
97+
// terminates if length characters have been read or timeout (see setTimeout)
98+
// returns the number of characters placed in the buffer (0 means no valid data found)
99+
100+
size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character
101+
size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
102+
// terminates if length characters have been read, timeout, or if the terminator character detected
103+
// returns the number of characters placed in the buffer (0 means no valid data found)
104+
105+
// Arduino String functions to be added here
106+
String readString();
107+
String readStringUntil(char terminator);
108+
109+
protected:
110+
long parseInt(char ignore) { return parseInt(SKIP_ALL, ignore); }
111+
float parseFloat(char ignore) { return parseFloat(SKIP_ALL, ignore); }
112+
// These overload exists for compatibility with any class that has derived
113+
// Stream and used parseFloat/Int with a custom ignore character. To keep
114+
// the public API simple, these overload remains protected.
115+
116+
struct MultiTarget {
117+
const char *str; // string you're searching for
118+
size_t len; // length of string you're searching for
119+
size_t index; // index used by the search routine.
120+
};
121+
122+
// This allows you to search for an arbitrary number of strings.
123+
// Returns index of the target that is found first or -1 if timeout occurs.
124+
int findMulti(struct MultiTarget *targets, int tCount);
125+
};
126+
127+
#undef NO_IGNORE_CHAR
128+

examples/streams-memory_raw-i2s_external_dac/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ Unlike in the other examples I am using the typed __StreamCopyT<int16_t>__ class
99
Please note that you must compile this sketch with the __Partition Scheme: Huge App__!
1010

1111

12-
For my tests I am using the 24-bit PCM5102 PCM5102A Stereo DAC Digital-to-analog Converter PLL Voice Module pHAT
12+
### External DAC:
13+
1314
![DAC](https://pschatzmann.github.io/arduino-audio-tools/resources/dac.jpeg)
1415

15-
### External DAC:
16+
For my tests I am using the 24-bit PCM5102 PCM5102A Stereo DAC Digital-to-analog Converter PLL Voice Module pHAT
1617

1718
I am just using the default pins defined by the framework. However I could change them with the help of the config object. The mute pin can be defined in the constructor of the I2SStream - by not defining anything we use the default which is GPIO23
1819

examples/streams-url_raw-I2S_external_dac/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ We are reading a raw audio file from the Intenet and write the data to the I2S i
66

77

88
### External DAC:
9-
9+
10+
![DAC](https://pschatzmann.github.io/arduino-audio-tools/resources/dac.jpeg)
11+
12+
13+
I am just using the default pins defined by the framework. However I could change them with the help of the config object. The mute pin can be defined in the constructor of the I2SStream - by not defining anything we use the default which is GPIO23
14+
1015
| DAC | ESP32
1116
| --------| ---------------
1217
| VDD | 5V
@@ -15,7 +20,14 @@ We are reading a raw audio file from the Intenet and write the data to the I2S i
1520
| L/R | GND
1621
| WS | WS (GPIO15)
1722
| SCK | BCK (GPIO14)
23+
| FMT | GND
24+
| XSMT | GPIO23
1825

1926

27+
- DEMP - De-emphasis control for 44.1kHz sampling rate(1): Off (Low) / On (High)
28+
- FLT - Filter select : Normal latency (Low) / Low latency (High)
29+
- SCK - System clock input (probably SCL on your board).
30+
- FMT - Audio format selection : I2S (Low) / Left justified (High)
31+
- XSMT - Soft mute control(1): Soft mute (Low) / soft un-mute (High)
2032

2133

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @file url_raw-I2S_external_dac.ino
3+
* @author Phil Schatzmann
4+
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/url_raw-I2S_externel_dac/README.md
5+
* @author Phil Schatzmann
6+
* @copyright GPLv3
7+
*/
8+
9+
#include "WiFi.h"
10+
#include "AudioTools.h"
11+
12+
using namespace audio_tools;
13+
14+
UrlStream music; // Music Stream
15+
I2SStream i2s; // I2S as Stream
16+
StreamCopy copier(i2s, music, 1024); // copy music to i2s_stream
17+
18+
19+
// Arduino Setup
20+
void setup(void) {
21+
Serial.begin(115200);
22+
23+
// connect to WIFI
24+
WiFi.begin("Phil Schatzmann", "sabrina01");
25+
while (WiFi.status() != WL_CONNECTED){
26+
Serial.print(".");
27+
delay(500);
28+
}
29+
30+
// open music stream
31+
music.begin("https://pschatzmann.github.io/arduino-audio-tools/resources/audio-8000.raw");
32+
33+
// start I2S with external DAC
34+
Serial.println("\nstarting I2S...");
35+
I2SConfig cfg = i2s.defaultConfig(TX_MODE);
36+
cfg.sample_rate = 8000;
37+
i2s.begin(cfg);
38+
}
39+
40+
// Arduino loop - repeated processing: copy input stream to output stream
41+
void loop() {
42+
int len = copier.copy();
43+
if (len){
44+
Serial.print(".");
45+
} else {
46+
i2s.end();
47+
Serial.println("\nCopy ended");
48+
delay(10000);
49+
}
50+
}

0 commit comments

Comments
 (0)