Skip to content

Commit

Permalink
added doxygen comments, added proper syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Noroian committed Nov 28, 2024
1 parent 25814f7 commit 389d3d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
18 changes: 13 additions & 5 deletions middleware/include/high_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ typedef struct {

float prev_output;

} high_pass_st;
} high_pass_t;

void high_pass_init(float alpha, float scale, high_pass_st filter);
/**
@brief Initialization for high pass values
* @brief
*
* @param alpha
* @param scale
* @param filter
*/
void high_pass_init(float alpha, float scale, high_pass_t *filter);

float high_pass(high_pass_st filter, float input);
/**
@brief Function for high pass filter
* @brief
*
* @param filter
* @param input
* @return float
*/
float high_pass(high_pass_t *filter, float input);

#endif
26 changes: 2 additions & 24 deletions middleware/src/high_pass.c
Original file line number Diff line number Diff line change
@@ -1,36 +1,14 @@
/*
Understanding High-Pass Filter Implementation
Goal is to customize the cutoff frequency/strength
One style:
-alpha factor -> smoothing factor used to make the changes smoother
-scale factor -> scales the output given by algo
these two params correlate to strength
Or user could pass desired cutoff frequency and that would be used
Algorithm:
1. first possibility
output = alpha * last_output + (1-alpha) * input
output = alpha * last_output + alpha * (avg - prev_avg)
*/

#include "high_pass.h"

void high_pass_init(float alpha, float scale, high_pass_st filter)
void high_pass_init(float alpha, float scale, high_pass_t *filter)
{
filter->alpha = alpha;
filter->scale = scale;

filter->prev_output = 0.0;
}

//y[n]=x[n]−SMA[n]
//The output is equal to the input - the moving average
float high_pass(high_pass_st filter, float input)
float high_pass(high_pass_t *filter, float input)
{
float output =
filter->scale(input - (filter->alpha * input +
Expand Down

0 comments on commit 389d3d1

Please sign in to comment.