School project.

Dependencies:   Timezone NTPClient BSP_DISCO_F746NG Grove_temperature

Committer:
tuxx0046
Date:
Thu Jan 14 14:07:01 2021 +0000
Revision:
9:fd1f07a4a0ff
Child:
10:137cf2c92871
Added rotary functions.; Fixed some minor things and comments.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tuxx0046 9:fd1f07a4a0ff 1 /**
tuxx0046 9:fd1f07a4a0ff 2 @file rotary_functions.h
tuxx0046 9:fd1f07a4a0ff 3 @brief Functions related to the Grove Rotary Angle Sensor
tuxx0046 9:fd1f07a4a0ff 4
tuxx0046 9:fd1f07a4a0ff 5 @author Tu Tri Huynh
tuxx0046 9:fd1f07a4a0ff 6 @date 1/14/2021
tuxx0046 9:fd1f07a4a0ff 7 */
tuxx0046 9:fd1f07a4a0ff 8
tuxx0046 9:fd1f07a4a0ff 9 /**
tuxx0046 9:fd1f07a4a0ff 10 Check if rotary has been turned. Returns true if rotary has been turned to a certain point (margin set).
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 9:fd1f07a4a0ff 15 if (rot.read() >= 0.10f) {
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 9:fd1f07a4a0ff 23 The rotary increases in resistance as the rotary is turned, while the light sensor decreases it 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 9:fd1f07a4a0ff 26 1/14/2021
tuxx0046 9:fd1f07a4a0ff 27 */
tuxx0046 9:fd1f07a4a0ff 28 float rotary_reverse_read(AnalogIn rot)
tuxx0046 9:fd1f07a4a0ff 29 {
tuxx0046 9:fd1f07a4a0ff 30 return (1 - rot.read());
tuxx0046 9:fd1f07a4a0ff 31 }