arduino-photometrics/lib/traitement/traitement.cpp

42 lines
1.3 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <Arduino.h>
#include "traitement.h"
Traitement::Traitement(){}
Traitement::~Traitement(){}
/**
* @brief map_r
* * Normalise resistance value
*
* * @param min_res_tab @c int32_t*
* @param max_res_tab @c int32_t*
* @param res_values @c int32_t*
* @param result @c int32_t*
* @param tab_lenght @c uint8_t
*/
void Traitement::map_r(int32_t* min_res_tab, int32_t* max_res_tab, int32_t* res_values, int16_t* result, uint8_t tab_lenght){
for(int i = 0; i < tab_lenght; i++){
result[i] = map(res_values[i], min_res_tab[i], max_res_tab[i], min_out_norm, max_out_norm);
}
}
/**
* @brief res_value_int32_to_uint8
* * Min max res values are measured in specifics condition, mapped value can be under the min val and can be above max val
* This function aim to trunck values and convert to smaller values in memory
* * @param FirstParamName @c ParamType
* @param SecondParamName @c ParamType
* @return @c ReturnType
*/
void Traitement::res_value_int32_to_uint8(int16_t* val_array, uint8_t* converted_val_array, uint8_t tab_lenght){
for(int i = 0; i < tab_lenght; i++){
if(val_array[i] < 0){
val_array[i] = 0;
}else if (val_array[i] > 254){
val_array[i] = 254;
}
converted_val_array[i] = (uint8_t) val_array[i];
}
}