Skip to content

Commit b7560fc

Browse files
committed
Set initial volume
1 parent 594f0a1 commit b7560fc

File tree

8 files changed

+32
-13
lines changed

8 files changed

+32
-13
lines changed

examples/audiotools/audiotools-custom-max/audiotools-custom-max.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ StreamCopy copier(out, sound);
1818
void setup() {
1919
// Setup logging
2020
Serial.begin(115200);
21-
AudioLogger::instance().begin(Serial, AudioLogger::Info);
22-
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;
21+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
22+
LOGLEVEL_AUDIODRIVER = AudioDriverWarning;
2323

2424
// setup pins
2525
// - add i2c codec pins: scl, sda, port, (I2C object)

examples/audiotools/audiotools-custom-min/audiotools-custom-min.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ StreamCopy copier(out, sound);
1717
void setup() {
1818
// Setup logging
1919
Serial.begin(115200);
20-
AudioLogger::instance().begin(Serial, AudioLogger::Info);
21-
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;
20+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
21+
LOGLEVEL_AUDIODRIVER = AudioDriverWarning;
2222

2323
// initialize i2c because board has no i2c definition
2424
Wire.begin();

examples/audiotools/audiotools-standard/audiotools-standard.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ StreamCopy copier(out, sound);
1616
void setup() {
1717
// Setup logging
1818
Serial.begin(115200);
19-
AudioLogger::instance().begin(Serial, AudioLogger::Info);
20-
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;
19+
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
20+
LOGLEVEL_AUDIODRIVER = AudioDriverWarning;
2121

2222
// start I2S & codec with i2c and i2s configured above
2323
Serial.println("starting I2S...");

examples/custom/custom-max/custom-max.ino

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ DriverPins my_pins;
1111
AudioBoard board(AudioDriverES8388);
1212

1313
void setup() {
14+
// Setup logging
15+
Serial.begin(115200);
16+
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;
17+
1418
// add i2c codec pins: scl, sda, port
1519
my_pins.addI2C(CODEC, 32, 22, 0x20);
1620
// example add other pins: PA on gpio 21

examples/custom/custom-min/custom-min.ino

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
AudioBoard board(AudioDriverES8388);
1010

1111
void setup() {
12+
// Setup logging
13+
Serial.begin(115200);
14+
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;
15+
1216
// start I2C for the communication with the codec
1317
Wire.begin();
1418
// configure codec

examples/custom/custom-standard/custom-standard.ino

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include "AudioBoard.h"
77

88
void setup() {
9+
// Setup logging
10+
Serial.begin(115200);
11+
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;
12+
913
// configure codec
1014
CodecConfig cfg;
1115
cfg.adc_input = ADC_INPUT_LINE1;

src/AudioBoard.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class AudioBoard {
2323
}
2424

2525
bool begin(){
26-
return pins.begin() && driver->begin(codec_cfg, pins);
26+
bool result = pins.begin() && driver->begin(codec_cfg, pins);
27+
setVolume(DRIVER_DEFAULT_VOLUME);
28+
return result;
2729
}
2830

2931
bool begin(CodecConfig cfg) {

src/Common.h

+11-6
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@
77
* @defgroup enumerations Public enumeration types
88
*/
99

10-
/// Definitions for error constants.
11-
#define RESULT_OK 0 /*!< error_t value indicating success (no error) */
12-
#define RESULT_FAIL -1 /*!< Generic error_t code indicating failure */
13-
#define ERROR_INVALID_ARG 1
14-
#define I2C_END true
10+
// Default volume at startup
11+
#ifndef DRIVER_DEFAULT_VOLUME
12+
# define DRIVER_DEFAULT_VOLUME 70
13+
#endif
1514

1615
// Define the default gain for the microphone amp (see values from
1716
// es_mic_gain_t) Alternativly you can call es8388_set_mic_gain(es_mic_gain_t
1817
// gain) if you prefer to use value from an comprehensive enum
1918
#ifndef ES8388_DEFAULT_INPUT_GAIN
20-
#define ES8388_DEFAULT_INPUT_GAIN 25
19+
# define ES8388_DEFAULT_INPUT_GAIN 25
2120
#endif
2221

22+
/// Fixed Definitions
23+
#define RESULT_OK 0 /*!< error_t value indicating success (no error) */
24+
#define RESULT_FAIL -1 /*!< Generic error_t code indicating failure */
25+
#define ERROR_INVALID_ARG 1
26+
#define I2C_END true
27+
2328
#ifdef __cplusplus
2429
namespace audio_driver {
2530
#endif

0 commit comments

Comments
 (0)