DIY Logging Volt/Ampmeter
|
Utility functionality for high-precision logging voltage/current meter. More...
Go to the source code of this file.
Macros | |
#define | TO_DEC(i) (i <= 9 ? '0' + i : '?') /* return "?" if out of range */ |
Functions | |
float | bytes_to_float (uint8_t byte0, uint8_t byte1, uint8_t byte2, uint8_t byte3) |
Convert four bytes into a float. More... | |
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). More... | |
void | uint32_to_charDec (char *buf, uint32_t value, uint8_t totalChars) |
Convert a uint32_t value to a decimal char array (string). More... | |
Utility functionality for high-precision logging voltage/current meter.
Copyright (C) 2021 - Brecht Van Eeckhoudt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License can be found in the LICENSE
file along with this source code.
Definition in file util.c.
float bytes_to_float | ( | uint8_t | byte0, |
uint8_t | byte1, | ||
uint8_t | byte2, | ||
uint8_t | byte3 | ||
) |
Convert four bytes into a float.
[in] | byte0 | First byte. |
[in] | byte1 | Second byte. |
[in] | byte2 | Third byte. |
[in] | byte3 | Fourth byte. |
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).
[in] | fValue | The float value to convert. |
[in,out] | beforeComma | Pointer to the uint16_t value before the comma. |
[in,out] | afterComma | Pointer to the uint16_t value after the comma. |
[in] | decimalPlaces | Amount of decimal places to use after the comma. |
void uint32_to_charDec | ( | char * | buf, |
uint32_t | value, | ||
uint8_t | totalChars | ||
) |
Convert a uint32_t
value to a decimal char array (string).
This method can also add a specific amount of leading zero's if necessary.
[out] | buf | The buffer to put the resulting string in. This needs to have a length of 10: char buf[10]; ! |
[in] | value | The uint32_t value to convert to a string. |
[in] | totalChars | Total amount of characters, to be filled with leading zero's if necessary. If a value <= 1 is given, no zero's will be added |
Definition at line 149 of file util.c.