-
Notifications
You must be signed in to change notification settings - Fork 24
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
[Wip]Diagnostics #336
Open
cua-cua
wants to merge
1
commit into
Bulebots:master
Choose a base branch
from
cua-cua:diagnostics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Wip]Diagnostics #336
Changes from all commits
Commits
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
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,79 @@ | ||
#include "diagnostics.h" | ||
|
||
static volatile float log_matrix[NUM_LOG_ELEMENTS]; | ||
static volatile int log_set_index = -1; | ||
static volatile int log_get_index = -1; | ||
static volatile int num_elements_counter; | ||
static volatile bool enable_diagnostics; | ||
static volatile bool enable_read_log; | ||
|
||
static int inc_log_set_index(void) | ||
{ | ||
if (log_set_index == (NUM_LOG_ELEMENTS - 1)) { | ||
log_set_index = 0; | ||
} else { | ||
log_set_index++; | ||
} | ||
LOG_INFO("%d set_index", log_set_index); | ||
return log_set_index; | ||
} | ||
|
||
static int inc_log_get_index(void) | ||
{ | ||
if (log_get_index == (NUM_LOG_ELEMENTS - 1)) { | ||
log_get_index = 0; | ||
} else { | ||
log_get_index++; | ||
} | ||
LOG_INFO("%d get_index", log_get_index); | ||
return log_get_index; | ||
} | ||
|
||
bool get_enable_diagnostics(void) | ||
{ | ||
return enable_diagnostics; | ||
} | ||
|
||
void set_enable_diagnostics(bool value) | ||
{ | ||
enable_diagnostics = value; | ||
} | ||
|
||
int get_log_set_index(void) | ||
{ | ||
return log_set_index; | ||
} | ||
|
||
/** | ||
* @brief Function to set the sensors distance. | ||
*/ | ||
void set_log_matrix(void) | ||
{ | ||
if (get_enable_diagnostics()) { | ||
log_matrix[inc_log_set_index()] = get_front_left_distance(); | ||
} | ||
} | ||
|
||
/** | ||
* @brief Function to get the sensors distance. | ||
* | ||
*@return The log_matrix | ||
*/ | ||
float get_log_matrix_element(void) | ||
{ | ||
if (num_elements_counter < NUM_LOG_ELEMENTS) { | ||
num_elements_counter++; | ||
return log_matrix[inc_log_get_index()]; | ||
} | ||
return 0; | ||
} | ||
|
||
/** | ||
* @brief Function to reset the buffer. | ||
*/ | ||
void reset_log_matrix(void) | ||
{ | ||
log_set_index = -1; | ||
log_get_index = -1; | ||
num_elements_counter = 0; | ||
} |
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,17 @@ | ||
#ifndef __DIAGNOSTICS_H | ||
#define __DIAGNOSTICS_H | ||
|
||
#include "detection.h" | ||
#include "formatting.h" | ||
|
||
#define NUM_LOG_ELEMENTS 2000 | ||
|
||
void set_log_matrix(void); | ||
float get_log_matrix_element(void); | ||
void set_enable_diagnostics(bool value); | ||
bool get_enable_diagnostics(void); | ||
int get_log_set_index(void); | ||
void reset_log_matrix(void); | ||
|
||
|
||
#endif /* __DIAGNOSTICS_H */ |
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
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
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.
I think we should not have this method. It would print unintelligible characters and the output may be huge.