Es un backup para las pruebas de firmware y hardware de un ventilador

Dependencies:   mbed QEI FastPWM

Revision:
11:5cb7ae8bd831
Parent:
10:b2d87404309a
Child:
12:3bc2465b034a
--- a/ventilator.cpp	Mon Apr 27 19:52:02 2020 +0000
+++ b/ventilator.cpp	Thu May 07 03:52:31 2020 +0000
@@ -13,7 +13,7 @@
 
 /* Object definition */
 Ticker ticker_int_1ms; // Ticker interrupt
-DigitalOut test_pin(D13);
+DigitalOut  test_pin(LED1);
 
 /* Global variable definition */
 
@@ -22,12 +22,9 @@
 volatile uint8_t pressure_sensor_waveform_update_flag;
 
 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;
@@ -80,6 +77,15 @@
                     first_time_in_state = 0;
                     nextion_display.printf("t1.pco=%d", ADJUST_COLOR); // Change font color
                     nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
+                    
+                    /* Read pressure sensors if necessary */ 
+                    if(read_pressure_sensors_flag){
+                        Pressure_Sensors_Read();
+                        Calculate_Flow_From_Pressure();
+                        Calculate_Volume_From_Flow();
+                        read_pressure_sensors_flag = 0;
+                    }                     
+                    
                     Volume_Setpoint_Display_Update();
                 }else if(volume_setpoint_index_change_flag){
                     volume_setpoint_index_change_flag = 0; 
@@ -102,6 +108,15 @@
                     first_time_in_state = 0;
                     nextion_display.printf("t4.pco=%d", ADJUST_COLOR); // Change font color
                     nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
+                    
+                    /* Read pressure sensors if necessary */ 
+                    if(read_pressure_sensors_flag){
+                        Pressure_Sensors_Read();
+                        Calculate_Flow_From_Pressure();
+                        Calculate_Volume_From_Flow();
+                        read_pressure_sensors_flag = 0;
+                    }                     
+                    
                     Resp_Frequency_Display_Update();
                 }else if(resp_frequency_index_change_flag){
                     resp_frequency_index_change_flag = 0; 
@@ -125,6 +140,15 @@
                     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);
+                    
+                    /* Read pressure sensors if necessary */ 
+                    if(read_pressure_sensors_flag){
+                        Pressure_Sensors_Read();
+                        Calculate_Flow_From_Pressure();
+                        Calculate_Volume_From_Flow();
+                        read_pressure_sensors_flag = 0;
+                    }                     
+                    
                     I_E_Ratio_Display_Update();
                 }else if(i_e_ratio_index_change_flag){
                     i_e_ratio_index_change_flag = 0; 
@@ -195,7 +219,7 @@
     static uint8_t encoder_conta_1ms = 0;
     static uint8_t sensor_conta_1ms = 0;
     static uint8_t sensor_waveform_conta_1ms = 0;
-    static uint8_t sensor_display_conta_1ms = 0;
+    static uint16_t sensor_display_conta_1ms = 0;
      
     debounce_conta_1ms++;
     encoder_conta_1ms++;
@@ -204,6 +228,7 @@
     sensor_display_conta_1ms++;
     
     
+    
     // Read buttons and performs debounce action
     if(debounce_conta_1ms == DEBOUNCE_PERIOD_MS){
         debounce_conta_1ms = 0;