![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
test changement de nom
Dependencies: mbed SimpleBLE Roller_C LIS3DH_spi USBDevice
Revision 9:111c818e8740, committed 2020-01-06
- Comitter:
- MaxenceGalopin
- Date:
- Mon Jan 06 14:12:46 2020 +0000
- Parent:
- 8:2890498e11b6
- Commit message:
- zer
Changed in this revision
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 |
diff -r 2890498e11b6 -r 111c818e8740 X_NUCLEO_IDB0XA1.lib --- a/X_NUCLEO_IDB0XA1.lib Fri Dec 27 15:30:51 2019 +0000 +++ b/X_NUCLEO_IDB0XA1.lib Mon Jan 06 14:12:46 2020 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/ST/code/X_NUCLEO_IDB0XA1/#fa98703ece8e +https://os.mbed.com/teams/Roller-Catcher/code/Roller_C/#85af48ae0335
diff -r 2890498e11b6 -r 111c818e8740 main.cpp --- a/main.cpp Fri Dec 27 15:30:51 2019 +0000 +++ b/main.cpp Mon Jan 06 14:12:46 2020 +0000 @@ -1,4 +1,3 @@ -//Includes #include "mbed.h" #include "SimpleBLE.h" @@ -38,11 +37,26 @@ LIS3DH acc(MOSI, MISO, SCLK, CS, LIS3DH_DR_NR_LP_50HZ, LIS3DH_FS_2G); +Timer timer; +InterruptIn event(A0); +InterruptIn button1(D3); +//DigitalOut myled(LED1); + // Characteristics Accelerometer input SimpleChar<float> accX = ble.readOnly_float(0xA000, 0xA002); -SimpleChar<float> accY = ble.readOnly_float(0xA000, 0xA003); -SimpleChar<float> accZ = ble.readOnly_float(0xA000, 0xA004); +SimpleChar<float> compteur = ble.readOnly_float(0xA000, 0xA003); +SimpleChar<float> temps = ble.readOnly_float(0xA000, 0xA004); + + +bool flag= false; +float begin, end; + +void Pressed(){ + compteur = compteur +1; +} + + // Clear the screen void clrscr () @@ -104,20 +118,20 @@ 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; - + //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; + accX = 0.048f; gotoscr('0','0'); pc.printf("X acceleration = "); pc.printf("%5.2f",accX); gotoscr('2','0'); pc.printf("Y acceleration = "); - pc.printf("%5.2f",accY); + //pc.printf("%5.2f",accY); gotoscr('3','0'); pc.printf("Z acceleration = "); - pc.printf("%5.2f",accZ); + //pc.printf("%5.2f",accZ); } // Characteritic PWM LED RGB @@ -127,6 +141,39 @@ SimpleChar<uint8_t> pwmout = ble.writeOnly_u8(0xA000, 0xA001, &PWMupdate); +void skater_d() +{ + if(flag==false) { + //printf("Ligne de depart coupee solo \n"); + if( flag == false) { + //printf("Depart skate \n"); + begin = timer.read_ms(); + compteur=100; + //pc.printf(" skater lance %.0f \n", begin); + flag = true; + } else if(flag == true) { + //printf("erreur \n"); + //pc.printf(" Temps du skater : %.0f \n", end-begin); + flag = false; + } + } + else if(flag==true) { + //printf("Ligne d'arrivee coupee \n"); + if( flag == false ) { + //printf("arrivee coupe sans depart\n"); + flag = true; + } else if(flag == true ) { + //printf("Arrivee skate \n"); + end = timer.read_ms(); + temps = end-begin; + compteur=200; + //pc.printf(" Temps du skater : %.0f \n", end-begin); + flag = false; + } + } +} + + //Main program int main(int, char**) @@ -135,9 +182,13 @@ ble.start(); clrscr(); homescr(); - pc.printf("BLE started"); + timer.start(); + //pc.printf("BLE started"); Ticker t; t.attach(&Accupdate, 5.0f); + event.fall(&skater_d); + button1.fall(&Pressed); + user1.fall(&Pressed); while (1) { ble.waitForEvent();