Miguel Angel Caycho
/
Pruebas_Ventilador_Eplimin_01_Backup
para el ventilador
ventilator.cpp
- Committer:
- miguelangel_2511
- Date:
- 2020-04-20
- Revision:
- 6:d38287621cca
- Parent:
- 2:6f618b905d4f
- Child:
- 7:f4e248182d31
File content as of revision 6:d38287621cca:
/* File inclusion */ #include "mbed.h" #include "stdint.h" #include "QEI.h" #include "project_defines.h" #include "buttons.h" #include "encoder_interface.h" #include "nextion_interface.h" #include "ventilator.h" /* Global variable definition */ uint16_t volume_setpoint = VOLUME_SETPOINT_VALUE_DEFAULT; uint16_t volume_measured = 480; uint8_t resp_frequency = RESP_FREQUENCY_VALUE_DEFAULT; float inspiration_time = INSPIRATION_TIME_VALUE_DEFAULT; float expiration_time = EXPIRATION_TIME_VALUE_DEFAULT; uint8_t pressure_measured = 16; uint8_t gas_input = AIR_INPUT; Main_Screen_State_t main_screen_state = MAIN_SCREEN_DEFAULT_STATE; uint8_t first_time_in_state = 1; /* Function definition */ void Nextion_Encoder_Interaction(void){ switch(main_screen_state){ case Main_Screen_Cursor_Disable: if(Get_Button_Press(1 << ENTER_SW)){ rotary_encoder.reset(); main_screen_state = Main_Screen_Cursor_Enable; } break; case Main_Screen_Cursor_Enable: if(first_time_in_state){ first_time_in_state = 0; Parameter_Selection_Box_Update(); }else if(parameter_selection_index_change_flag){ parameter_selection_index_change_flag = 0; Parameter_Selection_Box_Update(); }else{ //Does nothing } if(Get_Button_Press(1 << ENTER_SW)){ main_screen_state = (Main_Screen_State_t)(2 + parameter_selection_index); first_time_in_state = 1; } break; case Main_Screen_Volume_Setpoint_Adjust: if(first_time_in_state){ first_time_in_state = 0; nextion_display.printf("t6.pco=%d", ADJUST_COLOR); // Change font color nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff); pc.printf("t6.pco=%d\n\r", ADJUST_COLOR); // Change font color pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff); Volume_Setpoint_Display_Update(); }else if(volume_setpoint_index_change_flag){ volume_setpoint_index_change_flag = 0; Volume_Setpoint_Display_Update(); }else{ //Does nothing } if(Get_Button_Press(1 << ENTER_SW)){ main_screen_state = Main_Screen_Cursor_Disable; first_time_in_state = 1; Volume_Setpoint_Fix(); Parameter_Selection_Box_Remove(); } break; case Main_Screen_Resp_Frequency_Adjust: if(first_time_in_state){ first_time_in_state = 0; nextion_display.printf("t7.pco=%d", ADJUST_COLOR); // Change font color nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff); pc.printf("t7.pco=%d\n\r", ADJUST_COLOR); // Change font color pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff); Resp_Frequency_Display_Update(); }else if(resp_frequency_index_change_flag){ resp_frequency_index_change_flag = 0; Resp_Frequency_Display_Update(); }else{ //Does nothing } if(Get_Button_Press(1 << ENTER_SW)){ main_screen_state = Main_Screen_Cursor_Disable; first_time_in_state = 1; Resp_Frequency_Fix(); Parameter_Selection_Box_Remove(); } break; case Main_Screen_I_E_Ratio_Adjust: if(first_time_in_state){ first_time_in_state = 0; nextion_display.printf("t8.pco=%d", ADJUST_COLOR); // Change font color nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff); pc.printf("t8.pco=%d\n\r", ADJUST_COLOR); // Change font color pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff); I_E_Ratio_Display_Update(); }else if(i_e_ratio_index_change_flag){ i_e_ratio_index_change_flag = 0; I_E_Ratio_Display_Update(); }else{ //Does nothing } if(Get_Button_Press(1 << ENTER_SW)){ main_screen_state = Main_Screen_Cursor_Disable; first_time_in_state = 1; I_E_Ratio_Fix(); Parameter_Selection_Box_Remove(); } break; default: break; } }