Team Riedel - display

Dependencies:   LCD_fonts SPI_TFT_ILI9341 CMSIS_DSP_401_without_cm4 mbed-src SDFileSystem wavfile

Files at this revision

API Documentation at this revision

Comitter:
linx0576
Date:
Sat Dec 12 21:43:03 2015 +0000
Parent:
2:afdb1aaa7608
Child:
4:e1ec41710eb4
Commit message:
up down select

Changed in this revision

CMSIS_DSP_401.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-dsp.lib Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMSIS_DSP_401.lib	Sat Dec 12 21:43:03 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emh203/code/CMSIS_DSP_401/#3d9c67d97d6f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Sat Dec 12 21:43:03 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/neilt6/code/SDFileSystem/#d10a519c0910
--- a/main.cpp	Sat Dec 12 21:13:39 2015 +0000
+++ b/main.cpp	Sat Dec 12 21:43:03 2015 +0000
@@ -7,8 +7,18 @@
 #include "Arial24x23.h"
 #include "arm_math.h" 
 #define num 128
-//AnalogIn analogValue(A2);
-DigitalIn bt(PC_8);
+//AnalogIn ain1(PC_6);
+//AnalogIn ain2(PC_7);
+//AnalogIn ain3(PC_8);
+//AnalogIn ain4(PC_9);
+//AnalogIn ain5(PB_15);
+
+
+DigitalIn ain1(PC_9);
+DigitalIn ain2(PB_15);
+DigitalIn ain3(PC_7);
+DigitalIn ain4(PC_6);
+DigitalIn ain5(PC_8);
 
 /** External Input and Output buffer Declarations for FFT Bin Example **/ 
 //static float32_t testInput_f32_10khz[num]; 
