pre commentaire

Dependencies:   EthernetInterface WebSocketClient mbed-rtos mbed

Fork of Code_APP3_C by Éric Bisson

Files at this revision

API Documentation at this revision

Comitter:
LouBe4
Date:
Mon Jan 16 19:19:27 2017 +0000
Parent:
3:5dcf9b78f3ad
Child:
5:1a60144f7163
Commit message:
Affichage SPI marche;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Jan 16 19:09:24 2017 +0000
+++ b/main.cpp	Mon Jan 16 19:19:27 2017 +0000
@@ -13,9 +13,9 @@
 void calculer_angle(char bufferAngle[], int accZ)
 {
     float angle = abs(cos(static_cast<float>(accZ*90/64)*PI/180)*90);
-    pc.printf("%c\n", angle);
+    pc.printf("%f\n", angle);
     int angleInt = (int)(angle*100);
-    snprintf(bufferAngle, sizeof bufferAngle, "%d", angleInt);
+    snprintf(bufferAngle, 5, "%d", angleInt);
     
     if(angle < 10)
     {
@@ -24,6 +24,12 @@
         bufferAngle[1] = bufferAngle[0];
         bufferAngle[0] = '0';
     }    
+    pc.printf("%c", bufferAngle[0]);
+    pc.printf("%c", bufferAngle[1]);
+    pc.printf("%c", bufferAngle[2]);
+    pc.printf("%c", bufferAngle[3]);
+    pc.printf("\n");
+    
 }
 
 int main() {
@@ -48,13 +54,11 @@
         wait_us(25);
         spi.write(0x77);
         spi.write(0b00000010);
-        spi.write(0x7A);
-        spi.write(0xFF);
         wait_us(100);
         spi.write(resultat[0]);
         spi.write(resultat[1]);
+        spi.write(resultat[2]);
         spi.write(resultat[3]);
-        spi.write(resultat[4]);
         wait_us(25);
         cs = 1;
         wait(0.25);