School project.
Dependencies: Timezone NTPClient BSP_DISCO_F746NG Grove_temperature
main_functions.h
00001 /** 00002 @file main_functions.h 00003 @author Tu Tri Huynh 00004 @date January 18, 2021 00005 @brief Functions to be envoked in main function. Uses global variables. 00006 */ 00007 00008 /** 00009 This function will update the sensor readings. 00010 1/18/2021 00011 */ 00012 void main_update_readings() 00013 { 00014 light_sensor_reading = light_sensor.read(); 00015 light_intensity = helper_get_sensor_read_in_percent(light_sensor_reading); 00016 rotary_reading = rotary.read(); 00017 rotary_setting = helper_get_sensor_read_in_percent(rotary_reading); 00018 } 00019 00020 /** 00021 This function will check which sensor controls the light, allowing the rotary or the light sensor to determine blink rate, 00022 and updates the lcd display accordingly 00023 1/19/2021 00024 */ 00025 void main_check_light_control() 00026 { 00027 if (rotary_is_on(rotary)) 00028 { 00029 led_set_blink_rate(rotary_reverse_read(rotary_reading)); 00030 } 00031 else 00032 { 00033 led_set_blink_rate(light_sensor_reading); 00034 } 00035 00036 lcd_update_upper_right(light_intensity, rotary_setting); 00037 } 00038 00039 /** 00040 Reads the temperature and updates the display if temperature has changed. 00041 1/19/2021 00042 */ 00043 void main_update_temperature(bool switch_temp) 00044 { 00045 int new_temp = (int)temp.getTemperature(); 00046 /// Update if change in temperature 00047 if (current_temp != new_temp) 00048 { 00049 current_temp = new_temp; 00050 lcd_update_lower_right(temp.getTemperature(), is_fahrenheit); 00051 } 00052 /// Check if change temperature unit wanted 00053 else if (switch_temp == true) 00054 { 00055 lcd_update_lower_right(temp.getTemperature(), is_fahrenheit); 00056 } 00057 } 00058 00059 /** 00060 Runs a while loop that checks for button presses 00061 1/19/2021 00062 */ 00063 void main_run_button_check() 00064 { 00065 while(1) 00066 { 00067 switch_temp = button_switch_temp_unit(button, is_fahrenheit); 00068 main_update_temperature(switch_temp); 00069 switch_temp = false; 00070 wait_us(250000); 00071 } 00072 } 00073 00074 /** 00075 Runs the setup menu 00076 1/19/2021 00077 */ 00078 void main_run_setup() 00079 { 00080 lcd_initialize(); 00081 lcd_show_setup_screen(); 00082 setup_run_setup(); 00083 } 00084 00085 /** 00086 Starts the main screen on LCD display 00087 1/19/2021 00088 */ 00089 void main_run_main_screen() 00090 { 00091 lcd_show_main_screen(); 00092 lcd_update_lower_left(building, room); 00093 } 00094
Generated on Fri Jul 15 2022 03:26:25 by 1.7.2