Skip to content

Commit

Permalink
Merge branch 'main' into integrate_pull_request_137
Browse files Browse the repository at this point in the history
# Conflicts:
#	edrumulus.h
#	edrumulus.ino
#	hardware.cpp
#	hardware.h
  • Loading branch information
corrados committed Jun 15, 2024
2 parents 89ab06e + 594ce4a commit ef9c044
Show file tree
Hide file tree
Showing 14 changed files with 2,878 additions and 2,640 deletions.
26 changes: 26 additions & 0 deletions .clang-format
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
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade platformio setuptools wheel
- name: Install clang-format
run: sudo apt-get install clang-format

- name: Check clang-format
run: |
# Only check the format of the files in the root directory
clang-format --dry-run --Werror *.c *.cpp *.h *.ino
- name: Build
run: pio ci -c platformio.ini .
84 changes: 84 additions & 0 deletions common.h
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;
};
Loading

0 comments on commit ef9c044

Please sign in to comment.