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:
11:72c976e0d889
Parent:
10:a15e07c7ad61
Child:
12:797136ee9f42
--- a/main.cpp	Wed Jan 22 09:33:01 2020 +0000
+++ b/main.cpp	Sun Jan 26 10:37:54 2020 +0000
@@ -5,21 +5,13 @@
 #include "LIS3DH.h"
 #include "stdlib.h"
 
-//Accelerometer
-
-#define MOSI PC_12
-#define MISO PC_11
-#define CS PC_5
-#define SCLK PC_10
 
 //Bluetooth hc05-6
 
 #define TX D0
 #define RX D1
 
-//Init simpleBLE
 
-//SimpleBLE ble("ObCP_Roller_Catcher2");
 
 
 // GPIO set
@@ -43,15 +35,6 @@
 PwmOut Red(PC_6);                //PWM Green LED
 PwmOut Blue(PC_9);               //PWM Blue LED
 
-//Init accelerometer
-
-LIS3DH      acc(MOSI, MISO, SCLK, CS, LIS3DH_DR_NR_LP_50HZ, LIS3DH_FS_2G);
-
-// Characteristics Accelerometer input
-
-//SimpleChar<float> accX = ble.readOnly_float(0xA000, 0xA002);
-//SimpleChar<float> compteur = ble.readOnly_float(0xA000, 0xA003);
-//SimpleChar<float> Temps = ble.readOnly_float(0xA000, 0xA004);
 
 Serial BT(USBTX,USBRX);
 //Serial pc(USBTX, USBRX);
@@ -68,66 +51,17 @@
 
 void envoi(int message){
     BT.printf("%i\n", message);
-    //  pc.printf("Message envoye \r\n");
 }
 
 
 void pressed(){
-    //  pc.printf("Test 2 \n ");
     led1 = !led1;
     temps1 = timer.read_ms();
-    
-    //  pc.printf("%i \r\n",temps1);
     message = temps1;
     envoi(message);
-    //timer.stop();
-    //timer.start();
     }
 
 
-
-
-// When characteristic LED RGB changing
-
-void LEDupdate(uint32_t newColor)
-{/*
-    // read individual bytes
-    uint8_t* channels = (uint8_t*)&newColor;
-
-    // cast to float, as PwmOut expects a value between 0.0f and 1.0f
-    Red   = static_cast<float>(channels[0]) / 255.0f;
-    Green = static_cast<float>(channels[1]) / 255.0f;
-    Blue  = static_cast<float>(channels[2]) / 255.0f; */
-}
-
-// When characteristic PWM output changing
-
-void PWMupdate(uint8_t pwmvalue)
-{
-
-    // cast to float, as PwmOut expects a value between 0.0f and 1.0f
-//    PWMoutput   = static_cast<float>(pwmvalue) / 255.0f;
-}
-
-// When characteristic input changing
-void Accupdate()
-{
-
-    //accX = float(short((acc.read_reg(LIS3DH_OUT_X_H) << 8) | acc.read_reg(LIS3DH_OUT_X_L))) * 0.001F / 15;
-    //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;
-    //Temps=15.68;
-
-}
-
-// Characteritic PWM LED RGB
-//SimpleChar<uint32_t> color = ble.writeOnly_u32(0x6200, 0x6201, &LEDupdate);
-
-// Characteristic PWM output
-//SimpleChar<uint8_t> pwmout = ble.writeOnly_u8(0xA000, 0xA001, &PWMupdate);
-
-
-
 void skater_d()
 {
     if(flag==false) {
@@ -182,26 +116,14 @@
 
 
 void RXevent (){
-        //c=BT.getc();
     if(BT.readable()){
         BT.scanf("%s", &Buffer);
         wait(1);
     } 
         
-        //pc.printf(" Message recu :%s \n",Buffer);
-        //timer.start();
-        
-        //test_mode(Buffer);
-        
     if (Buffer[0] == 'R'){
-        //  pc.printf("Reset timer \r\n ");
         timer.reset();
-        //wait(1);
-        //timer.start();
-        //temps1=timer.read_ms();
-        //envoi(temps1);
     }
-    //  pc.printf(" Message recu :%s \n", Buffer); 
     return;    
 }
 
@@ -212,26 +134,16 @@
 int main(int, char**)
 {
     transistor=1;
-    //ble.start();
-    //Ticker t;
-    //t.attach(&Accupdate, 15.0f);
     timer.start();
     BT.attach(&RXevent);
-    //BT.attach(&RXevent);
     user1.fall(&pressed);
-    //boutton1.fall(&pressed);
-    //boutton2.fall(&pressed);
     event.fall(&pressed);
-    //BT.attach(&RXevent);
-
-    
+   
     while (1) {
         
 
-        //begin2 = timer.read_ms();
         Green = 0.001;
         wait(1);
-        //BT.puts("Test");
         Green = 0;
         wait(1);
         //}
@@ -239,4 +151,3 @@
     }
 }
 
-//blablabla
\ No newline at end of file