Skip to content

Commit de7c63a

Browse files
committed
use IndentPPDirectives: AfterHash
1 parent cada00b commit de7c63a

File tree

6 files changed

+70
-69
lines changed

6 files changed

+70
-69
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ SpacesBeforeTrailingComments: 1
2121
AlignOperands: true
2222
AllowAllParametersOfDeclarationOnNextLine: true
2323
AllowShortFunctionsOnASingleLine: All
24+
IndentPPDirectives: AfterHash
2425
#AllowShortLiteralsOnASingleLine: true
2526
#BracketAlignmentStyle: BAS_Align

edrumulus.ino

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@ const int number_pads4 = 8; // example: do not use tom3 and shrink number of pad
3434
#include "edrumulus.h"
3535

3636
#ifdef USE_MIDI
37-
#ifdef ESP_PLATFORM
38-
#include <MIDI.h>
39-
#ifdef USE_TINYUSB
40-
#include <Adafruit_TinyUSB.h>
37+
# ifdef ESP_PLATFORM
38+
# include <MIDI.h>
39+
# ifdef USE_TINYUSB
40+
# include <Adafruit_TinyUSB.h>
4141
Adafruit_USBD_MIDI usb_midi;
4242
MIDI_CREATE_INSTANCE(Adafruit_USBD_MIDI, usb_midi, MIDI);
43-
#else
43+
# else
4444
MIDI_CREATE_DEFAULT_INSTANCE();
45-
#endif
46-
#define MYMIDI MIDI
47-
#define MIDI_CONTROL_CHANGE_TYPE midi::ControlChange
48-
#define MIDI_SEND_AFTER_TOUCH sendAfterTouch
49-
#define MIDI_SERIAL 38400
50-
#endif
51-
#ifdef TEENSYDUINO
52-
#define MYMIDI usbMIDI
53-
#define MIDI_CONTROL_CHANGE_TYPE usbMIDI.ControlChange
54-
#define MIDI_SEND_AFTER_TOUCH sendAfterTouchPoly
55-
#endif
45+
# endif
46+
# define MYMIDI MIDI
47+
# define MIDI_CONTROL_CHANGE_TYPE midi::ControlChange
48+
# define MIDI_SEND_AFTER_TOUCH sendAfterTouch
49+
# define MIDI_SERIAL 38400
50+
# endif
51+
# ifdef TEENSYDUINO
52+
# define MYMIDI usbMIDI
53+
# define MIDI_CONTROL_CHANGE_TYPE usbMIDI.ControlChange
54+
# define MIDI_SEND_AFTER_TOUCH sendAfterTouchPoly
55+
# endif
5656
#endif
5757

5858
// local variables and defines
@@ -83,9 +83,9 @@ void setup()
8383
number_pads = min(number_pads, 7); // only max. 7 pads are supported for ESP32 serial debug plotting
8484
#endif
8585
#ifdef USE_MIDI
86-
#ifdef USE_TINYUSB
86+
# ifdef USE_TINYUSB
8787
TinyUSBDevice.setProductDescriptor("Edrumulus");
88-
#endif
88+
# endif
8989
MYMIDI.begin();
9090
#endif
9191
#ifdef MIDI_SERIAL

hardware.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ void Edrumulus_hardware::setup(const int conf_Fs,
6666
input_pin[total_number_inputs] = analog_pin[i][j];
6767
total_number_inputs++;
6868

69-
#if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) // Teensy 4.0/4.1 specific code
69+
# if defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) // Teensy 4.0/4.1 specific code
7070
// disable MIMXRT1062DVL6A "keeper" on all Teensy 4.0/4.1 ADC input pins
7171
// NOTE: pinMode() needs absolute pin numbers, e.g. 0 for A0 will not work
7272
pinMode(analog_pin[i][j], INPUT_DISABLE);
73-
#endif
73+
# endif
7474
}
7575
}
7676

