School project.
Dependencies: Timezone NTPClient BSP_DISCO_F746NG Grove_temperature
helper_functions.h@20:9d4450357ce7, 2021-01-21 (annotated)
- Committer:
- tuxx0046
- Date:
- Thu Jan 21 12:43:03 2021 +0000
- Revision:
- 20:9d4450357ce7
- Parent:
- 15:638e65c37d58
Updated libraries used section in comments in main.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tuxx0046 | 8:1a1e7cf7dcb6 | 1 | /** |
tuxx0046 | 10:137cf2c92871 | 2 | @file helper_functions.h |
tuxx0046 | 10:137cf2c92871 | 3 | @author Tu Tri Huynh |
tuxx0046 | 10:137cf2c92871 | 4 | @date January 14, 2021 |
tuxx0046 | 10:137cf2c92871 | 5 | @brief Functions to help with general tasks. |
tuxx0046 | 8:1a1e7cf7dcb6 | 6 | */ |
tuxx0046 | 8:1a1e7cf7dcb6 | 7 | |
tuxx0046 | 8:1a1e7cf7dcb6 | 8 | /** |
tuxx0046 | 8:1a1e7cf7dcb6 | 9 | This function returns the percentage of AnalogIn sensor read values that by default are floating point numbers between 0.00 to 1.00. |
tuxx0046 | 15:638e65c37d58 | 10 | @param read_value Float value from the read() function in analog units |
tuxx0046 | 15:638e65c37d58 | 11 | @return whole number that represents percentage. |
tuxx0046 | 8:1a1e7cf7dcb6 | 12 | 1/14/2021 |
tuxx0046 | 8:1a1e7cf7dcb6 | 13 | */ |
tuxx0046 | 8:1a1e7cf7dcb6 | 14 | int helper_get_sensor_read_in_percent(float read_value) |
tuxx0046 | 8:1a1e7cf7dcb6 | 15 | { |
tuxx0046 | 8:1a1e7cf7dcb6 | 16 | return (int)(read_value*100); |
tuxx0046 | 13:41debc0b9063 | 17 | } |
tuxx0046 | 13:41debc0b9063 | 18 | |
tuxx0046 | 13:41debc0b9063 | 19 | /** |
tuxx0046 | 13:41debc0b9063 | 20 | This function returns a rounded float value, used for temperature readings. |
tuxx0046 | 14:3ac7c08dbc52 | 21 | @param temp Temperature value to be rounded |
tuxx0046 | 13:41debc0b9063 | 22 | */ |
tuxx0046 | 13:41debc0b9063 | 23 | float helper_round_temperature(float temp) |
tuxx0046 | 13:41debc0b9063 | 24 | { |
tuxx0046 | 13:41debc0b9063 | 25 | return floorf(temp * 100)/100; |
tuxx0046 | 13:41debc0b9063 | 26 | } |
tuxx0046 | 13:41debc0b9063 | 27 | |
tuxx0046 | 13:41debc0b9063 | 28 | /** |
tuxx0046 | 13:41debc0b9063 | 29 | This function converts Celsius temperature to Fahrenheit. |
tuxx0046 | 14:3ac7c08dbc52 | 30 | @param temp Celsius value |
tuxx0046 | 13:41debc0b9063 | 31 | */ |
tuxx0046 | 13:41debc0b9063 | 32 | float helper_convert_celsius_to_fahrenheit(float temp) |
tuxx0046 | 13:41debc0b9063 | 33 | { |
tuxx0046 | 13:41debc0b9063 | 34 | float fahrenheit = ((temp * 9)/5)+32; |
tuxx0046 | 13:41debc0b9063 | 35 | return fahrenheit; |
tuxx0046 | 13:41debc0b9063 | 36 | } |
tuxx0046 | 13:41debc0b9063 | 37 | |
tuxx0046 | 13:41debc0b9063 | 38 | /** |
tuxx0046 | 13:41debc0b9063 | 39 | This function reverses the bool value. |
tuxx0046 | 14:3ac7c08dbc52 | 40 | @@param value Bool value to reverse. |
tuxx0046 | 13:41debc0b9063 | 41 | 1/18/2021 |
tuxx0046 | 13:41debc0b9063 | 42 | */ |
tuxx0046 | 13:41debc0b9063 | 43 | bool helper_reverse_bool(bool value) |
tuxx0046 | 13:41debc0b9063 | 44 | { |
tuxx0046 | 13:41debc0b9063 | 45 | return !value; |
tuxx0046 | 8:1a1e7cf7dcb6 | 46 | } |