Skip to content

Commit

Permalink
Pass reference to Wire library in constructor
Browse files Browse the repository at this point in the history
Instead of using a pointer in begin().
  • Loading branch information
MCUdude committed Oct 6, 2020
1 parent 2185871 commit b4a18d0
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 263 deletions.
35 changes: 18 additions & 17 deletions examples/0_Template/0_Template.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,43 @@
| SigmaDSP library |
| https://github.com/MCUdude/SigmaDSP |
| |
| 0_Template. |
| 0_Template.ino |
| This example is ment to be used as a |
| template for your own projects. It brings no |
| functionality other than connecting the two |
| analog inputs directly to output 0 and 1. |
| template for your own projects. It provide |
| no functionality other than connecting the |
| two analog inputs directly to output 0 and 1 |
|**********************************************/

// Include SigmaDSP library
// Include Wire and SigmaDSP library
#include <Wire.h>
#include <SigmaDSP.h>

// Include generated parameter file
#include "SigmaDSP_parameters.h"


// The first parameter is the i2c address, which is defined in the parameter file.
// The next parameter is the SigmaDSP type
// An optional third parameter is the pin to physically reset the DSP
SigmaDSP dsp(DSP_I2C_ADDRESS, ADAU1701 /*,12*/);
// The first parameter is the Wire object we'll be using when communicating wth the DSP
// The second parameter is the DSP i2c address, which is defined in the parameter file
// The third parameter is the SigmaDSP type
// An optional fourth parameter is the pin to physically reset the DSP
SigmaDSP dsp(Wire, DSP_I2C_ADDRESS, ADAU1701 /*,12*/);


// Only needed if an external i2c EEPROM is present + the DSP is in selfboot mode
// The first parameter is the i2c address, which is defined in the parameter file.
// The second parameter is the EEPROM size in kilobits
// An optional third parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);
// The first parameter is the Wire object we'll be using when communicating wth the EEPROM
// The second parameter is the EEPROM i2c address, which is defined in the parameter file
// The third parameter is the EEPROM size in kilobits (kb)
// An optional fourth parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(Wire, EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);


void setup()
{
Serial.begin(9600);
Serial.println(F("SigmaDSP 0_Template example\n"));

// dsp and ee supports re-mapping of the SDA and SCL signals, but
// can only be done if the microcontroller supports it (ESP8266 for example)
dsp.begin(/* &Wire, SDA, SCL */);
//ee.begin(/* &Wire, SDA, SCL */);
dsp.begin();
//ee.begin();

delay(2000);

Expand Down
30 changes: 16 additions & 14 deletions examples/1_Volume/1_Volume.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,37 @@
| to learn more, tweak or do modifications. |
|**********************************************/

// Include SigmaDSP library
// Include Wire and SigmaDSP library
#include <Wire.h>
#include <SigmaDSP.h>

// Include generated parameter file
#include "SigmaDSP_parameters.h"


// The first parameter is the i2c address, which is defined in the parameter file.
// The next parameter is the SigmaDSP type
// An optional third parameter is the pin to physically reset the DSP
SigmaDSP dsp(DSP_I2C_ADDRESS, ADAU1701 /*,12*/);
// The first parameter is the Wire object we'll be using when communicating wth the DSP
// The second parameter is the DSP i2c address, which is defined in the parameter file
// The third parameter is the SigmaDSP type
// An optional fourth parameter is the pin to physically reset the DSP
SigmaDSP dsp(Wire, DSP_I2C_ADDRESS, ADAU1701 /*,12*/);


// Only needed if an external i2c EEPROM is present + the DSP is in selfboot mode
// The first parameter is the i2c address, which is defined in the parameter file.
// The second parameter is the EEPROM size in kilobits
// An optional third parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);
// The first parameter is the Wire object we'll be using when communicating wth the EEPROM
// The second parameter is the EEPROM i2c address, which is defined in the parameter file
// The third parameter is the EEPROM size in kilobits (kb)
// An optional fourth parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(Wire, EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);


void setup()
{
Serial.begin(9600);
Serial.println(F("SigmaDSP 1_Volume example\n"));

// dsp and ee supports re-mapping of the SDA and SCL signals, but
// can only be done if the microcontroller supports it (ESP8266 for example)
dsp.begin(/* &Wire, SDA, SCL */);
//ee.begin(/* &Wire, SDA, SCL */);
Wire.begin();
dsp.begin();
//ee.begin();

delay(2000);

Expand Down Expand Up @@ -80,4 +82,4 @@ void loop()
dsp.volume_slew(MOD_SWVOL1_ALG0_TARGET_ADDR, i); // Slew rate is default 12
delay(200);
}
}
}
29 changes: 16 additions & 13 deletions examples/2_First_order_EQ/2_First_order_EQ.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@
| to learn more, tweak or do modifications. |
|**********************************************/

// Include SigmaDSP library
// Include Wire and SigmaDSP library
#include <Wire.h>
#include <SigmaDSP.h>

