Skip to content

Commit

Permalink
Set initial volume
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Feb 7, 2024
1 parent 594f0a1 commit b7560fc
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ StreamCopy copier(out, sound);
void setup() {
// Setup logging
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
LOGLEVEL_AUDIODRIVER = AudioDriverWarning;

// setup pins
// - add i2c codec pins: scl, sda, port, (I2C object)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ StreamCopy copier(out, sound);
void setup() {
// Setup logging
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
LOGLEVEL_AUDIODRIVER = AudioDriverWarning;

// initialize i2c because board has no i2c definition
Wire.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ StreamCopy copier(out, sound);
void setup() {
// Setup logging
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;
AudioLogger::instance().begin(Serial, AudioLogger::Warning);
LOGLEVEL_AUDIODRIVER = AudioDriverWarning;

// start I2S & codec with i2c and i2s configured above
Serial.println("starting I2S...");
Expand Down
4 changes: 4 additions & 0 deletions examples/custom/custom-max/custom-max.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ DriverPins my_pins;
AudioBoard board(AudioDriverES8388);

void setup() {
// Setup logging
Serial.begin(115200);
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;

// add i2c codec pins: scl, sda, port
my_pins.addI2C(CODEC, 32, 22, 0x20);
// example add other pins: PA on gpio 21
Expand Down
4 changes: 4 additions & 0 deletions examples/custom/custom-min/custom-min.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
AudioBoard board(AudioDriverES8388);

void setup() {
// Setup logging
Serial.begin(115200);
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;

// start I2C for the communication with the codec
Wire.begin();
// configure codec
Expand Down
4 changes: 4 additions & 0 deletions examples/custom/custom-standard/custom-standard.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "AudioBoard.h"

void setup() {
// Setup logging
Serial.begin(115200);
LOGLEVEL_AUDIODRIVER = AudioDriverInfo;

// configure codec
CodecConfig cfg;
cfg.adc_input = ADC_INPUT_LINE1;
Expand Down
4 changes: 3 additions & 1 deletion src/AudioBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class AudioBoard {
}

bool begin(){
return pins.begin() && driver->begin(codec_cfg, pins);
bool result = pins.begin() && driver->begin(codec_cfg, pins);
setVolume(DRIVER_DEFAULT_VOLUME);
return result;
}

bool begin(CodecConfig cfg) {
Expand Down
17 changes: 11 additions & 6 deletions src/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@
* @defgroup enumerations Public enumeration types
*/

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

// Define the default gain for the microphone amp (see values from
// es_mic_gain_t) Alternativly you can call es8388_set_mic_gain(es_mic_gain_t
// gain) if you prefer to use value from an comprehensive enum
#ifndef ES8388_DEFAULT_INPUT_GAIN
#define ES8388_DEFAULT_INPUT_GAIN 25
# define ES8388_DEFAULT_INPUT_GAIN 25
#endif

/// Fixed Definitions
#define RESULT_OK 0 /*!< error_t value indicating success (no error) */
#define RESULT_FAIL -1 /*!< Generic error_t code indicating failure */
#define ERROR_INVALID_ARG 1
#define I2C_END true

#ifdef __cplusplus
namespace audio_driver {
#endif
Expand Down

0 comments on commit b7560fc

Please sign in to comment.