Skip to content

Commit ef9c044

Browse files
committed
Merge branch 'main' into integrate_pull_request_137
# Conflicts: # edrumulus.h # edrumulus.ino # hardware.cpp # hardware.h
2 parents 89ab06e + 594ce4a commit ef9c044

File tree

14 files changed

+2878
-2640
lines changed

14 files changed

+2878
-2640
lines changed

.clang-format

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
BasedOnStyle: Google
2+
IndentWidth: 2
3+
TabWidth: 2
4+
UseTab: Never
5+
BreakBeforeBraces: Allman
6+
ColumnLimit: 0
7+
SpaceBeforeParens: ControlStatements
8+
SpaceAfterCStyleCast: false
9+
SpacesInParentheses: false
10+
SpacesInSquareBrackets: false
11+
SpacesInContainerLiterals: false
12+
AlignAfterOpenBracket: DontAlign
13+
AlignTrailingComments: true
14+
BinPackArguments: false
15+
BinPackParameters: false
16+
PenaltyBreakBeforeFirstCallParameter: 0
17+
18+
AllowShortCaseLabelsOnASingleLine: true
19+
AlignConsecutiveAssignments: true
20+
SpacesBeforeTrailingComments: 1
21+
AlignOperands: true
22+
AllowAllParametersOfDeclarationOnNextLine: true
23+
AllowShortFunctionsOnASingleLine: All
24+
IndentPPDirectives: AfterHash
25+
#AllowShortLiteralsOnASingleLine: true
26+
#BracketAlignmentStyle: BAS_Align

.github/workflows/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,13 @@ jobs:
3333
python -m pip install --upgrade pip
3434
pip install --upgrade platformio setuptools wheel
3535
36+
- name: Install clang-format
37+
run: sudo apt-get install clang-format
38+
39+
- name: Check clang-format
40+
run: |
41+
# Only check the format of the files in the root directory
42+
clang-format --dry-run --Werror *.c *.cpp *.h *.ino
43+
3644
- name: Build
3745
run: pio ci -c platformio.ini .

common.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/******************************************************************************\
2+
* Copyright (c) 2020-2024
3+
* Author(s): Volker Fischer
4+
******************************************************************************
5+
* This program is free software; you can redistribute it and/or modify it under
6+
* the terms of the GNU General Public License as published by the Free Software
7+
* Foundation; either version 2 of the License, or (at your option) any later
8+
* version.
9+
* This program is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12+
* details.
13+
* You should have received a copy of the GNU General Public License along with
14+
* this program; if not, write to the Free Software Foundation, Inc.,
15+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
16+
\******************************************************************************/
17+
18+
#pragma once
19+
20+
//#define USE_SERIAL_DEBUG_PLOTTING
21+
22+
#define VERSION_MAJOR 0
23+
#define VERSION_MINOR 9
24+
25+
#define MAX_NUM_PADS 12 // a maximum of 12 pads are supported
26+
#define MAX_NUM_PAD_INPUTS 5 // a maximum of 5 sensors per pad is supported (where one is rim and one is the sum of three)
27+
28+
inline void update_fifo(const float input,
29+
const int fifo_length,
30+
float* fifo_memory)
31+
{
32+
// move all values in the history one step back and put new value on the top
33+
for (int i = 0; i < fifo_length - 1; i++)
34+
{
35+
fifo_memory[i] = fifo_memory[i + 1];
36+
}
37+
fifo_memory[fifo_length - 1] = input;
38+
}
39+
40+
inline void allocate_initialize(float** array_memory,
41+
const int array_length)
42+
{
43+
// (delete and) allocate memory
44+
if (*array_memory != nullptr)
45+
{
46+
delete[] * array_memory;
47+
}
48+
49+
*array_memory = new float[array_length];
50+
51+
// initialization values
52+
for (int i = 0; i < array_length; i++)
53+
{
54+
(*array_memory)[i] = 0.0f;
55+
}
56+
}
57+
58+
class FastWriteFIFO
59+
{
60+
public:
61+
void initialize(const int len)
62+
{
63+
pointer = 0;
64+
fifo_length = len;
65+
allocate_initialize(&fifo_memory, len);
66+
}
67+
68+
void add(const float input)
69+
{
70+
// write new value and increment data pointer with wrap around
71+
fifo_memory[pointer] = input;
72+
pointer = (pointer + 1) % fifo_length;
73+
}
74+
75+
const float operator[](const int index)
76+
{
77+
return fifo_memory[(pointer + index) % fifo_length];
78+
}
79+
80+
protected:
81+
float* fifo_memory = nullptr;
82+
int pointer;
83+
int fifo_length;
84+
};

0 commit comments

Comments
 (0)