Premier programme pour la cellule de départ : L476RG HC05 + BLE

Dependencies:   mbed SimpleBLE X_NUCLEO_IDB0XA1

Files at this revision

API Documentation at this revision

Comitter:
dorianvoydie
Date:
Tue Nov 10 14:25:00 2020 +0000
Commit message:
Laser Gate Timer Depart

Changed in this revision

SimpleBLE.lib Show annotated file Show diff for this revision Revisions of this file
X_NUCLEO_IDB0XA1.lib Show annotated file Show diff for this revision Revisions of this file
main.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
diff -r 000000000000 -r badac4c5dd91 SimpleBLE.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SimpleBLE.lib	Tue Nov 10 14:25:00 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ENSMM/code/SimpleBLE/#e26d79727dfa
diff -r 000000000000 -r badac4c5dd91 X_NUCLEO_IDB0XA1.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IDB0XA1.lib	Tue Nov 10 14:25:00 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ENSMM/code/X_NUCLEO_IDB0XA1/#8886c0252544
diff -r 000000000000 -r badac4c5dd91 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 10 14:25:00 2020 +0000
@@ -0,0 +1,130 @@
+//Includes
+
+#include "mbed.h"
+#include "SimpleBLE.h"
+
+
+///////////Init STM32 pins///////////
+DigitalOut myLed(PC_8);
+DigitalIn my_button(PC_13);  //User1
+/////////////////////////////////////
+
+
+
+
+///////////Init HC05/////////////////
+Serial HC05(PA_2, PA_3);
+//Bluetooth
+//Maitre (Tanguy) : ADDR = 0019,10,08FCD3
+//Esclave (Dorian) : ADDR = 0019,10,08FCB5
+/////////////////////////////////////
+
+
+
+
+//////////////Init BLE///////////////
+SimpleBLE ble("ObCP_CROC_ENSMM");
+
+/////////////READ////////////////////
+SimpleChar<float> trigger_value = ble.readOnly_float(0xA000, 0xA002);
+SimpleChar<float> chrono_value = ble.readOnly_float(0xA000, 0xA003);
+/////////////////////////////////////
+
+
+
+
+////////////TIMER////////////////////
+Timer timer;
+int begin;
+int end;
+float chrono=0;
+void Timer_triggered()
+{
+    timer.start();
+    begin = timer.read_ms();
+}
+void Timer_Reset()
+{
+    timer.stop();
+    begin=0;
+    end=0;
+    chrono=0;
+}
+/////////////////////////////////////
+
+
+
+
+/////////COMMUNICATION///////////////
+void HC05_receive()
+{
+    char IncomingValue = HC05.getc();
+    if(IncomingValue == 'u') {
+        end = timer.read_ms();
+        timer.stop();
+        chrono = end-begin;
+
+    }
+    HC05.putc(IncomingValue);
+}
+/////////////////////////////////////
+
+
+
+
+/////////////GAMEMODES///////////////
+void solo()
+{
+    trigger_value = float(my_button);
+    chrono_value = float(chrono)* 0.001F;
+
+
+    if (my_button==0) {
+        Timer_triggered();
+        myLed=1;
+    } else {
+        myLed = 0;
+    }
+    //while bluetooth device is receiving data
+    while(HC05.readable()) {
+        HC05_receive();
+    }
+}
+/////////////////////////////////////
+
+
+
+
+/////////GAMEMODES UPDATE////////////
+float gamemode = 0;
+void updateGM(float newValue)
+{
+    gamemode = newValue;
+}
+SimpleChar<float> gamemode_command = ble.writeOnly_float(0xA000, 0xA004, &updateGM);
+/////////////////////////////////////
+
+
+
+
+
+
+
+
+int main(int, char**)
+{
+    HC05.baud(9600);
+    ble.start();
+    while (1) {
+        ble.waitForEvent();
+        solo();
+
+    }
+}
+
+
+
+
+
+
+
diff -r 000000000000 -r badac4c5dd91 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 10 14:25:00 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file