-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/getset bits #211
Merged
+57
−46
Merged
Feature/getset bits #211
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2f4449d
#173: casual lowpass filter
DimitryP6 5e4840d
#173: finalized file location
DimitryP6 6799607
#200: created macros for adding and setting bits
DimitryP6 39abc7e
#200: changed macro name to avoid redefinition error, and added if el…
DimitryP6 294e51e
#200 : moved endif to end of file
DimitryP6 4cb4aa1
#200 : pulled changes and fixed formatting issue
DimitryP6 3177949
Delete middleware/simple_ema.c
DimitryP6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: clang_restage | ||
name: Restage formatted files | ||
entry: clang_restage | ||
language: system | ||
pass_filenames: false | ||
always_run: true | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: clang_restage | ||
name: Restage formatted files | ||
entry: clang_restage | ||
language: system | ||
pass_filenames: false | ||
always_run: true | ||
stages: [pre-commit] |
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 |
---|---|---|
@@ -1,18 +1,29 @@ | ||
#ifndef C_UTILS | ||
#define C_UTILS | ||
|
||
/* | ||
* Will retrieve the container of a certain pointer given the container type and | ||
* its pointer Trick pulled from Linux Kernel | ||
*/ | ||
#define CONTAINER_OF(ptr, type, member) \ | ||
((type *)((char *)(ptr) - offsetof(type, member))) | ||
|
||
#endif /* C_UTILS */ | ||
|
||
void endian_swap(void *ptr, int size); | ||
|
||
/// @brief Reverses the bit order of a byte | ||
/// @param b byte | ||
/// @return the same byte but wuth the bits reversed | ||
#ifndef C_UTILS | ||
#define C_UTILS | ||
|
||
/* | ||
* Will retrieve the container of a certain pointer given the container type and | ||
* its pointer Trick pulled from Linux Kernel | ||
*/ | ||
#define CONTAINER_OF(ptr, type, member) \ | ||
((type *)((char *)(ptr) - offsetof(type, member))) | ||
|
||
/* | ||
* Gets a bit of a binary number at desired location | ||
*/ | ||
#define NER_GET_BIT(num, bit) ((num >> bit) & 1) | ||
|
||
/* | ||
* Sets a bit of a binary number at desired location | ||
*/ | ||
#define NER_SET_BIT(num, bit) \ | ||
bit < (sizeof(num) * 8) ? (num |= (1UL << bit)) : num | ||
|
||
#endif /* C_UTILS */ | ||
|
||
void endian_swap(void *ptr, int size); | ||
|
||
/// @brief Reverses the bit order of a byte | ||
/// @param b byte | ||
/// @return the same byte but wuth the bits reversed | ||
unsigned char reverse_bits(unsigned char b); |
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,8 @@ | ||
#include <stdio.h> | ||
|
||
// Exponential Moving Average Lowpass Filter | ||
void ema_filter(float current_value, float *previous_ema, float alpha) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should only appear in ur other PR. |
||
{ | ||
*previous_ema = | ||
(alpha * current_value) + ((1 - alpha) * (*previous_ema)); | ||
} |
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
#include "c_utils.h" | ||
|
||
void endian_swap(void *ptr, int size) | ||
{ | ||
char *p = (char *)ptr; | ||
char tmp; | ||
for (int i = 0; i < size / 2; i++) { | ||
tmp = p[i]; | ||
p[i] = p[size - i - 1]; | ||
p[size - i - 1] = tmp; | ||
} | ||
} | ||
|
||
unsigned char reverse_bits(unsigned char b) | ||
{ | ||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; | ||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2; | ||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1; | ||
return b; | ||
#include "c_utils.h" | ||
void endian_swap(void *ptr, int size) | ||
{ | ||
char *p = (char *)ptr; | ||
char tmp; | ||
for (int i = 0; i < size / 2; i++) { | ||
tmp = p[i]; | ||
p[i] = p[size - i - 1]; | ||
p[size - i - 1] = tmp; | ||
} | ||
} | ||
unsigned char reverse_bits(unsigned char b) | ||
{ | ||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; | ||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2; | ||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1; | ||
return b; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put endif at the end of the file