Formula Student Electronics & Software
The code for the embedded software
Loading...
Searching...
No Matches
utils.hpp File Reference
#include <cstdint>
#include <deque>
#include <numeric>
Include dependency graph for utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  float2bytes
 

Functions

void insert_value_queue (const int value, std::deque< int > &queue)
 
int average_queue (const std::deque< int > &queue)
 
bool check_sequence (const uint8_t *data, const std::array< uint8_t, 3 > &expected)
 
void rpm_2_byte (const float rr_rpm, char *rr_rpm_byte)
 
void debounce (const bool new_value, bool &stored_value, unsigned int &counter, const unsigned int counter_limit)
 debounce function to avoid sporadic changes (and repeating the code everywhere)
 
void debounce (const bool new_value, bool &stored_value, unsigned int &counter)
 

Function Documentation

◆ average_queue()

int average_queue ( const std::deque< int > &  queue)

Definition at line 14 of file utils.hpp.

◆ check_sequence()

bool check_sequence ( const uint8_t *  data,
const std::array< uint8_t, 3 > &  expected 
)

Definition at line 23 of file utils.hpp.

◆ debounce() [1/2]

void debounce ( const bool  new_value,
bool &  stored_value,
unsigned int &  counter 
)

Definition at line 71 of file utils.hpp.

Here is the call graph for this function:

◆ debounce() [2/2]

void debounce ( const bool  new_value,
bool &  stored_value,
unsigned int &  counter,
const unsigned int  counter_limit 
)

debounce function to avoid sporadic changes (and repeating the code everywhere)

Parameters
new_valueThe newly read value
stored_valueReference to the stored value that will be updated
counterReference to the counter for this specific input
counter_limitNumber of consecutive different readings before accepting change

Definition at line 58 of file utils.hpp.

Here is the caller graph for this function:

◆ insert_value_queue()

void insert_value_queue ( const int  value,
std::deque< int > &  queue 
)

Definition at line 6 of file utils.hpp.

◆ rpm_2_byte()

void rpm_2_byte ( const float  rr_rpm,
char *  rr_rpm_byte 
)

Definition at line 32 of file utils.hpp.

Here is the caller graph for this function: