Programme de la première cellule du RC, celle uniquement connectée en BT avec l'autre ObCP. Le code reçoit des infos et renvoi le temps relevé.

Dependencies:   mbed SimpleBLE X_NUCLEO_IDB0XA1 LIS3DH_spi

Revision:
7:f5e10b18984d
Parent:
6:1670244c4eb4
Child:
9:3d83d0b410b8
--- a/main.cpp	Wed Nov 27 15:27:56 2019 +0000
+++ b/main.cpp	Tue Dec 17 14:23:20 2019 +0000
@@ -3,7 +3,6 @@
 #include "mbed.h"
 #include "SimpleBLE.h"
 #include "LIS3DH.h"
-#include "USBSerial.h"
 
 //Accelerometer
 
@@ -14,7 +13,7 @@
 
 //Init simpleBLE
 
-SimpleBLE ble("ObCP_ENSMM_CROC");
+SimpleBLE ble("ObCP_CROC_ENSMM");
 
 
 // GPIO set
@@ -30,10 +29,6 @@
 PwmOut Red(PC_6);                //PWM Green LED
 PwmOut Blue(PC_9);               //PWM Blue LED
 
-//USART
-
-USBSerial pc(0x1f00, 0x2012, 0x0001, false);
-
 //Init accelerometer
 
 LIS3DH      acc(MOSI, MISO, SCLK, CS, LIS3DH_DR_NR_LP_50HZ, LIS3DH_FS_2G);
@@ -44,26 +39,6 @@
 SimpleChar<float> accY = ble.readOnly_float(0xA000, 0xA003);
 SimpleChar<float> accZ = ble.readOnly_float(0xA000, 0xA004);
 
-// Clear the screen
-void clrscr ()
-{
-    char clrscr[] = {0x1B, '[', '2', 'J', 0};
-    pc.printf(clrscr);
-}
-//Home the cursor
-void homescr()
-{
-    char homescr[] = {0x1B, '[', 'H', 0};
-    pc.printf(homescr);
-}
-//goto specified line an column
-void gotoscr(int line, int column)
-{
-    char scr[] = {0x1B, '[', 0x00,';',0x00, 'H', 0};
-    scr[2] = line;
-    scr[4] = column;
-    pc.printf(scr);
-}
 
 // When characteristic LED RGB changing
 
@@ -76,15 +51,6 @@
     Red   = static_cast<float>(channels[0]) / 255.0f;
     Green = static_cast<float>(channels[1]) / 255.0f;
     Blue  = static_cast<float>(channels[2]) / 255.0f;
-    gotoscr('5','0');
-    pc.printf("PWM Red = ");
-    pc.printf("%5.2f",Red);
-    gotoscr('6','0');
-    pc.printf("PWM Green = ");
-    pc.printf("%5.2f",Green);
-    gotoscr('7','0');
-    pc.printf("PWM Blue = ");
-    pc.printf("%5.2f",Blue);
 }
 
 // When characteristic PWM output changing
@@ -94,10 +60,6 @@
 
     // cast to float, as PwmOut expects a value between 0.0f and 1.0f
     PWMoutput   = static_cast<float>(pwmvalue) / 255.0f;
-    
-    gotoscr('4','0');
-    pc.printf("PWM = ");
-    pc.printf("%5.2f",PWMoutput);
 }
 
 // When characteristic input changing
@@ -108,16 +70,6 @@
     accY = float(short((acc.read_reg(LIS3DH_OUT_Y_H) << 8) | acc.read_reg(LIS3DH_OUT_Y_L))) * 0.001F / 15;
     accZ = float(short((acc.read_reg(LIS3DH_OUT_Z_H) << 8) | acc.read_reg(LIS3DH_OUT_Z_L))) * 0.001F / 15;
 
-    
-    gotoscr('0','0');
-    pc.printf("X acceleration = ");
-    pc.printf("%5.2f",accX);
-    gotoscr('2','0');
-    pc.printf("Y acceleration = ");
-    pc.printf("%5.2f",accY);
-    gotoscr('3','0');
-    pc.printf("Z acceleration = ");
-    pc.printf("%5.2f",accZ);
 }
 
 // Characteritic PWM LED RGB
@@ -133,9 +85,6 @@
 {
 
     ble.start();
-    clrscr();
-    homescr();
-    pc.printf("BLE started");
     Ticker t;
     t.attach(&Accupdate, 5.0f);