@@ -154,7 +154,7 @@ int Edrumulus_hardware::get_prototype_pins(int** analog_pins,
154154
int* number_pins,
155155
int* status_LED_pin)
156156
{
157-
#ifdef CONFIG_IDF_TARGET_ESP32
157+
# ifdef CONFIG_IDF_TARGET_ESP32
158158
// Definition:
159159
// - Pin 5 is "input enabled, pull-up resistor" -> if read value is 1, we know that we have a
160160
// legacy or custom board. Boards which support the identification set this pin to low.
@@ -209,7 +209,7 @@ int Edrumulus_hardware::get_prototype_pins(int** analog_pins,
209209
// default: assume that analog pins are set outside this function, only update board LED pin
210210
*status_LED_pin = BOARD_LED_PIN;
211211
return 4;
212-
#else // CONFIG_IDF_TARGET_ESP32S3
212+
# else // CONFIG_IDF_TARGET_ESP32S3
213213
// clang-format off
214214
// analog pins setup: snare | kick | hi-hat | hi-hat-ctrl | crash | tom1 | ride | tom2 | tom3
215215
static int analog_pins_s3[] = { 4, 6, 7, 9, 10, 12, 13, 15, 16 };
@@ -220,7 +220,7 @@ int Edrumulus_hardware::get_prototype_pins(int** analog_pins,
220220
*number_pins = sizeof(analog_pins_s3) / sizeof(int);
221221
*status_LED_pin = BOARD_LED_PIN;
222222
return 4;
223-
#endif
223+
# endif
224224
}
225225

226226
void Edrumulus_hardware::setup(const int conf_Fs,
@@ -252,7 +252,7 @@ void Edrumulus_hardware::setup(const int conf_Fs,
252252
// find ADC pairs, i.e., one pin uses ADC1 and the other uses ADC2
253253
num_pin_pairs = 0; // we use it as a counter, too
254254

255-
#ifdef CONFIG_IDF_TARGET_ESP32
255+
# ifdef CONFIG_IDF_TARGET_ESP32
256256
for (int i = 0; i < total_number_inputs - 1; i++)
257257
{
258258
if (!input_is_used[i])
@@ -287,7 +287,7 @@ void Edrumulus_hardware::setup(const int conf_Fs,
287287
}
288288
}
289289
}
290-
#endif
290+
# endif
291291

292292
// find remaining single pins which we cannot create an ADC pair with
293293
num_pin_single = 0; // we use it as a counter, too
@@ -315,16 +315,16 @@ void Edrumulus_hardware::setup(const int conf_Fs,
315315
void Edrumulus_hardware::setup_timer()
316316
{
317317
// prepare timer at a rate of given sampling rate
318-
#if ESP_IDF_VERSION_MAJOR < 5
318+
# if ESP_IDF_VERSION_MAJOR < 5
319319
timer = timerBegin(0, 80, true); // prescaler of 80 (i.e. below we have 1 MHz instead of 80 MHz)
320320
timerAttachInterrupt(timer, &on_timer, true);
321321
timerAlarmWrite(timer, 1000000 / Fs, true); // here we define the sampling rate (1 MHz / Fs)
322322
timerAlarmEnable(timer);
323-
#else
323+
# else
324324
timer = timerBegin(1000000);
325325
timerAttachInterrupt(timer, &on_timer);
326326
timerAlarm(timer, 1000000 / Fs, true, 0);
327-
#endif
327+
# endif
328328
}
329329

330330
void Edrumulus_hardware::start_timer_core0_task(void* param)
@@ -395,7 +395,7 @@ void Edrumulus_hardware::capture_samples(const int number_pads,
395395
// As a workaround, we had to write our own analogRead function.
396396
void Edrumulus_hardware::init_my_analogRead()
397397
{
398-
#ifdef CONFIG_IDF_TARGET_ESP32
398+
# ifdef CONFIG_IDF_TARGET_ESP32
399399
// if the GIOP 25/26 are used, we have to set the DAC to 0 to get correct DC offset
400400
// estimates and reduce the number of large spikes
401401
dac_i2s_enable();
@@ -444,7 +444,7 @@ void Edrumulus_hardware::init_my_analogRead()
444444
{
445445
pinMode(input_pin[i], ANALOG);
446446
}
447-
#else // CONFIG_IDF_TARGET_ESP32S3
447+
# else // CONFIG_IDF_TARGET_ESP32S3
448448
int cur_sample;
449449
for (int channel = 0; channel < 10; channel++) // 10 channels per ADC
450450
{
@@ -455,7 +455,7 @@ void Edrumulus_hardware::init_my_analogRead()
455455
adc2_get_raw(static_cast<adc2_channel_t>(channel), ADC_WIDTH_BIT_12, &cur_sample);
456456
}
457457
adc_power_acquire();
458-
#endif
458+
# endif
459459
}
460460

461461
uint16_t Edrumulus_hardware::my_analogRead(const uint8_t pin)
@@ -465,39 +465,39 @@ uint16_t Edrumulus_hardware::my_analogRead(const uint8_t pin)
465465
if (channel > 9)
466466
{
467467
const int8_t channel_modified = channel - 10;
468-
#ifdef CONFIG_IDF_TARGET_ESP32
468+
# ifdef CONFIG_IDF_TARGET_ESP32
469469
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_START_SAR_M);
470470
SET_PERI_REG_BITS(SENS_SAR_MEAS_START2_REG, SENS_SAR2_EN_PAD, (1 << channel_modified), SENS_SAR2_EN_PAD_S);
471471
SET_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_START_SAR_M);
472472
while (GET_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_DONE_SAR) == 0)
473473
;
474474
return GET_PERI_REG_BITS2(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_DATA_SAR, SENS_MEAS2_DATA_SAR_S);
475-
#else // CONFIG_IDF_TARGET_ESP32S3
475+
# else // CONFIG_IDF_TARGET_ESP32S3
476476
SENS.sar_meas2_ctrl2.meas2_start_sar = 0;
477477
SENS.sar_meas2_ctrl2.sar2_en_pad = (1 << channel_modified);
478478
SENS.sar_meas2_ctrl2.meas2_start_sar = 1;
479479
while (!SENS.sar_meas2_ctrl2.meas2_done_sar)
480480
;
481481
return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_meas2_ctrl2, meas2_data_sar);
482-
#endif
482+
# endif
483483
}
484484
else
485485
{
486-
#ifdef CONFIG_IDF_TARGET_ESP32
486+
# ifdef CONFIG_IDF_TARGET_ESP32
487487
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_START_SAR_M);
488488
SET_PERI_REG_BITS(SENS_SAR_MEAS_START1_REG, SENS_SAR1_EN_PAD, (1 << channel), SENS_SAR1_EN_PAD_S);
489489
SET_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_START_SAR_M);
490490
while (GET_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_DONE_SAR) == 0)
491491
;
492492
return GET_PERI_REG_BITS2(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_DATA_SAR, SENS_MEAS1_DATA_SAR_S);
493-
#else // CONFIG_IDF_TARGET_ESP32S3
493+
# else // CONFIG_IDF_TARGET_ESP32S3
494494
SENS.sar_meas1_ctrl2.meas1_start_sar = 0;
495495
SENS.sar_meas1_ctrl2.sar1_en_pad = (1 << channel);
496496
SENS.sar_meas1_ctrl2.meas1_start_sar = 1;
497497
while (!SENS.sar_meas1_ctrl2.meas1_done_sar)
498498
;
499499
return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_meas1_ctrl2, meas1_data_sar);
500-
#endif
500+
# endif
501501
}
502502
}
503503