// Include generated parameter file
#include "SigmaDSP_parameters.h"


// The first parameter is the i2c address, which is defined in the parameter file.
// The next parameter is the SigmaDSP type
// An optional third parameter is the pin to physically reset the DSP
SigmaDSP dsp(DSP_I2C_ADDRESS, ADAU1701 /*,12*/);
// The first parameter is the Wire object we'll be using when communicating wth the DSP
// The second parameter is the DSP i2c address, which is defined in the parameter file
// The third parameter is the SigmaDSP type
// An optional fourth parameter is the pin to physically reset the DSP
SigmaDSP dsp(Wire, DSP_I2C_ADDRESS, ADAU1701 /*,12*/);


// Only needed if an external i2c EEPROM is present + the DSP is in selfboot mode
// The first parameter is the i2c address, which is defined in the parameter file.
// The second parameter is the EEPROM size in kilobits
// An optional third parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);
// The first parameter is the Wire object we'll be using when communicating wth the EEPROM
// The second parameter is the EEPROM i2c address, which is defined in the parameter file
// The third parameter is the EEPROM size in kilobits (kb)
// An optional fourth parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(Wire, EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);


// Create an instance for each EQ block
firstOrderEQ eq1;
Expand All @@ -38,10 +42,9 @@ void setup()
Serial.begin(9600);
Serial.println(F("SigmaDSP 2_First_order_EQ example\n"));

// dsp and ee supports re-mapping of the SDA and SCL signals, but
// can only be done if the microcontroller supports it (ESP8266 for example)
dsp.begin(/* &Wire, SDA, SCL */);
//ee.begin(/* &Wire, SDA, SCL */);
Wire.begin();
dsp.begin();
//ee.begin();

delay(2000);

Expand Down
29 changes: 16 additions & 13 deletions examples/3_Second_order_EQ/3_Second_order_EQ.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@
| to learn more, tweak or do modifications. |
|**********************************************/

// Include SigmaDSP library
// Include Wire and SigmaDSP library
#include <Wire.h>
#include <SigmaDSP.h>

// Include generated parameter file
#include "SigmaDSP_parameters.h"


// The first parameter is the i2c address, which is defined in the parameter file.
// The next parameter is the SigmaDSP type
// An optional third parameter is the pin to physically reset the DSP
SigmaDSP dsp(DSP_I2C_ADDRESS, ADAU1701 /*,12*/);
// The first parameter is the Wire object we'll be using when communicating wth the DSP
// The second parameter is the DSP i2c address, which is defined in the parameter file
// The third parameter is the SigmaDSP type
// An optional fourth parameter is the pin to physically reset the DSP
SigmaDSP dsp(Wire, DSP_I2C_ADDRESS, ADAU1701 /*,12*/);


// Only needed if an external i2c EEPROM is present + the DSP is in selfboot mode
// The first parameter is the i2c address, which is defined in the parameter file.
// The second parameter is the EEPROM size in kilobits
// An optional third parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);
// The first parameter is the Wire object we'll be using when communicating wth the EEPROM
// The second parameter is the EEPROM i2c address, which is defined in the parameter file
// The third parameter is the EEPROM size in kilobits (kb)
// An optional fourth parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(Wire, EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);


// Create an instance for each EQ block
secondOrderEQ eqBand1;
Expand All @@ -40,10 +44,9 @@ void setup()
Serial.begin(9600);
Serial.println(F("3_Second_order_EQ example\n"));

// dsp and ee supports re-mapping of the SDA and SCL signals, but
// can only be done if the microcontroller supports it (ESP8266 for example)
dsp.begin(/* &Wire, SDA, SCL */);
//ee.begin(/* &Wire, SDA, SCL */);
Wire.begin();
dsp.begin();
//ee.begin();

delay(2000);

Expand Down
29 changes: 16 additions & 13 deletions examples/4_State_variable_filter/4_State_variable_filter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,28 @@
| to learn more, tweak or do modifications. |
|**********************************************/

// Include SigmaDSP library
// Include Wire and SigmaDSP library
#include <Wire.h>
#include <SigmaDSP.h>

// Include generated parameter file
#include "SigmaDSP_parameters.h"


// The first parameter is the i2c address, which is defined in the parameter file.
// The next parameter is the SigmaDSP type
// An optional third parameter is the pin to physically reset the DSP
SigmaDSP dsp(DSP_I2C_ADDRESS, ADAU1701 /*,12*/);
// The first parameter is the Wire object we'll be using when communicating wth the DSP
// The second parameter is the DSP i2c address, which is defined in the parameter file
// The third parameter is the SigmaDSP type
// An optional fourth parameter is the pin to physically reset the DSP
SigmaDSP dsp(Wire, DSP_I2C_ADDRESS, ADAU1701 /*,12*/);


// Only needed if an external i2c EEPROM is present + the DSP is in selfboot mode
// The first parameter is the i2c address, which is defined in the parameter file.
// The second parameter is the EEPROM size in kilobits
// An optional third parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);
// The first parameter is the Wire object we'll be using when communicating wth the EEPROM
// The second parameter is the EEPROM i2c address, which is defined in the parameter file
// The third parameter is the EEPROM size in kilobits (kb)
// An optional fourth parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(Wire, EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);


