basic functional test of FT810 LCD via SPI

Dependencies:   FT810 mbed

Revision:
9:bf787d41b645
Parent:
8:886908a6127c
Child:
10:c56b7ca4805f
--- a/main.cpp	Fri Apr 01 18:32:03 2016 +0000
+++ b/main.cpp	Fri Apr 01 19:47:39 2016 +0000
@@ -51,6 +51,9 @@
 unsigned int r, b, g, CalVal0, CalVal1, CalVal2, CalVal3, CalVal4, curX, curY, pasX, pasY;
 float PSEpressure, PFWflowrate = 0.0;
 float ITVpressure1_feedback, ITVpressure2_feedback, ITVpressure1_user_input,  ITVpressure2_user_input = 0.0;
+float ITV1_pre, ITV1_fcal, ITV2_pre, ITV2_fcal, PFW_pre, PFW_fcal, PSE_pre, PSE_fcal = 0.0;
+static float avg1 = 0.05;
+static float avg2 = 0.95;
 uint16_t ITVpressure1_input_raw, ITVpressure2_input_raw, test = 0;
 int16_t velocity, distance, touched, location, paslocation ;
 char buffer[50];
@@ -161,6 +164,11 @@
     TFT.Text(325,275,31,0,buffer);
     TFT.Text(415, 275, 31, 0, " PSI");
     ITVpressure1_feedback = (ITVpressure1_feedback_raw.read_u16() - 9430) * (70.0) / (48430 - 9430) + 0;
+    ITV1_fcal = ITVpressure1_feedback;
+    ITV1_fcal *= avg1;
+    ITV1_fcal += ITV1_pre * avg2;
+    ITV1_pre = ITV1_fcal;
+    ITVpressure1_feedback = ITV1_fcal;
     TFT.DL(COLOR_RGB(255,255,255));
     TFT.FgColor(COLOR_RGB(0,124,196));
     TFT.BgColor(COLOR_RGB(0,124,196));
@@ -194,6 +202,11 @@
     TFT.Text(325,275,31,0,buffer);
     TFT.Text(415, 275, 31, 0, " PSI");
     ITVpressure2_feedback = (ITVpressure2_feedback_raw.read_u16()- 9365) * (70.0) / (48420 - 9365) + 0;
+    ITV2_fcal = ITVpressure2_feedback;
+    ITV2_fcal *= avg1;
+    ITV2_fcal += ITV2_pre * avg2;
+    ITV2_pre = ITV2_fcal;
+    ITVpressure2_feedback = ITV2_fcal;
     TFT.DL(COLOR_RGB(255,255,255));
     TFT.FgColor(COLOR_RGB(0,124,196));
     TFT.BgColor(COLOR_RGB(0,124,196));
@@ -208,6 +221,11 @@
     TFT.DL(VERTEX2F(300*16,85*16));
     TFT.DL(VERTEX2F(505*16,150*16));
     PFWflowrate = (PFWflowrate_raw.read_u16() - 10355) * (40.0) / (51920 - 10355) + 0;
+    PFW_fcal = PFWflowrate;
+    PFW_fcal *= avg1;
+    PFW_fcal += PFW_pre * avg2;
+    PFW_pre = PFW_fcal;
+    PFWflowrate = PFW_fcal;
     TFT.DL(COLOR_RGB(255,255,255));
     sprintf(buffer, "%.1f", PFWflowrate);
     TFT.Text(285,95,31,0,buffer);
@@ -234,7 +252,12 @@
     TFT.DL(VERTEX2F(295*16,265*16));
     TFT.DL(VERTEX2F(505*16,330*16));
     TFT.DL(END());
-    PSEpressure = (PSEpressure_raw.read_u16() - 10440) * (1.0) / (52350 - 10440) + 0;;
+    PSEpressure = (PSEpressure_raw.read_u16() - 10440) * (1.0) / (52350 - 10440) + 0;
+    PSE_fcal = PSEpressure;
+    PSE_fcal *= avg1;
+    PSE_fcal += PSE_pre * avg2;
+    PSE_pre = PSE_fcal;
+    PSEpressure = PSE_fcal;
     TFT.DL(COLOR_RGB(255,255,255));
     sprintf(buffer, "%.2f", PSEpressure);
     //test = ISEpressure_raw.read_u16();