@@ -506,7 +506,7 @@ void Edrumulus_hardware::my_analogRead_parallel(const uint32_t channel_adc1_bitv
506506
uint16_t& out_adc1,
507507
uint16_t& out_adc2)
508508
{
509-
#ifdef CONFIG_IDF_TARGET_ESP32
509+
# ifdef CONFIG_IDF_TARGET_ESP32
510510
// start ADC1
511511
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS_START1_REG, SENS_MEAS1_START_SAR_M);
512512
SET_PERI_REG_BITS(SENS_SAR_MEAS_START1_REG, SENS_SAR1_EN_PAD, channel_adc1_bitval, SENS_SAR1_EN_PAD_S);
@@ -526,7 +526,7 @@ void Edrumulus_hardware::my_analogRead_parallel(const uint32_t channel_adc1_bitv
526526
while (GET_PERI_REG_MASK(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_DONE_SAR) == 0)
527527
;
528528
out_adc2 = GET_PERI_REG_BITS2(SENS_SAR_MEAS_START2_REG, SENS_MEAS2_DATA_SAR, SENS_MEAS2_DATA_SAR_S);
529-
#endif
529+
# endif
530530
}
531531

532532
#endif

hardware.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
// -----------------------------------------------------------------------------
3030
#ifdef TEENSYDUINO
3131

32-
#include <ADC.h>
32+
# include <ADC.h>
3333

