louis VERZELLESI / Mbed 2 deprecated TP3

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
louisverzellesi
Date:
Sun Nov 18 14:16:59 2018 +0000
Commit message:
1

Changed in this revision

Q1.cpp Show annotated file Show diff for this revision Revisions of this file
Q2.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Q1.cpp	Sun Nov 18 14:16:59 2018 +0000
@@ -0,0 +1,30 @@
+#include "mbed.h"
+#include "C12832.h"
+
+I2C ansarnia(p28,p27);                  //CONNEXION BUS I2C
+
+ const int adresse = 0x90;
+ char octet_ecriture[1];
+ char octet_lecture[2];
+ C12832 lcd(p5, p7, p6, p8, p11);
+ int L,M;
+ float temp;
+
+ int main(){
+     //ansarnia.frequency(50000];
+    octet_ecriture[0] =0x00;
+
+    while(true){
+    ansarnia.write(adresse,octet_ecriture,1);
+    ansarnia.read(adresse,octet_lecture,2);
+    M=octet_lecture[0];
+    L=octet_lecture[1];
+        lcd.cls();
+        lcd.locate(0,3);
+        //lcd.printf("la valeur de temperature est :");
+        //lcd.locate(0,15);
+        temp = ((256.0*M+L)/32.0)*0.125;
+        lcd.printf("degrees %f\n\r",temp);
+        wait(0.5);
+     }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Q2.cpp	Sun Nov 18 14:16:59 2018 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "C12832.h"
+
+C12832 lcd(p5, p7, p6, p8, p11);
+const int adresse = 0x98;
+ char octet_config[2];
+  char octet_XOUT[1];
+ char octet_lecture[3];
+ int Ax,Ay,Az;
+ float X,Y,Z;
+ 
+I2C ansarnia(p28,p27);
+
+int main() {
+        lcd.cls();
+        lcd.locate(0,3);
+         octet_config[0] = 0x07;
+         octet_config[1] = 0x01;
+         octet_XOUT[0] = 0x00; 
+         
+        ansarnia.write(adresse,octet_config,2);
+        while(true) {
+            ansarnia.write(adresse,octet_XOUT,1);
+            ansarnia.read(adresse,octet_lecture,3);
+            Ax=octet_lecture[0];
+            Ay=octet_lecture[1];
+            Az=octet_lecture[2];
+            if (Ax>32) {
+                X = (Ax-64)*0.046;
+            }
+            else{
+                X = Ax*0.046;
+            }
+            if (Ay>32) {
+                Y = (Ay - 64)*0.046;
+            }
+            else{
+                Y = Ay * 0.046;
+            }
+            if (Az>32) {
+                Z = (Az - 64)*0.046;
+            }
+            else {
+                Z = Az*0.046;
+            }
+            lcd.cls();
+            lcd.locate(0,3);
+            lcd.printf("Ax,%f\n\r",X);
+            wait(0.5);
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Nov 18 14:16:59 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file