// Variable to store calculated sweep tone
uint16_t frequency;
Expand All @@ -38,10 +42,9 @@ void setup()
Serial.begin(9600);
Serial.println(F("SigmaDSP 4_State_variable_filter example\n"));

// dsp and ee supports re-mapping of the SDA and SCL signals, but
// can only be done if the microcontroller supports it (ESP8266 for example)
dsp.begin(/* &Wire, SDA, SCL */);
//ee.begin(/* &Wire, SDA, SCL */);
Wire.begin();
dsp.begin();
//ee.begin();

delay(2000);

Expand Down
28 changes: 15 additions & 13 deletions examples/5_Signal_generator/5_Signal_generator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,27 @@
| to learn more, tweak or do modifications. |
|**********************************************/

// Include SigmaDSP library
// Include Wire and SigmaDSP library
#include <Wire.h>
#include <SigmaDSP.h>

// Include generated parameter file
#include "SigmaDSP_parameters.h"


// The first parameter is the i2c address, which is defined in the parameter file.
// The next parameter is the SigmaDSP type
// An optional third parameter is the pin to physically reset the DSP
SigmaDSP dsp(DSP_I2C_ADDRESS, ADAU1701 /*,12*/);
// The first parameter is the Wire object we'll be using when communicating wth the DSP
// The second parameter is the DSP i2c address, which is defined in the parameter file
// The third parameter is the SigmaDSP type
// An optional fourth parameter is the pin to physically reset the DSP
SigmaDSP dsp(Wire, DSP_I2C_ADDRESS, ADAU1701 /*,12*/);


// Only needed if an external i2c EEPROM is present + the DSP is in selfboot mode
// The first parameter is the i2c address, which is defined in the parameter file.
// The second parameter is the EEPROM size in kilobits
// An optional third parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);
// The first parameter is the Wire object we'll be using when communicating wth the EEPROM
// The second parameter is the EEPROM i2c address, which is defined in the parameter file
// The third parameter is the EEPROM size in kilobits (kb)
// An optional fourth parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(Wire, EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);

// Variable to store calculated sweep tone
uint16_t frequency;
Expand All @@ -36,10 +39,9 @@ void setup()
Serial.begin(9600);
Serial.println(F("5_Signal_generator example\n"));

// dsp and ee supports re-mapping of the SDA and SCL signals, but
// can only be done if the microcontroller supports it (ESP8266 for example)
dsp.begin(/* &Wire, SDA, SCL */);
//ee.begin(/* &Wire, SDA, SCL */);
Wire.begin();
dsp.begin();
//ee.begin();

delay(2000);

Expand Down
29 changes: 16 additions & 13 deletions examples/6_Dynamic_bass_boost/6_Dynamic_bass_boost.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,37 @@
| to learn more, tweak or do modifications. |
|***********************************************/

// Include SigmaDSP library
// Include Wire and SigmaDSP library
#include <Wire.h>
#include <SigmaDSP.h>

// Include generated parameter file
#include "SigmaDSP_parameters.h"


// The first parameter is the i2c address, which is defined in the parameter file.
// The next parameter is the SigmaDSP type
// An optional third parameter is the pin to physically reset the DSP
SigmaDSP dsp(DSP_I2C_ADDRESS, ADAU1701 /*,12*/);
// The first parameter is the Wire object we'll be using when communicating wth the DSP
// The second parameter is the DSP i2c address, which is defined in the parameter file
// The third parameter is the SigmaDSP type
// An optional fourth parameter is the pin to physically reset the DSP
SigmaDSP dsp(Wire, DSP_I2C_ADDRESS, ADAU1701 /*,12*/);


// Only needed if an external i2c EEPROM is present + the DSP is in selfboot mode
// The first parameter is the i2c address, which is defined in the parameter file.
// The second parameter is the EEPROM size in kilobits
// An optional third parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);
// The first parameter is the Wire object we'll be using when communicating wth the EEPROM
// The second parameter is the EEPROM i2c address, which is defined in the parameter file
// The third parameter is the EEPROM size in kilobits (kb)
// An optional fourth parameter is the pin to toggle while writing content to EEPROM
//DSPEEPROM ee(Wire, EEPROM_I2C_ADDRESS, 256, LED_BUILTIN);


void setup()
{
Serial.begin(9600);
Serial.println(F("6_Dynamic_bass_boost example\n"));

// dsp and ee supports re-mapping of the SDA and SCL signals, but
// can only be done if the microcontroller supports it (ESP8266 for example)
dsp.begin(/* &Wire, SDA, SCL */);
//ee.begin(/* &Wire, SDA, SCL */);
Wire.begin();
dsp.begin();
//ee.begin();

delay(2000);

Expand Down
Loading

0 comments on commit b4a18d0

Please sign in to comment.