pachas

Dependencies:   mbed QEI FastPWM

Revision:
8:208d965a3bd2
Parent:
7:f4e248182d31
Child:
9:95fdcdc0977e
--- a/project_defines.h	Mon Apr 20 21:58:36 2020 +0000
+++ b/project_defines.h	Thu Apr 23 17:05:36 2020 +0000
@@ -20,11 +20,10 @@
 #define NEXTION_DISPLAY_RX_PIN                  PC_11
 
 // Pressure sensors
-#define PRESSURE_SENSOR_01_SDA_PIN              PB_9
-#define PRESSURE_SENSOR_01_SCL_PIN              PB_8
-
-#define PRESSURE_SENSOR_02_SDA_PIN              PB_10
-#define PRESSURE_SENSOR_02_SCL_PIN              PB_11
+#define PRESSURE_SENSOR_01_SCL_PIN              PB_10
+#define PRESSURE_SENSOR_01_SDA_PIN              PB_11
+#define PRESSURE_SENSOR_02_SCL_PIN              PB_8
+#define PRESSURE_SENSOR_02_SDA_PIN              PB_9
 
 //Stepper motor
 #define STEPPER_PULSE_PIN                       PC_8
@@ -40,6 +39,8 @@
 #define LIMIT_SW_01                             1
 #define GAS_INPUT_SW                            2
 
+#define DEBOUNCE_PERIOD_MS                      10
+
 /* Defines for the encoder user interface */
 #define ENCODER_THRESHOLD                       8
 
@@ -53,9 +54,11 @@
 #define RESP_FREQUENCY_INDEX_DEFAULT            10
 #define I_E_RATIO_INDEX_DEFAULT                 0
 
+#define ENCODER_READ_PERIOD_MS                  50
+
 /* Defines for the Nextion user interface */
 
-#define NEXTION_DISPLAY_BAUD_RATE               9600
+#define NEXTION_DISPLAY_BAUD_RATE               115200
 
 #define BLACK                                   0
 #define BLUE                                    31
@@ -66,25 +69,10 @@
 #define GRAY                                    33840
 #define WHITE                                   65535
 
-#define NORMAL_COLOR                            BLACK
+#define NORMAL_COLOR                            WHITE
 #define SELECT_COLOR                            BLUE
 #define ADJUST_COLOR                            GREEN
 
-//#define BACKGROUND_COLOR                        Black
-//#define INDICATOR_BOX_LINE_COLOR                Green
-//#define INDICATOR_HEADER_TEXT_COLOR             Yellow
-//#define INDICATOR_VALUE_TEXT_COLOR              White
-//#define INDICATOR_UNITS_TEXT_COLOR              White
-//#define PARAMETER_SELECTION_BOX_COLOR           Yellow
-//#define PARAMETER_ADJUST_TEXT_COLOR             Green 
-
-#define HEADERS_ROW1_Y_POS                      20
-#define HEADERS_ROW2_Y_POS                      180
-#define UNITS_ROW1_Y_POS                        103
-#define UNITS_ROW2_Y_POS                        263
-#define VALUES_ROW1_Y_POS                       60
-#define VALUES_ROW2_Y_POS                       220
-
 #define VOLUME_SETPOINT_VALUE_DEFAULT           500
 #define RESP_FREQUENCY_VALUE_DEFAULT            20
 #define INSPIRATION_TIME_VALUE_DEFAULT          1.0
@@ -96,7 +84,25 @@
 #define AIR_INPUT                               0
 #define OXYGEN_INPUT                            1
 
-#define MAIN_SCREEN_DEFAULT_STATE                       Main_Screen_Cursor_Disable
+#define MAIN_SCREEN_DEFAULT_STATE               Main_Screen_Cursor_Disable
+
+#define VOLUME_WAVEFORM_X0                      200
+#define VOLUME_WAVEFORM_Y0                      3
+#define VOLUME_WAVEFORM_WIDTH                   400
+#define VOLUME_WAVEFORM_HEIGHT                  157
+
+#define FLOW_WAVEFORM_X0                        200
+#define FLOW_WAVEFORM_Y0                        162
+#define FLOW_WAVEFORM_WIDTH                     400
+#define FLOW_WAVEFORM_HEIGHT                    157
+
+#define PRESSURE_WAVEFORM_X0                    200
+#define PRESSURE_WAVEFORM_Y0                    321
+#define PRESSURE_WAVEFORM_WIDTH                 400
+#define PRESSURE_WAVEFORM_HEIGHT                157
+
+#define SENSOR_WAVEFORM_PLOT_PERIOD_MS          25
+#define SENSOR_DISPLAY_PERIOD_MS                100
 
 /* Defines for the pressure sensors */
 #define PRESSURE_SENSOR_I2C_CLK_HZ                      200000
@@ -106,8 +112,16 @@
 #define PRESSURE_SENSOR_02_SWA                          (PRESSURE_SENSOR_02_SLAVE_ADDRESS << 1)
 #define PRESSURE_SENSOR_01_SRA                          (PRESSURE_SENSOR_01_SWA  | 1)
 #define PRESSURE_SENSOR_02_SRA                          (PRESSURE_SENSOR_02_SWA  | 1)
+
+#define VOLUME_DISPLAY_THRESHOLD                        0.01f
+#define FLOW_DISPLAY_THRESHOLD                          0.01f
 #define PRESSURE_DISPLAY_THRESHOLD                      0.01f
 
+#define PSI_TO_CMH2O_CONSTANT                           70.307
+#define SPIROMETER_SENSOR_CONSTANT                      1.0f
+
+#define PRESSURE_SENSOR_READ_PERIOD_MS                  1
+
 /* Defines for the stepper motor control */ 
 #define TO_HOME                                         0
 #define TO_AIRBAG                                       1
@@ -142,6 +156,6 @@
 #define STEPPER_START_BRAKE_PERIOD_US                   (1000000.0/STEPPER_START_BRAKE_FREQUENCY_HZ)
 #define SHORT_RAMP_STEPS                                25
 
-#define TUNING_FACTOR                                   1.25
+#define TUNING_FACTOR                                   1.2
 
 #endif