PARTYYYY

Dependencies:   mbed MMA8452

Files at this revision

API Documentation at this revision

Comitter:
ThierryLeonard
Date:
Tue Sep 05 10:27:28 2017 +0000
Parent:
8:5124be43c963
Child:
10:2836530d9a5e
Commit message:
Merged, working UART with accelerometer

Changed in this revision

Afficheur.cpp Show annotated file Show diff for this revision Revisions of this file
Afficheur.cpp.orig Show diff for this revision Revisions of this file
Afficheur.h Show annotated file Show diff for this revision Revisions of this file
CommUART.h Show annotated file Show diff for this revision Revisions of this file
MainEvr.cpp Show annotated file Show diff for this revision Revisions of this file
MainEvr.cpp.orig Show diff for this revision Revisions of this file
maint.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Afficheur.cpp	Tue Sep 05 10:00:13 2017 +0000
+++ b/Afficheur.cpp	Tue Sep 05 10:27:28 2017 +0000
@@ -14,18 +14,14 @@
         chipSelect = 1;
     }
 #endif
-    void Afficheur::write(char* characters,int length ) 
+    void Afficheur::write(char* characters,int length, int commaFlags ) 
     {
         
         Serial pc(USBTX, USBRX);
-        pc.printf("1");
         static char buf[20];
-        pc.printf("2");
         resetDisplay();
-        pc.printf("3");
         afficheur.write(characters,length,buf,20);
-        pc.printf("4");
-        showDot(expo);    
+        showDot(commaFlags);    
     }
     void Afficheur::write(char ch)
     {
--- a/Afficheur.cpp.orig	Tue Sep 05 10:00:13 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-
-
-#include "Afficheur.h"
-
-    Afficheur::Afficheur():afficheur(p5,p6,p7),chipSelect(p8)
-    {
-        afficheur.format(8,0);
-        afficheur.frequency(50000);
-        chipSelect = 0;
-    }
-    
-    void Afficheur::write(char* characters,int length,int expo ) 
-    {
-        
-Serial pc(USBTX, USBRX);
-        pc.printf("1");
-        static char buf[20];
-        pc.printf("2");
-        resetDisplay();
-        pc.printf("3");
-        afficheur.write(characters,length,buf,20);
-        pc.printf("4");
-        showDot(expo);    
-    }
-    void Afficheur::write(char ch)
-    {
-        static char buf[1];
-        afficheur.write(&ch,1,buf,1);
-    }
-    void Afficheur::resetDisplay()
-    {
-        char buf[1];
-        afficheur.write("v",1,buf,1);
-    }
-    void Afficheur::showDot(int expo)
-    {
-        char command[2] = {'w',expo};
-        char buf[2];
-        afficheur.write(command,2,buf, 2);
-    }
-    void Afficheur::hideDot()
-    {
-        char command[2] = {'w',0};
-        char buf[2];
-        afficheur.write(command,2,buf, 2);
-    }
\ No newline at end of file
--- a/Afficheur.h	Tue Sep 05 10:00:13 2017 +0000
+++ b/Afficheur.h	Tue Sep 05 10:27:28 2017 +0000
@@ -4,18 +4,27 @@
 
 #include "mbed.h"
 
+ //#define USESPI
+
+#ifndef USESPI
 #include "CommUART.h"
+#endif
+
 
 class Afficheur
 {
+#ifdef USESPI
+    typedef SPI CommInterface;
+#else
     typedef CommUART3 CommInterface;
+#endif
 public:
     Afficheur();
     
-    void write(char* characters,int length ,int expo);
+    void write(char* characters,int length ,int commaFlags);
     void write(char ch);
     void resetDisplay();
-    void showDot(int expo);
+    void showDot(int commaFlags);
     void hideDot();
     
     private:
--- a/CommUART.h	Tue Sep 05 10:00:13 2017 +0000
+++ b/CommUART.h	Tue Sep 05 10:27:28 2017 +0000
@@ -17,6 +17,7 @@
         // DLab enable divide latch
         LPC_UART3->LCR |= (1 << 7);
         
+        //Default Baud rate of 9600 in serial segment
         // MSB of baud rate divisor
         LPC_UART3->DLM = 0x2;
         // MLB of baud rate divisor
--- a/MainEvr.cpp	Tue Sep 05 10:00:13 2017 +0000
+++ b/MainEvr.cpp	Tue Sep 05 10:27:28 2017 +0000
@@ -1,45 +1,45 @@
-//#include "Accelerometre.h"
-//#include "Afficheur.h"
-//
-//Serial pc(USBTX, USBRX);
-//int main() {
-//    
-//
-//    
-//    Afficheur afficheur;
-//    Accelerometre acc;
-//    
-//    double angle = 0;
-//    
-//    while(true){
-//    
-//        acc.readxyzAngle(&angle);
-//        pc.printf("angle is : %lf\r\n",angle);
-//        
-//        
-//        
-//        char c1[10];
-//        char c2[4];
-//    
-//        sprintf(c1 , "%4f" , angle);
-//        int virgule;
-//        int j =0;
-//        for(int i =0;i<4;i++){
-//            if(c1[j] == '.'){
-//                virgule =  1 <<j-1;
-//                i--;
-//                j++;
-//                continue;
-//            }
-//            c2[i] =  c1[j];
-//            j++;
-//            
-//        }
-//        
-//        pc.printf("virg= %d",virgule);
-//        afficheur.write(c2,4, virgule);
-//        
-//        pc.printf("test");
-//        wait(0.45);
-//    }
-//}
+#include "Accelerometre.h"
+#include "Afficheur.h"
+
+Serial pc(USBTX, USBRX);
+int main() {
+    
+
+    
+    Afficheur afficheur;
+    Accelerometre acc;
+    
+    double angle = 0;
+    
+    while(true){
+    
+        acc.readxyzAngle(&angle);
+        pc.printf("angle is : %lf\r\n",angle);
+        
+        
+        
+        char c1[10];
+        char c2[4];
+    
+        sprintf(c1 , "%4f" , angle);
+        int virgule;
+        int j =0;
+        for(int i =0;i<4;i++){
+            if(c1[j] == '.'){
+                virgule =  1 <<j-1;
+                i--;
+                j++;
+                continue;
+            }
+            c2[i] =  c1[j];
+            j++;
+            
+        }
+        
+        pc.printf("virg= %d",virgule);
+        afficheur.write(c2,4, virgule);
+        
+        pc.printf("test");
+        wait(0.45);
+    }
+}
--- a/MainEvr.cpp.orig	Tue Sep 05 10:00:13 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#include "Accelerometre.h"
-#include "Afficheur.h"
-
-Serial pc(USBTX, USBRX);
-int main() {
-    
-
-    
-    Afficheur afficheur;
-    Accelerometre acc;
-    
-    double angle = 0;
-    
-    while(true){
-    
-        acc.readxyzAngle(&angle);
-        pc.printf("angle is : %lf\r\n",angle);
-        
-        
-        
-        char c1[10];
-        char c2[4];
-    
-        sprintf(c1 , "%4f" , angle);
-        int virgule;
-        int j =0;
-        for(int i =0;i<4;i++){
-            if(c1[j] == '.'){
-                virgule =  1 <<j-1;
-                i--;
-                j++;
-                continue;
-            }
-            c2[i] =  c1[j];
-            j++;
-            
-        }
-        
-        pc.printf("virg= %d",virgule);
-        afficheur.write(c2,4, virgule);
-        
-        pc.printf("test");
-        wait(0.45);
-    }
-}
\ No newline at end of file
--- a/maint.cpp	Tue Sep 05 10:00:13 2017 +0000
+++ b/maint.cpp	Tue Sep 05 10:27:28 2017 +0000
@@ -1,19 +1,19 @@
-#include "mbed.h"
-#include "Afficheur.h"
-
-
-Serial pc(USBTX, USBRX); // tx, rx
-
-Afficheur afficheur;
-
-int main() {
-     while(1)
-     {
-        if(pc.readable())
-        {
-            afficheur.write(pc.getc());
-        }
-        
-    }
-    
-}
+//#include "mbed.h"
+//#include "Afficheur.h"
+//
+//
+//Serial pc(USBTX, USBRX); // tx, rx
+//
+//Afficheur afficheur;
+//
+//int main() {
+//     while(1)
+//     {
+//        if(pc.readable())
+//        {
+//            afficheur.write(pc.getc());
+//        }
+//        
+//    }
+//    
+//}