-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into integrate_pull_request_137
# Conflicts: # edrumulus.h # edrumulus.ino # hardware.cpp # hardware.h
- Loading branch information
Showing
14 changed files
with
2,878 additions
and
2,640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
BasedOnStyle: Google | ||
IndentWidth: 2 | ||
TabWidth: 2 | ||
UseTab: Never | ||
BreakBeforeBraces: Allman | ||
ColumnLimit: 0 | ||
SpaceBeforeParens: ControlStatements | ||
SpaceAfterCStyleCast: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
SpacesInContainerLiterals: false | ||
AlignAfterOpenBracket: DontAlign | ||
AlignTrailingComments: true | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
PenaltyBreakBeforeFirstCallParameter: 0 | ||
|
||
AllowShortCaseLabelsOnASingleLine: true | ||
AlignConsecutiveAssignments: true | ||
SpacesBeforeTrailingComments: 1 | ||
AlignOperands: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortFunctionsOnASingleLine: All | ||
IndentPPDirectives: AfterHash | ||
#AllowShortLiteralsOnASingleLine: true | ||
#BracketAlignmentStyle: BAS_Align |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/******************************************************************************\ | ||
* Copyright (c) 2020-2024 | ||
* Author(s): Volker Fischer | ||
****************************************************************************** | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 2 of the License, or (at your option) any later | ||
* version. | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
\******************************************************************************/ | ||
|
||
#pragma once | ||
|
||
//#define USE_SERIAL_DEBUG_PLOTTING | ||
|
||
#define VERSION_MAJOR 0 | ||
#define VERSION_MINOR 9 | ||
|
||
#define MAX_NUM_PADS 12 // a maximum of 12 pads are supported | ||
#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) | ||
|
||
inline void update_fifo(const float input, | ||
const int fifo_length, | ||
float* fifo_memory) | ||
{ | ||
// move all values in the history one step back and put new value on the top | ||
for (int i = 0; i < fifo_length - 1; i++) | ||
{ | ||
fifo_memory[i] = fifo_memory[i + 1]; | ||
} | ||
fifo_memory[fifo_length - 1] = input; | ||
} | ||
|
||
inline void allocate_initialize(float** array_memory, | ||
const int array_length) | ||
{ | ||
// (delete and) allocate memory | ||
if (*array_memory != nullptr) | ||
{ | ||
delete[] * array_memory; | ||
} | ||
|
||
*array_memory = new float[array_length]; | ||
|
||
// initialization values | ||
for (int i = 0; i < array_length; i++) | ||
{ | ||
(*array_memory)[i] = 0.0f; | ||
} | ||
} | ||
|
||
class FastWriteFIFO | ||
{ | ||
public: | ||
void initialize(const int len) | ||
{ | ||
pointer = 0; | ||
fifo_length = len; | ||
allocate_initialize(&fifo_memory, len); | ||
} | ||
|
||
void add(const float input) | ||
{ | ||
// write new value and increment data pointer with wrap around | ||
fifo_memory[pointer] = input; | ||
pointer = (pointer + 1) % fifo_length; | ||
} | ||
|
||
const float operator[](const int index) | ||
{ | ||
return fifo_memory[(pointer + index) % fifo_length]; | ||
} | ||
|
||
protected: | ||
float* fifo_memory = nullptr; | ||
int pointer; | ||
int fifo_length; | ||
}; |
Oops, something went wrong.