School project.

Dependencies:   Timezone NTPClient BSP_DISCO_F746NG Grove_temperature

Committer:
tuxx0046
Date:
Tue Jan 19 10:05:13 2021 +0000
Revision:
15:638e65c37d58
Parent:
14:3ac7c08dbc52
Child:
16:296d68305630
Updated the main_functions and lcd_functions.; Connected all of the functions to have a working program.; Updated some comments and documentation.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tuxx0046 14:3ac7c08dbc52 1 /**
tuxx0046 14:3ac7c08dbc52 2 @file main_functions.h
tuxx0046 14:3ac7c08dbc52 3 @author Tu Tri Huynh
tuxx0046 14:3ac7c08dbc52 4 @date January 18, 2021
tuxx0046 15:638e65c37d58 5 @brief Functions to be envoked in main funtion. Uses global variables.
tuxx0046 14:3ac7c08dbc52 6 */
tuxx0046 14:3ac7c08dbc52 7
tuxx0046 14:3ac7c08dbc52 8 /**
tuxx0046 14:3ac7c08dbc52 9 This function will update the sensor readings.
tuxx0046 15:638e65c37d58 10 1/18/2021
tuxx0046 14:3ac7c08dbc52 11 */
tuxx0046 14:3ac7c08dbc52 12 void update_readings()
tuxx0046 14:3ac7c08dbc52 13 {
tuxx0046 15:638e65c37d58 14 light_sensor_reading = light_sensor.read();
tuxx0046 14:3ac7c08dbc52 15 light_intensity = helper_get_sensor_read_in_percent(light_sensor_reading);
tuxx0046 14:3ac7c08dbc52 16 rotary_reading = rotary.read();
tuxx0046 14:3ac7c08dbc52 17 rotary_setting = helper_get_sensor_read_in_percent(rotary_reading);
tuxx0046 15:638e65c37d58 18 }
tuxx0046 15:638e65c37d58 19
tuxx0046 15:638e65c37d58 20 /**
tuxx0046 15:638e65c37d58 21 This function will check which sensor controls the light, allowing the rotary or the light sensor to determine blink rate,
tuxx0046 15:638e65c37d58 22 and updates the lcd display accordingly
tuxx0046 15:638e65c37d58 23 1/19/2021
tuxx0046 15:638e65c37d58 24 */
tuxx0046 15:638e65c37d58 25 void check_light_control()
tuxx0046 15:638e65c37d58 26 {
tuxx0046 15:638e65c37d58 27 if (rotary_is_on(rotary))
tuxx0046 15:638e65c37d58 28 {
tuxx0046 15:638e65c37d58 29 led_set_blink_rate(rotary_reverse_read(rotary_reading));
tuxx0046 15:638e65c37d58 30 }
tuxx0046 15:638e65c37d58 31 else
tuxx0046 15:638e65c37d58 32 {
tuxx0046 15:638e65c37d58 33 led_set_blink_rate(light_sensor_reading);
tuxx0046 15:638e65c37d58 34 }
tuxx0046 15:638e65c37d58 35
tuxx0046 15:638e65c37d58 36 lcd_update_upper_right(light_intensity, rotary_setting);
tuxx0046 15:638e65c37d58 37 }
tuxx0046 15:638e65c37d58 38
tuxx0046 15:638e65c37d58 39 /**
tuxx0046 15:638e65c37d58 40 Reads the temperature and updates the display if temperature has changed.
tuxx0046 15:638e65c37d58 41 1/19/2021
tuxx0046 15:638e65c37d58 42 */
tuxx0046 15:638e65c37d58 43 void update_temperature(bool switch_temp)
tuxx0046 15:638e65c37d58 44 {
tuxx0046 15:638e65c37d58 45 int new_temp = (int)temp.getTemperature();
tuxx0046 15:638e65c37d58 46 /// Update if change in temperature
tuxx0046 15:638e65c37d58 47 if (current_temp != new_temp)
tuxx0046 15:638e65c37d58 48 {
tuxx0046 15:638e65c37d58 49 current_temp = new_temp;
tuxx0046 15:638e65c37d58 50 lcd_update_lower_right(temp.getTemperature(), is_fahrenheit);
tuxx0046 15:638e65c37d58 51 }
tuxx0046 15:638e65c37d58 52 /// Change temperature unit
tuxx0046 15:638e65c37d58 53 else if (switch_temp == true)
tuxx0046 15:638e65c37d58 54 {
tuxx0046 15:638e65c37d58 55 lcd_update_lower_right(temp.getTemperature(), is_fahrenheit);
tuxx0046 15:638e65c37d58 56 }
tuxx0046 15:638e65c37d58 57 }