Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI FastPWM
Diff: nextion_interface.cpp
- Revision:
- 7:f4e248182d31
- Parent:
- 6:d38287621cca
- Child:
- 8:208d965a3bd2
--- a/nextion_interface.cpp Mon Apr 20 11:39:30 2020 +0000
+++ b/nextion_interface.cpp Mon Apr 20 21:58:36 2020 +0000
@@ -4,14 +4,15 @@
#include "project_defines.h"
#include "nextion_interface.h"
#include "encoder_interface.h"
+#include "pressure_sensors.h"
+#include "stepper_motor_driver.h"
#include "ventilator.h"
-#include "stepper_motor_driver.h"
+
/* Object definition */
+Serial nextion_display(NEXTION_DISPLAY_TX_PIN,NEXTION_DISPLAY_RX_PIN);
// For testing pusposes only
-Serial pc(USBTX, USBRX);
-Serial nextion_display(NEXTION_TX_PIN,NEXTION_RX_PIN);
-
+//Serial pc(USBTX, USBRX);
/* Global variable definition */
@@ -40,10 +41,10 @@
void Nextion_Interface_Initialize(void){
/* Configure baud rate */
- nextion_display.baud(9600);
- pc.baud(115200);
+ nextion_display.baud(NEXTION_DISPLAY_BAUD_RATE);
+ //pc.baud(115200);
- pc.printf("PUERTO SERIAL HABILITADO\n\n\r");
+ //pc.printf("PUERTO SERIAL HABILITADO\n\n\r");
/* Set font color */
nextion_display.printf("t6.pco=%d", NORMAL_COLOR);
@@ -53,12 +54,12 @@
nextion_display.printf("t8.pco=%d", NORMAL_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t6.pco=%d\n\r", NORMAL_COLOR);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
- pc.printf("t7.pco=%d\n\r", NORMAL_COLOR);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
- pc.printf("t8.pco=%d\n\r", NORMAL_COLOR);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t6.pco=%d\n\r", NORMAL_COLOR);
+ //pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t7.pco=%d\n\r", NORMAL_COLOR);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t8.pco=%d\n\r", NORMAL_COLOR);
+ //pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
/* Print default values */
Volume_Setpoint_Fix();
@@ -77,20 +78,20 @@
case 0:
nextion_display.printf("t6.pco=%d", NORMAL_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t6.pco=%d", NORMAL_COLOR);
- pc.printf("%c%c%c", 0xff, 0xff, 0xff);
+ // pc.printf("t6.pco=%d", NORMAL_COLOR);
+ // pc.printf("%c%c%c", 0xff, 0xff, 0xff);
break;
case 1:
nextion_display.printf("t7.pco=%d", NORMAL_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t7.pco=%d\n\r", NORMAL_COLOR);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t7.pco=%d\n\r", NORMAL_COLOR);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
break;
case 2:
nextion_display.printf("t8.pco=%d", NORMAL_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t8.pco=%d\n\r", NORMAL_COLOR);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t8.pco=%d\n\r", NORMAL_COLOR);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
break;
default:
break;
@@ -102,20 +103,20 @@
case 0:
nextion_display.printf("t6.pco=%d", SELECT_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t6.pco=%d", SELECT_COLOR);
- pc.printf("%c%c%c", 0xff, 0xff, 0xff);
+ // pc.printf("t6.pco=%d", SELECT_COLOR);
+ // pc.printf("%c%c%c", 0xff, 0xff, 0xff);
break;
case 1:
nextion_display.printf("t7.pco=%d", SELECT_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t7.pco=%d\n\r", SELECT_COLOR);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t7.pco=%d\n\r", SELECT_COLOR);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
break;
case 2:
nextion_display.printf("t8.pco=%d", SELECT_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t8.pco=%d\n\r", SELECT_COLOR);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t8.pco=%d\n\r", SELECT_COLOR);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
break;
default:
break;
@@ -132,20 +133,20 @@
case 0:
nextion_display.printf("t6.pco=%d", NORMAL_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t6.pco=%d", NORMAL_COLOR);
- pc.printf("%c%c%c", 0xff, 0xff, 0xff);
+ // pc.printf("t6.pco=%d", NORMAL_COLOR);
+ // pc.printf("%c%c%c", 0xff, 0xff, 0xff);
break;
case 1:
nextion_display.printf("t7.pco=%d", NORMAL_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t7.pco=%d\n\r", NORMAL_COLOR);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t7.pco=%d\n\r", NORMAL_COLOR);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
break;
case 2:
nextion_display.printf("t8.pco=%d", NORMAL_COLOR);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t8.pco=%d\n\r", NORMAL_COLOR);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t8.pco=%d\n\r", NORMAL_COLOR);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
break;
default:
break;
@@ -163,8 +164,8 @@
/* Print volume value */
nextion_display.printf("t6.txt=\"%d mL\"", volume_setpoint_display);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t6.txt=\"%d mL\"\n\r", volume_setpoint_display);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t6.txt=\"%d mL\"\n\r", volume_setpoint_display);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
}
@@ -176,8 +177,8 @@
/* Print volume value */
nextion_display.printf("t6.txt=\"%d mL\"", volume_setpoint_display);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t6.txt=\"%d mL\"\n\r", volume_setpoint_display);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t6.txt=\"%d mL\"\n\r", volume_setpoint_display);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
}
@@ -188,8 +189,8 @@
/* Print frequency value */
nextion_display.printf("t7.txt=\"%d RPM\"", resp_frequency_display);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t7.txt=\"%d RPM\"\n\r", resp_frequency_display);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t7.txt=\"%d RPM\"\n\r", resp_frequency_display);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
}
@@ -201,8 +202,8 @@
/* Print frequency value */
nextion_display.printf("t7.txt=\"%d RPM\"", resp_frequency_display);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t7.txt=\"%d RPM\"\n\r", resp_frequency_display);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t7.txt=\"%d RPM\"\n\r", resp_frequency_display);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
}
@@ -214,8 +215,8 @@
/* Print i:e ratio value */
nextion_display.printf("t8.txt=\"%2.1f/%2.1f\"", inspiration_time_display, expiration_time_display);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t8.txt=\"%2.1f/%2.1f\"\n\r", inspiration_time_display, expiration_time_display);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t8.txt=\"%2.1f/%2.1f\"\n\r", inspiration_time_display, expiration_time_display);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
}
@@ -228,6 +229,21 @@
/* Print i:e ratio value */
nextion_display.printf("t8.txt=\"%2.1f/%2.1f\"", inspiration_time_display, expiration_time_display);
nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
- pc.printf("t8.txt=\"%2.1f/%2.1f\"\n\r", inspiration_time_display, expiration_time_display);
- pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
+ // pc.printf("t8.txt=\"%2.1f/%2.1f\"\n\r", inspiration_time_display, expiration_time_display);
+ // pc.printf("%c%c%c\n\r", 0xff, 0xff, 0xff);
}
+
+void Pressure_01_Display_Update(void){
+ nextion_display.printf("t1.txt=\"%.2f mL\"", pressure_01_psi);
+ nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
+}
+
+void Pressure_02_Display_Update(void){
+ nextion_display.printf("t2.txt=\"%.2f mL\"", pressure_02_psi);
+ nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
+}
+
+void Diff_Pressure_Display_Update(void){
+ nextion_display.printf("t0.txt=\"%.2f mL\"", diff_pressure_psi);
+ nextion_display.printf("%c%c%c", 0xff, 0xff, 0xff);
+}
\ No newline at end of file