Skip to content

Commit a2fd52f

Browse files
committed
Merge remote-tracking branch 'origin/improve_hardware_config'
2 parents 902eb5f + 987faec commit a2fd52f

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

edrumulus.ino

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717

1818
#define USE_MIDI
1919

20+
// ESP32 default pin definition:
21+
// For older prototypes or custom implementations, simply change the GPIO numbers in the table below
22+
// to match your hardware (note that the GPIO assignment of Prototype 2 is the same as Prototype 4).
23+
// analog pins setup: snare | kick | hi-hat | hi-hat-ctrl | crash | tom1 | ride | tom2 | tom3
24+
static int analog_pins4[] = { 36, 33, 32, 25, 34, 39, 27, 12, 15 };
25+
static int analog_pins_rimshot4[] = { 35, -1, 26, -1, 14, -1, 13, -1, -1 };
26+
const int number_pads4 = sizeof ( analog_pins4 ) / sizeof ( int );
27+
28+
2029
#include "edrumulus.h"
2130

2231
#ifdef USE_MIDI
@@ -35,21 +44,21 @@ MIDI_CREATE_DEFAULT_INSTANCE();
3544
# endif
3645
#endif
3746

47+
// local variables and defines
3848
Edrumulus edrumulus;
39-
const int midi_channel = 10; // default for edrums is 10
40-
const int hihat_pad_idx = 2;
41-
const int hihatctrl_pad_idx = 3;
42-
int number_pads = 0; // initialization value, will be set in setup()
43-
int status_LED_pin = 0; // initialization value, will be set in setup()
44-
bool is_status_LED_on = false; // initialization value
45-
int selected_pad = 0; // initialization value
46-
49+
const int midi_channel = 10; // default for edrums is 10
50+
const int hihat_pad_idx = 2; // this definition should not be changed
51+
const int hihatctrl_pad_idx = 3; // this definition should not be changed
52+
int number_pads = number_pads4; // initialization value, may be overwritten by get_prototype_pins()
53+
int status_LED_pin = 0; // initialization value, will be set in get_prototype_pins()
54+
bool is_status_LED_on = false; // initialization value
55+
int selected_pad = 0; // initialization value
4756

4857
void setup()
4958
{
5059
// get the pin-to-pad assignments
51-
int* analog_pins = nullptr;
52-
int* analog_pins_rimshot = nullptr;
60+
int* analog_pins = analog_pins4; // initialize with the default setup
61+
int* analog_pins_rimshot = analog_pins_rimshot4; // initialize with the default setup
5362
const int prototype = Edrumulus_hardware::get_prototype_pins ( &analog_pins,
5463
&analog_pins_rimshot,
5564
&number_pads,

edrumulus_hardware.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ int Edrumulus_hardware::get_prototype_pins ( int** analog_pins,
3636
int* number_pins,
3737
int* status_LED_pin )
3838
{
39-
4039
// analog pins setup: snare | kick | hi-hat | hi-hat-ctrl | crash | tom1 | ride | tom2 | tom3
4140
static int analog_pins1[] = { 10, 11, 12, 13, 1, 6, 4, 5 };
4241
static int analog_pins_rimshot1[] = { 9, -1, 0, -1, 3, 8, 2, 7 };
@@ -221,17 +220,8 @@ int Edrumulus_hardware::get_prototype_pins ( int** analog_pins,
221220
}
222221
}
223222

224-
// if no GPIO prototype identification is available, we assume it is Prototype 4,
225-
// for older prototypes or custom implementations, simply change the GPIO numbers in the
226-
// table below to match your hardware (note that the GPIO assignment of Prototype 2 is the
227-
// same as Prototype 4)
228-
// analog pins setup: snare | kick | hi-hat | hi-hat-ctrl | crash | tom1 | ride | tom2 | tom3
229-
static int analog_pins4[] = { 36, 33, 32, 25, 34, 39, 27, 12, 15 };
230-
static int analog_pins_rimshot4[] = { 35, -1, 26, -1, 14, -1, 13, -1, -1 };
231-
*analog_pins = analog_pins4;
232-
*analog_pins_rimshot = analog_pins_rimshot4;
233-
*number_pins = sizeof ( analog_pins4 ) / sizeof ( int );
234-
*status_LED_pin = BOARD_LED_PIN;
223+
// default: assume that analog pins are set outside this function, only update board LED pin
224+
*status_LED_pin = BOARD_LED_PIN;
235225
return 4;
236226
#else // CONFIG_IDF_TARGET_ESP32S3
237227
// analog pins setup: snare | kick | hi-hat | hi-hat-ctrl | crash | tom1 | ride | tom2 | tom3

0 commit comments

Comments
 (0)