School project.

Dependencies:   Timezone NTPClient BSP_DISCO_F746NG Grove_temperature

Committer:
tuxx0046
Date:
Mon Jan 18 13:39:58 2021 +0000
Revision:
13:41debc0b9063
Parent:
10:137cf2c92871
Child:
14:3ac7c08dbc52
Temperature reading functionality added.; Button functionality added, so a button press will change temperature from celsius to fahrenheit.; Comments fixed and added.

Who changed what in which revision?

UserRevisionLine numberNew 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 10:137cf2c92871 10 @read_value Float value from the read() function in analog units.
tuxx0046 8:1a1e7cf7dcb6 11 1/14/2021
tuxx0046 8:1a1e7cf7dcb6 12 */
tuxx0046 8:1a1e7cf7dcb6 13 int helper_get_sensor_read_in_percent(float read_value)
tuxx0046 8:1a1e7cf7dcb6 14 {
tuxx0046 8:1a1e7cf7dcb6 15 return (int)(read_value*100);
tuxx0046 13:41debc0b9063 16 }
tuxx0046 13:41debc0b9063 17
tuxx0046 13:41debc0b9063 18 /**
tuxx0046 13:41debc0b9063 19 This function returns a rounded float value, used for temperature readings.
tuxx0046 13:41debc0b9063 20 @temp Temperature value to be rounded
tuxx0046 13:41debc0b9063 21 */
tuxx0046 13:41debc0b9063 22 float helper_round_temperature(float temp)
tuxx0046 13:41debc0b9063 23 {
tuxx0046 13:41debc0b9063 24 return floorf(temp * 100)/100;
tuxx0046 13:41debc0b9063 25 }
tuxx0046 13:41debc0b9063 26
tuxx0046 13:41debc0b9063 27 /**
tuxx0046 13:41debc0b9063 28 This function converts Celsius temperature to Fahrenheit.
tuxx0046 13:41debc0b9063 29 @temp Celsius value
tuxx0046 13:41debc0b9063 30 */
tuxx0046 13:41debc0b9063 31 float helper_convert_celsius_to_fahrenheit(float temp)
tuxx0046 13:41debc0b9063 32 {
tuxx0046 13:41debc0b9063 33 float fahrenheit = ((temp * 9)/5)+32;
tuxx0046 13:41debc0b9063 34 return fahrenheit;
tuxx0046 13:41debc0b9063 35 }
tuxx0046 13:41debc0b9063 36
tuxx0046 13:41debc0b9063 37 /**
tuxx0046 13:41debc0b9063 38 This function reverses the bool value.
tuxx0046 13:41debc0b9063 39 @value Bool value to reverse.
tuxx0046 13:41debc0b9063 40 1/18/2021
tuxx0046 13:41debc0b9063 41 */
tuxx0046 13:41debc0b9063 42 bool helper_reverse_bool(bool value)
tuxx0046 13:41debc0b9063 43 {
tuxx0046 13:41debc0b9063 44 return !value;
tuxx0046 8:1a1e7cf7dcb6 45 }