DIY Logging Volt/Ampmeter
util.h
Go to the documentation of this file.
1 /***************************************************************************//**
2  * @file util.h
3  * @brief Utility functionality for high-precision logging voltage/current meter.
4  * @version 1.0
5  * @author Brecht Van Eeckhoudt
6  *
7  * ******************************************************************************
8  *
9  * @section Versions
10  *
11  * @li v1.0: Initial version.
12  *
13  * ******************************************************************************
14  *
15  * @section License
16  *
17  * **Copyright (C) 2021 - Brecht Van Eeckhoudt**
18  *
19  * This program is free software: you can redistribute it and/or modify
20  * it under the terms of the **GNU General Public License** as published by
21  * the Free Software Foundation, either **version 3** of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * *A copy of the GNU General Public License can be found in the `LICENSE`
30  * file along with this source code.*
31  *
32  ******************************************************************************/
33 
34 
35 /* Include guards prevent multiple inclusions of the same header */
36 #ifndef __UTIL_H_
37 #define __UTIL_H_
38 
39 
40 /* Includes necessary for this header file */
41 #include <stdint.h> /* (u)intXX_t */
42 
43 
44 /* Public definitions */
45 // None
46 
47 
48 /* Public prototypes */
49 float bytes_to_float(uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3);
50 void splitFloat(float fValue, uint16_t *beforeComma, uint16_t *afterComma, uint8_t decimalPlaces);
51 void uint32_to_charDec(char *buf, uint32_t value, uint8_t totalChars);
52 
53 
54 #endif /* __UTIL_H_ */
splitFloat
void splitFloat(float fValue, uint16_t *beforeComma, uint16_t *afterComma, uint8_t decimalPlaces)
Split a float value in two uint values (before and after the comma).
Definition: util.c:107
bytes_to_float
float bytes_to_float(uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3)
Convert four bytes into a float.
Definition: util.c:72
uint32_to_charDec
void uint32_to_charDec(char *buf, uint32_t value, uint8_t totalChars)
Convert a uint32_t value to a decimal char array (string).
Definition: util.c:149