34-
#define BOARD_LED_PIN 13 // pin number of the LED on the Teensy 4.0 board
35-
#define ADC_MAX_RANGE 4096 // Teensy 4.0/4.1 ADC has 12 bits -> 0..4095
36-
#define ADC_MAX_NOISE_AMPL 8 // highest assumed ADC noise amplitude in the ADC input range unit (measured)
34+
# define BOARD_LED_PIN 13 // pin number of the LED on the Teensy 4.0 board
35+
# define ADC_MAX_RANGE 4096 // Teensy 4.0/4.1 ADC has 12 bits -> 0..4095
36+
# define ADC_MAX_NOISE_AMPL 8 // highest assumed ADC noise amplitude in the ADC input range unit (measured)
3737

3838
class Edrumulus_hardware
3939
{
@@ -77,17 +77,17 @@ class Edrumulus_hardware
7777
// -----------------------------------------------------------------------------
7878
#ifdef ESP_PLATFORM
7979

80-
#include "driver/adc.h"
81-
#include "soc/sens_reg.h"
82-
#ifdef CONFIG_IDF_TARGET_ESP32
83-
#include "driver/dac.h"
84-
#else // CONFIG_IDF_TARGET_ESP32S3
85-
#include "hal/adc_hal.h"
86-
#endif
87-
88-
#define BOARD_LED_PIN 2 // pin number of the LED on the ESP32 board
89-
#define ADC_MAX_RANGE 4096 // ESP32 ADC has 12 bits -> 0..4095
90-
#define ADC_MAX_NOISE_AMPL 8 // highest assumed ADC noise amplitude in the ADC input range unit (measured)
80+
# include "driver/adc.h"
81+
# include "soc/sens_reg.h"
82+
# ifdef CONFIG_IDF_TARGET_ESP32
83+
# include "driver/dac.h"
84+
# else // CONFIG_IDF_TARGET_ESP32S3
85+
# include "hal/adc_hal.h"
86+
# endif
87+
88+
# define BOARD_LED_PIN 2 // pin number of the LED on the ESP32 board
89+
# define ADC_MAX_RANGE 4096 // ESP32 ADC has 12 bits -> 0..4095
90+
# define ADC_MAX_NOISE_AMPL 8 // highest assumed ADC noise amplitude in the ADC input range unit (measured)
9191

9292
class Edrumulus_hardware
9393
{

pad.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,12 @@ class Pad
434434

435435
// real-time debugging support
436436
#ifdef USE_SERIAL_DEBUG_PLOTTING
437-
#ifdef TEENSYDUINO // MIDI+Serial possible with the Teensy
437+
# ifdef TEENSYDUINO // MIDI+Serial possible with the Teensy
438438
static const int debug_buffer_size = 500;
439-
#else
440-
#undef USE_MIDI // only MIDI or Serial possible with the ESP32
439+
# else
440+
# undef USE_MIDI // only MIDI or Serial possible with the ESP32
441441
static const int debug_buffer_size = 400; // smaller size needed for ESP32
442-
#endif
442+
# endif
443443
static const int number_debug_buffers = 4;
444444
int debug_buffer_idx = 0;
445445
int debug_out_cnt = 0;

teensy_name.c

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

1818
#ifdef TEENSYDUINO
1919

20-
#include <usb_names.h>
20+
# include <usb_names.h>
2121

2222
// define the name of the Teensy USB MIDI device showing up in the operating system
23-
#define MANUFACTURER_NAME \
24-
{ \
25-
'v', 'o', 'f', 'i', ' ', 't', 'e', 'c' \
26-
}
27-
#define MANUFACTURER_NAME_LEN 8
28-
#define PRODUCT_NAME \
29-
{ \
30-
'E', 'd', 'r', 'u', 'm', 'u', 'l', 'u', 's' \
31-
}
32-
#define PRODUCT_NAME_LEN 9
23+
# define MANUFACTURER_NAME \
24+
{ \
25+
'v', 'o', 'f', 'i', ' ', 't', 'e', 'c' \
26+
}
27+
# define MANUFACTURER_NAME_LEN 8
28+
# define PRODUCT_NAME \
29+
{ \
30+
'E', 'd', 'r', 'u', 'm', 'u', 'l', 'u', 's' \
31+
}
32+
# define PRODUCT_NAME_LEN 9
3333

3434
struct usb_string_descriptor_struct usb_string_manufacturer_name = {
3535
2 + MANUFACTURER_NAME_LEN * 2,

0 commit comments

Comments
 (0)