AresENSEA-CDF2020
/
AresCDFMainCode_capteur_US
Capteur_US
motors.cpp@5:34ed652f8c31, 2020-07-21 (annotated)
- Committer:
- Nanaud
- Date:
- Tue Jul 21 19:33:38 2020 +0000
- Revision:
- 5:34ed652f8c31
- Parent:
- 4:ad9b7355332e
- Child:
- 6:ea6b30c4bb01
Commande Bluetooth test moteur
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nanaud | 1:2fe8c402ee79 | 1 | // Nom du fichier : motors.cpp |
Nanaud | 0:dc036b67c87c | 2 | #include "pins.h" |
Nanaud | 0:dc036b67c87c | 3 | |
Nanaud | 5:34ed652f8c31 | 4 | void drv_init() |
Nanaud | 5:34ed652f8c31 | 5 | { |
Nanaud | 0:dc036b67c87c | 6 | mot_dis(); |
Nanaud | 5:34ed652f8c31 | 7 | motGauche_fwd(); |
Nanaud | 5:34ed652f8c31 | 8 | motDroite_fwd(); |
Nanaud | 5:34ed652f8c31 | 9 | drvGauche.moveLinSpeed(0.1); |
Nanaud | 5:34ed652f8c31 | 10 | drvDroite.moveLinSpeed(0.1); |
Nanaud | 4:ad9b7355332e | 11 | mode = 0b111; // M0, M1 et M2 sont à 1 |
Nanaud | 0:dc036b67c87c | 12 | } |
Nanaud | 0:dc036b67c87c | 13 | |
Nanaud | 0:dc036b67c87c | 14 | // ENABLE/DISABLE // Les deux modules ont le même enable |
Nanaud | 5:34ed652f8c31 | 15 | void mot_en() |
Nanaud | 5:34ed652f8c31 | 16 | { |
Nanaud | 0:dc036b67c87c | 17 | drvGauche.setEnable(START); |
Nanaud | 0:dc036b67c87c | 18 | //drvDroite.setEnable(START); |
Nanaud | 0:dc036b67c87c | 19 | } |
Nanaud | 0:dc036b67c87c | 20 | |
Nanaud | 5:34ed652f8c31 | 21 | void mot_dis() |
Nanaud | 5:34ed652f8c31 | 22 | { |
Nanaud | 0:dc036b67c87c | 23 | drvGauche.setEnable(STOP); |
Nanaud | 0:dc036b67c87c | 24 | //drvDroite.setEnable(STOP); |
Nanaud | 0:dc036b67c87c | 25 | } |
Nanaud | 0:dc036b67c87c | 26 | |
Nanaud | 0:dc036b67c87c | 27 | // FORWARD |
Nanaud | 5:34ed652f8c31 | 28 | void motGauche_fwd() |
Nanaud | 5:34ed652f8c31 | 29 | { |
Nanaud | 0:dc036b67c87c | 30 | drvGauche.setDir(FORWARD); |
Nanaud | 0:dc036b67c87c | 31 | } |
Nanaud | 0:dc036b67c87c | 32 | |
Nanaud | 5:34ed652f8c31 | 33 | void motDroite_fwd() |
Nanaud | 5:34ed652f8c31 | 34 | { |
Nanaud | 4:ad9b7355332e | 35 | drvDroite.setDir(BACKWARD); |
Nanaud | 0:dc036b67c87c | 36 | } |
Nanaud | 0:dc036b67c87c | 37 | |
Nanaud | 0:dc036b67c87c | 38 | // BACKWARD |
Nanaud | 5:34ed652f8c31 | 39 | void motGauche_bck() |
Nanaud | 5:34ed652f8c31 | 40 | { |
Nanaud | 0:dc036b67c87c | 41 | drvGauche.setDir(BACKWARD); |
Nanaud | 0:dc036b67c87c | 42 | } |
Nanaud | 0:dc036b67c87c | 43 | |
Nanaud | 5:34ed652f8c31 | 44 | void motDroite_bck() |
Nanaud | 5:34ed652f8c31 | 45 | { |
Nanaud | 4:ad9b7355332e | 46 | drvDroite.setDir(FORWARD); |
Nanaud | 3:3ba377aafdfd | 47 | } |
Nanaud | 3:3ba377aafdfd | 48 | |
Nanaud | 3:3ba377aafdfd | 49 | // TESTS |
Nanaud | 3:3ba377aafdfd | 50 | |
Nanaud | 5:34ed652f8c31 | 51 | void test_drv() |
Nanaud | 5:34ed652f8c31 | 52 | { |
Nanaud | 3:3ba377aafdfd | 53 | mot_en(); |
Nanaud | 3:3ba377aafdfd | 54 | motGauche_fwd(); |
Nanaud | 4:ad9b7355332e | 55 | motDroite_fwd(); |
Nanaud | 5:34ed652f8c31 | 56 | drvGauche.moveLinSpeed(0.250); // 0.035 |
Nanaud | 5:34ed652f8c31 | 57 | drvDroite.moveLinSpeed(0.250); // 0.035 |
Nanaud | 3:3ba377aafdfd | 58 | wait(2); |
Nanaud | 3:3ba377aafdfd | 59 | motGauche_bck(); |
Nanaud | 4:ad9b7355332e | 60 | motDroite_bck(); |
Nanaud | 3:3ba377aafdfd | 61 | wait(2); |
Nanaud | 3:3ba377aafdfd | 62 | mot_dis(); |
Nanaud | 3:3ba377aafdfd | 63 | } |
Nanaud | 3:3ba377aafdfd | 64 | |
Nanaud | 5:34ed652f8c31 | 65 | void testAngle(int cmdAngle){} |