School project.

Dependencies:   Timezone NTPClient BSP_DISCO_F746NG Grove_temperature

rotary_functions.h

Committer:
tuxx0046
Date:
2021-01-14
Revision:
9:fd1f07a4a0ff
Child:
10:137cf2c92871

File content as of revision 9:fd1f07a4a0ff:

/**
@file rotary_functions.h
@brief Functions related to the Grove Rotary Angle Sensor

@author Tu Tri Huynh
@date 1/14/2021
*/

/** 
Check if rotary has been turned. Returns true if rotary has been turned to a certain point (margin set).
1/14/2021
*/
bool rotary_is_on(AnalogIn rot)
{
    if (rot.read() >= 0.10f) {
        return true;
    }
    return false;
}

/**
Reverses the value of the analog rotary reading, which reads the resistance of the rotary so 0 becomes 1 and 1 becomes 0. 
The rotary increases in resistance as the rotary is turned, while the light sensor decreases it resistance as light intensity increases.
The led_set_blink_rate() function is fitted to the light sensor read values and set to decrease blinking speed the higher the value.
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.
1/14/2021
*/
float rotary_reverse_read(AnalogIn rot)
{
    return (1 - rot.read());
}