@@ -64,7 +74,7 @@
 
 int main()
 {    
-//    arm_cfft_radix2_instance_f32 S; 
+/*//    arm_cfft_radix2_instance_f32 S; 
     int stage=0;
     int pu, pd, pl, pr, ps;
     TFT.claim(stdout);      // send stdout to the TFT display
@@ -72,15 +82,29 @@
     TFT.set_orientation(2);       // comment out = "||"   include = "="
     TFT.background(Black);    // set background to black
     TFT.foreground(White);    // set chars to white
+    TFT.cls();                // clear the screen*/
+    
+//      arm_cfft_radix2_instance_f32 S; 
+    int stage=0;
+    int menu=0;
+    float32_t mean=0; 
+    float32_t mse=0;
+    float32_t st=0;
+  //  int pu, pd, pl, pr, ps;
+    TFT.claim(stdout);      // send stdout to the TFT display
+    TFT.claim(stderr);      // send stderr to the TFT display
+    TFT.set_orientation(2);       // comment out = "||"   include = "="
+    TFT.background(Black);    // set background to black
+    TFT.foreground(White);    // set chars to white
     TFT.cls();                // clear the screen
     
+    
+    
     while(1)
-    {   TFT.cls();
-        TFT.background(Black);
- 
+    {   int pu, pd, ps; 
+
         if (stage==0)   //menu
-        {   int menu=0;
-            TFT.cls();
+        {   
             TFT.set_font((unsigned char*) Arial24x23);
             TFT.locate(20,60);
             printf("Configuration");
@@ -95,169 +119,230 @@
             printf("   Return");
         
             if (menu==0)    //Configuration
-            {   pu=0; pd=0; pl=0; pr=0; ps=0;
-                TFT.rect(15,55,220,85,GreenYellow);
+            {   TFT.rect(15,55,220,85,Green);
                 TFT.rect(15,105,220,135,Black);
-                ps=1;
-                if (pd==1)  {wait(1);   menu=1;}
-                if (ps==1)  {wait(1);   stage=1;}
+                pu = ain1.read(); 
+                pd = ain2.read(); 
+                ps = ain3.read(); 
+                if (pd==1)  {wait(0.5); menu=1;}
+                if (ps==1)  {wait(0.5); TFT.cls();  stage=1;}
             }
         
             if (menu==1)    //waveform
-            {   pu=0; pd=0; pl=0; pr=0; ps=0;
+            {   
                 TFT.rect(15,55,220,85,Black);   
-                TFT.rect(15,105,220,135,GreenYellow);
+                TFT.rect(15,105,220,135,Green);
                 TFT.rect(15,155,220,185,Black);
-                pd=1;
-                if (pu==1)  {wait(1);   menu=0;}
-                if (pd==1)  {wait(1);   menu=2;}
-                if (ps==1)  {wait(1);   stage=2;}
+                pu = ain1.read(); 
+                pd = ain2.read(); 
+                ps = ain3.read(); 
+                if (pu==1)  {wait(0.5); menu=0;}
+                if (pd==1)  {wait(0.5); menu=2;}
+                if (ps==1)  {wait(0.5); TFT.cls();  stage=2;}
             }  
 
             if (menu==2)    //log
-            {   pu=0; pd=0; pl=0; pr=0; ps=0;
+            {   
                 TFT.rect(15,105,220,135,Black);   
-                TFT.rect(15,155,220,185,GreenYellow);
+                TFT.rect(15,155,220,185,Green);
                 TFT.rect(15,255,220,285,Black);
-                ps=1;
-                if (pu==1)  {wait(1);   menu=1;}
-                if (pd==1)  {wait(1);   menu=3;}
-                if (ps==1)  {wait(1);   stage=3;}
+                pu = ain1.read(); 
+                pd = ain2.read(); 
+                ps = ain3.read(); 
+                if (pu==1)  {wait(0.5); menu=1;}
+                if (pd==1)  {wait(0.5); menu=3;}
+                if (ps==1)  {wait(0.5); TFT.cls();  stage=3;}
             }
         
             if (menu==3)    //return
-            {   pu=0; pd=0; pl=0; pr=0; ps=0;
+            {   
                 TFT.rect(15,155,220,185,Black);   
-                TFT.rect(15,255,220,285,GreenYellow);
-                if (pu==1)  {wait(1);   menu=0;}
-                if (ps==1)  {wait(1);   stage=3;}
-            }
+                TFT.rect(15,255,220,285,Green);
+                pu = ain1.read(); 
+                pd = ain2.read(); 
+                ps = ain3.read(); 
+                if (pu==1)  {wait(0.5); menu=2;}
+                if (ps==1)  {wait(0.5); TFT.cls();  stage=3;}       //  main return...
+            }            
         }
         
         if (stage==1)   //Configuration
-        {   TFT.cls();
-            int i, j;
+        {   
+            int i=0;
+            int j=0;
+            int ia, ib, ja, jb;
+            int config=0;
             TFT.set_font((unsigned char*) Arial24x23);
             TFT.locate(20,60);
             printf("SET PERIOD");
             TFT.rect(15,55, 220,85,Red);
+            TFT.locate(68,150);
+            TFT.printf("Hr    Min");
+
             TFT.set_font((unsigned char*) Arial12x12);
             TFT.locate(40,270);
             printf("Set");
-            TFT.set_font((unsigned char*) Arial12x12);
             TFT.locate(165,270);
             printf("Return");
-                    
-            pu=0; pd=0; pl=1; pr=0; ps=0;
-            i=3;    j=38;
-            while (ps==0)
-            {   TFT.set_font((unsigned char*) Arial12x12);
-                TFT.locate(20,130);
-                TFT.printf("  %i          %i", i-1, j-1);
+            TFT.rect(24,145, 64,175,Olive);  //Cyan
+            TFT.rect(119,145,159,175,Olive);
+            TFT.rect(15,265,85,285,Olive);  //Green
+            TFT.rect(150,265,220,285,Olive); 
+                
+            while (stage==1)
+            {   ia=i-1;     if (i==0) ia=23;
+                ib=i+1;     if (i==23) ib=0;
+                ja=j-1;     if (j==0) ja=59;
+                jb=j+1;     if (j==59) jb=00;
+                
                 TFT.set_font((unsigned char*) Arial24x23);
-                TFT.locate(20,150);
-                TFT.printf(" %i Hr %i Min", i, j);
+                TFT.locate(26,150);
+                if (i<10)  TFT.printf("0%i", i);
+                else if (i>=10)  TFT.printf("%i", i);
+                TFT.locate(120,150);
+                if (j<10)  TFT.printf("0%i", j);
+                else if (j>=10)  TFT.printf("%i", j);
+                
                 TFT.set_font((unsigned char*) Arial12x12);
-                TFT.locate(20,180);
-                TFT.printf("  %i          %i", i+1, j+1);  
-                pu=0; pd=0; pl=1; pr=0; ps=0;
-                if (pl==1)
-                {   TFT.rect(20,145, 58,175,Yellow);
-                    TFT.rect(120,145,158,175,Blue);
-                    pu=1;
-                    if (i>05)   i=0; 
-                    if (pu==1)  {wait(1);   i=i+1;  }
-                    if (pd==1)  {wait(1);   i=i-1;  }
+                TFT.locate(40,130);
+                if (ia<10)  TFT.printf("0%i", ia);
+                else if (ia>=10)  TFT.printf("%i", ia);
+                TFT.locate(40,180);
+                if (ib<10)  TFT.printf("0%i", ib);
+                else if (ib>=10)  TFT.printf("%i", ib);
+                TFT.locate(135,130);
+                if (ja<10)  TFT.printf("0%i", ja);
+                else if (ja>=10)  TFT.printf("%i", ja);
+                TFT.locate(135,180);
+                if (jb<10)  TFT.printf("0%i", jb);
+                else if (jb>=10)  TFT.printf("%i", jb);
+                                
+                if  (config==0)
+                {   TFT.rect(24,145, 64,175,Green);  //Cyan
+                    TFT.rect(119,145,159,175,Olive);       
+                    pu = ain1.read(); 
+                    pd = ain2.read(); 
+                    ps = ain3.read(); 
+                    if (pu==1)  {wait(0.5);   i=ib;  }
+                    if (pd==1)  {wait(0.5);   i=ia;  }
+                    if (ps==1)  {wait(0.5);   config=1;}
                 }
-                pu=0; pd=0; pl=0; pr=1; ps=0;   
-                if (pr==1)
-                {   TFT.rect(20,145, 58,175,Blue);
-                    TFT.rect(120,145,158,175,Yellow);
-                    pu=1;
-                    if (j>60)    j=0;
-                    if (pu==1)  {wait(1);   j=j+1;  }
-                    if (pd==1)  {wait(1);   j=j-1;  }
+                if  (config==1)
+                {   TFT.rect(24,145, 64,175,Olive);  //Cyan
+                    TFT.rect(119,145,159,175,Green);
+                    pu = ain1.read(); 
+                    pd = ain2.read(); 
+                    ps = ain3.read(); 
+                    if (pu==1)  {wait(0.5);   j=jb;  }
+                    if (pd==1)  {wait(0.5);   j=ja;  }
+                    if (ps==1)  {wait(0.5);   config=2;}
                 }
-             //   ps=1;
-            }
-            
-            pu=0; pd=0; pl=1; pr=0; ps=0;
-            while (ps==0)
-            {   if (pl==1)
-                {   TFT.rect(15,265,85,285,GreenYellow);
-                    TFT.rect(150,265,220,285,Black); 
-                    wait(1);
+                if  (config==2)
+                {   TFT.rect(24,145, 64,175,Olive);  //Cyan
+                    TFT.rect(119,145,159,175,Olive);
+                    TFT.rect(15,265,85,285,Green);  //Green
+                    TFT.rect(150,265,220,285,Olive); 
+                    pu = ain1.read(); 
+                    pd = ain2.read(); 
+                    ps = ain3.read(); 
+                    if (pu==1)  {wait(0.5);   config=2;  }
+                    if (pd==1)  {wait(0.5);   config=3;  }
+                    if (ps==1)  {wait(0.5); TFT.cls();  stage=2;}
                 }
-                pr=1;
-                if (pr==1)
-                {   TFT.rect(15,265,85,285,Black);
-                    TFT.rect(150,265,220,285,GreenYellow); 
-                    wait(1);
+                if  (config==3)
+                {   TFT.rect(24,145, 64,175,Olive);  //Cyan
+                    TFT.rect(119,145,159,175,Olive);
+                    TFT.rect(15,265,85,285,Olive);  //Green
+                    TFT.rect(150,265,220,285,Green); 
+                    pu = ain1.read(); 
+                    pd = ain2.read(); 
+                    ps = ain3.read(); 
+                    if (pu==1)  {wait(0.5);   config=2;  }
+                    if (pd==1)  {wait(0.5);   config=3;  }
+                    if (ps==1)  {wait(0.5); TFT.cls();  stage=3;}
                 }
-                ps=1;
-                if (ps==1)  {wait(1);   stage=0;}
             }
         }
-            
+        
         if (stage==2)   //waveform
-        {   TFT.cls();   
-            pu=0; pd=0; pl=0; pr=0; ps=0;
-            int abc, x2, y2;
+        {   int abc, x2, y2;
             int x1 = 0;
             int y1 = 100;
             float32_t sum=0; 
-            float32_t k=0; 
-    
+            float32_t sum_mse=0; 
+            float32_t sum_st=0; 
             for(abc=0; abc<num; abc++) 
             {   a1 = a[abc]; 
                 b1 = b[abc]; 
+                sum = sum+a[abc];
                 arm_sub_f32(&a1, &b1, &subOutput, 1);
                 arm_mult_f32(&subOutput, &subOutput, &SquareOutput, 1); 
-                sum = sum+SquareOutput;
-            
+                sum_mse = sum_mse+SquareOutput;
                 x2 = abc*2; 
                 y2 = 80+a1*10;
                 TFT.line(x1,y1,x2,y2,Green);
                 x1 = x2;
-                y1 = y2;        
+                y1 = y2;
             }
-            k = sum / num;
+            mean = sum/num;
+            mse = sum_mse / num;
+            
+            for(abc=0; abc<num; abc++) 
+            {   a1 = a[abc]; 
+                arm_sub_f32(&a1, &mean, &subOutput, 1);
+                arm_mult_f32(&subOutput, &subOutput, &SquareOutput, 1); 
+                sum_st = sum_st+SquareOutput;
+            }
+            st = sqrt(sum_st/num);
             
             TFT.set_font((unsigned char*) Arial12x12);
-            TFT.locate(10,180);
-            TFT.printf("sum:  %f", sum);
+            
+            TFT.locate(10,130);
+            TFT.printf("Samples number: ");
+            TFT.locate(30,140);
+            TFT.printf("%i", num);  
+            
+            TFT.locate(10,160);
+            TFT.printf("Sample Mean Value: ");
+            TFT.locate(30,170);
+            TFT.printf("%f", mean);  
+            
             TFT.locate(10,190);
-            TFT.printf("num:  %i", num);
-            TFT.locate(10,210);
+            TFT.printf("Standard Deviation: ");
+            TFT.locate(30,200);
+            TFT.printf("%f", st);  
+            
+            TFT.locate(10,220);
             TFT.printf("Mean Square Error: ");
-            TFT.locate(10,220);
-            TFT.printf("   %f", k);  
-            TFT.set_font((unsigned char*) Arial12x12);
+            TFT.locate(30,230);
+            TFT.printf("%f", mse);  
+            
             TFT.locate(165,270);
             printf("Return");
-            TFT.rect(150,265,220,285,GreenYellow); 
-            ps=1;
-            if (ps==1)  {wait(1);   stage=0;}
+            TFT.rect(150,265,220,285,Green); 
+            ps = ain3.read(); 
+            if (ps==1)  {wait(0.5); TFT.cls();  stage=0;}
         }
         
         if (stage==3)   //log
-        {   TFT.cls();
-            pu=0; pd=0; pl=0; pr=0; ps=0;
-            TFT.set_font((unsigned char*) Arial24x23);
-            TFT.locate(20,60);
-            printf("Team Riedel");
+        {   
             TFT.set_font((unsigned char*) Arial24x23);
-            TFT.locate(30,110);
-            TFT.printf("We are");
-            TFT.set_font((unsigned char*) Arial24x23);
-            TFT.locate(40,160);
-            TFT.printf("awesome!");
+            TFT.locate(20,20);
+            printf("     Log");
+            int row=50;
+            for(int abc=0; abc<20; abc++) 
+            {   TFT.set_font((unsigned char*) Arial12x12);
+                TFT.locate(10,row+10*abc);
+                printf("[%i]", abc+1);
+                TFT.locate(60,row+10*abc);
+                printf("%f", mse+abc);
+            }
             TFT.set_font((unsigned char*) Arial12x12);
             TFT.locate(165,270);
             printf("Return"); 
-            TFT.rect(150,265,220,285,GreenYellow); 
-            ps=1;
-            if (ps==1)  {wait(1);   stage=0;}
+            TFT.rect(150,265,220,285,Green); 
+            ps = ain3.read(); 
+            if (ps==1)  {wait(0.5); TFT.cls();  stage=0;}
         }
     }
 }
\ No newline at end of file
--- a/mbed-dsp.lib	Sat Dec 12 21:13:39 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/mbed_official/code/mbed-dsp/#9cee975aadce