School project.

Dependencies:   Timezone NTPClient BSP_DISCO_F746NG Grove_temperature

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?

UserRevisionLine numberNew contents of line
tuxx0046 9:fd1f07a4a0ff 1 /**
tuxx0046 10:137cf2c92871 2 @file rotary_functions.h
tuxx0046 10:137cf2c92871 3 @author Tu Tri Huynh
tuxx0046 10:137cf2c92871 4 @date January 14, 2021
tuxx0046 10:137cf2c92871 5 @brief Functions related to the Grove Rotary Angle Sensor
tuxx0046 9:fd1f07a4a0ff 6 */
tuxx0046 9:fd1f07a4a0ff 7
tuxx0046 9:fd1f07a4a0ff 8 /**
tuxx0046 9:fd1f07a4a0ff 9 Check if rotary has been turned. Returns true if rotary has been turned to a certain point (margin set).
tuxx0046 14:3ac7c08dbc52 10 @param rot AnalogIn rotary angle sensor object.
tuxx0046 9:fd1f07a4a0ff 11 1/14/2021
tuxx0046 9:fd1f07a4a0ff 12 */
tuxx0046 9:fd1f07a4a0ff 13 bool rotary_is_on(AnalogIn rot)
tuxx0046 9:fd1f07a4a0ff 14 {
tuxx0046 10:137cf2c92871 15 if (rot.read() >= 0.04f) {
tuxx0046 9:fd1f07a4a0ff 16 return true;
tuxx0046 9:fd1f07a4a0ff 17 }
tuxx0046 9:fd1f07a4a0ff 18 return false;
tuxx0046 9:fd1f07a4a0ff 19 }
tuxx0046 9:fd1f07a4a0ff 20
tuxx0046 9:fd1f07a4a0ff 21 /**
tuxx0046 9:fd1f07a4a0ff 22 Reverses the value of the analog rotary reading, which reads the resistance of the rotary so 0 becomes 1 and 1 becomes 0.
tuxx0046 10:137cf2c92871 23 The rotary increases in resistance as the rotary is turned, while the light sensor decreases its resistance as light intensity increases.
tuxx0046 9:fd1f07a4a0ff 24 The led_set_blink_rate() function is fitted to the light sensor read values and set to decrease blinking speed the higher the value.
tuxx0046 9:fd1f07a4a0ff 25 This function can be used to reverse the value of the registered rotary resistance value so it can be used with the LED blinking function.
tuxx0046 15:638e65c37d58 26 @param rotary_value Rotary angle sensor read value.
tuxx0046 9:fd1f07a4a0ff 27 1/14/2021
tuxx0046 9:fd1f07a4a0ff 28 */
tuxx0046 15:638e65c37d58 29 float rotary_reverse_read(float rotary_value)
tuxx0046 9:fd1f07a4a0ff 30 {
tuxx0046 15:638e65c37d58 31 return (1 - rotary_value);
tuxx0046 9:fd1f07a4a0ff 32 }