School project.
Dependencies: Timezone NTPClient BSP_DISCO_F746NG Grove_temperature
Diff: main_functions.h
- Revision:
- 15:638e65c37d58
- Parent:
- 14:3ac7c08dbc52
- Child:
- 16:296d68305630
--- a/main_functions.h Mon Jan 18 16:13:13 2021 +0000 +++ b/main_functions.h Tue Jan 19 10:05:13 2021 +0000 @@ -2,17 +2,56 @@ @file main_functions.h @author Tu Tri Huynh @date January 18, 2021 -@brief Functions to be envoked in main funtion. Will use global variables. +@brief Functions to be envoked in main funtion. Uses global variables. */ /** This function will update the sensor readings. -1/18/21 +1/18/2021 */ void update_readings() { - light_sensor_reading = light_sensor.read(); + light_sensor_reading = light_sensor.read(); light_intensity = helper_get_sensor_read_in_percent(light_sensor_reading); rotary_reading = rotary.read(); rotary_setting = helper_get_sensor_read_in_percent(rotary_reading); -} \ No newline at end of file +} + +/** +This function will check which sensor controls the light, allowing the rotary or the light sensor to determine blink rate, +and updates the lcd display accordingly +1/19/2021 +*/ +void check_light_control() +{ + if (rotary_is_on(rotary)) + { + led_set_blink_rate(rotary_reverse_read(rotary_reading)); + } + else + { + led_set_blink_rate(light_sensor_reading); + } + + lcd_update_upper_right(light_intensity, rotary_setting); +} + +/** +Reads the temperature and updates the display if temperature has changed. +1/19/2021 +*/ +void update_temperature(bool switch_temp) +{ + int new_temp = (int)temp.getTemperature(); + /// Update if change in temperature + if (current_temp != new_temp) + { + current_temp = new_temp; + lcd_update_lower_right(temp.getTemperature(), is_fahrenheit); + } + /// Change temperature unit + else if (switch_temp == true) + { + lcd_update_lower_right(temp.getTemperature(), is_fahrenheit); + } +}