v7
Robot.cpp@3:3f75a7741b8f, 2017-02-27 (annotated)
- Committer:
- fab16
- Date:
- Mon Feb 27 10:30:15 2017 +0000
- Revision:
- 3:3f75a7741b8f
- Parent:
- 2:c17925c0ce25
- Child:
- 4:c8ae1b606d51
Robot v2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fab16 | 0:3cb651f7347b | 1 | #include "Robot.h" |
fab16 | 3:3f75a7741b8f | 2 | #include "m3pi.h" |
fab16 | 3:3f75a7741b8f | 3 | |
fab16 | 3:3f75a7741b8f | 4 | m3pi m3piR; |
fab16 | 0:3cb651f7347b | 5 | |
fab16 | 1:b3c45f39e86e | 6 | Robot::Robot(){ |
fab16 | 2:c17925c0ce25 | 7 | obstacle = false; |
fab16 | 2:c17925c0ce25 | 8 | Affichage affichage; |
fab16 | 2:c17925c0ce25 | 9 | LED led; |
fab16 | 2:c17925c0ce25 | 10 | Deplacement deplacement; |
fab16 | 3:3f75a7741b8f | 11 | Pattern pattern; |
fab16 | 1:b3c45f39e86e | 12 | } |
fab16 | 1:b3c45f39e86e | 13 | |
fab16 | 1:b3c45f39e86e | 14 | Robot::~Robot(){ |
fab16 | 1:b3c45f39e86e | 15 | // TODO fermer connexion bluetooth |
fab16 | 1:b3c45f39e86e | 16 | } |
fab16 | 1:b3c45f39e86e | 17 | |
fab16 | 2:c17925c0ce25 | 18 | Affichage Robot::getAffichage(){ |
fab16 | 2:c17925c0ce25 | 19 | return affichage; |
fab16 | 2:c17925c0ce25 | 20 | } |
fab16 | 2:c17925c0ce25 | 21 | |
fab16 | 2:c17925c0ce25 | 22 | LED Robot::getLed(){ |
fab16 | 2:c17925c0ce25 | 23 | return led; |
fab16 | 2:c17925c0ce25 | 24 | } |
fab16 | 2:c17925c0ce25 | 25 | |
fab16 | 2:c17925c0ce25 | 26 | Deplacement Robot::getDeplacement(){ |
fab16 | 2:c17925c0ce25 | 27 | return deplacement; |
fab16 | 2:c17925c0ce25 | 28 | } |
fab16 | 3:3f75a7741b8f | 29 | |
fab16 | 3:3f75a7741b8f | 30 | Pattern Robot::getPattern(){ |
fab16 | 3:3f75a7741b8f | 31 | return pattern; |
fab16 | 3:3f75a7741b8f | 32 | } |
fab16 | 3:3f75a7741b8f | 33 | |
fab16 | 3:3f75a7741b8f | 34 | void Robot::action(int idAction){ |
fab16 | 3:3f75a7741b8f | 35 | |
fab16 | 3:3f75a7741b8f | 36 | switch(idAction){ |
fab16 | 3:3f75a7741b8f | 37 | |
fab16 | 3:3f75a7741b8f | 38 | // deplacement simple |
fab16 | 3:3f75a7741b8f | 39 | case 0 : |
fab16 | 3:3f75a7741b8f | 40 | { |
fab16 | 3:3f75a7741b8f | 41 | this->deplacement.avancer(); |
fab16 | 3:3f75a7741b8f | 42 | break; |
fab16 | 3:3f75a7741b8f | 43 | } |
fab16 | 3:3f75a7741b8f | 44 | |
fab16 | 3:3f75a7741b8f | 45 | case 1 : |
fab16 | 3:3f75a7741b8f | 46 | { |
fab16 | 3:3f75a7741b8f | 47 | this->deplacement.droite(); |
fab16 | 3:3f75a7741b8f | 48 | break; |
fab16 | 3:3f75a7741b8f | 49 | } |
fab16 | 3:3f75a7741b8f | 50 | |
fab16 | 3:3f75a7741b8f | 51 | case 2 : |
fab16 | 3:3f75a7741b8f | 52 | { |
fab16 | 3:3f75a7741b8f | 53 | this->deplacement.reculer(); |
fab16 | 3:3f75a7741b8f | 54 | break; |
fab16 | 3:3f75a7741b8f | 55 | } |
fab16 | 3:3f75a7741b8f | 56 | |
fab16 | 3:3f75a7741b8f | 57 | case 3 : |
fab16 | 3:3f75a7741b8f | 58 | { |
fab16 | 3:3f75a7741b8f | 59 | this->deplacement.gauche(); |
fab16 | 3:3f75a7741b8f | 60 | break; |
fab16 | 3:3f75a7741b8f | 61 | } |
fab16 | 3:3f75a7741b8f | 62 | |
fab16 | 3:3f75a7741b8f | 63 | case 4 : |
fab16 | 3:3f75a7741b8f | 64 | { |
fab16 | 3:3f75a7741b8f | 65 | this->deplacement.tourner_gauche(); |
fab16 | 3:3f75a7741b8f | 66 | break; |
fab16 | 3:3f75a7741b8f | 67 | } |
fab16 | 3:3f75a7741b8f | 68 | |
fab16 | 3:3f75a7741b8f | 69 | case 5 : |
fab16 | 3:3f75a7741b8f | 70 | { |
fab16 | 3:3f75a7741b8f | 71 | this->deplacement.tourner_droite(); |
fab16 | 3:3f75a7741b8f | 72 | break; |
fab16 | 3:3f75a7741b8f | 73 | } |
fab16 | 3:3f75a7741b8f | 74 | |
fab16 | 3:3f75a7741b8f | 75 | // pattern |
fab16 | 3:3f75a7741b8f | 76 | |
fab16 | 3:3f75a7741b8f | 77 | case 6 : |
fab16 | 3:3f75a7741b8f | 78 | { |
fab16 | 3:3f75a7741b8f | 79 | this->pattern.carre(); |
fab16 | 3:3f75a7741b8f | 80 | break; |
fab16 | 3:3f75a7741b8f | 81 | } |
fab16 | 3:3f75a7741b8f | 82 | |
fab16 | 3:3f75a7741b8f | 83 | case 7 : |
fab16 | 3:3f75a7741b8f | 84 | { |
fab16 | 3:3f75a7741b8f | 85 | this->pattern.triangle(); |
fab16 | 3:3f75a7741b8f | 86 | break; |
fab16 | 3:3f75a7741b8f | 87 | } |
fab16 | 3:3f75a7741b8f | 88 | |
fab16 | 3:3f75a7741b8f | 89 | // led |
fab16 | 3:3f75a7741b8f | 90 | case 8 : |
fab16 | 3:3f75a7741b8f | 91 | { |
fab16 | 3:3f75a7741b8f | 92 | this->led.K1000(1); |
fab16 | 3:3f75a7741b8f | 93 | break; |
fab16 | 3:3f75a7741b8f | 94 | } |
fab16 | 3:3f75a7741b8f | 95 | |
fab16 | 3:3f75a7741b8f | 96 | case 9 : |
fab16 | 3:3f75a7741b8f | 97 | { |
fab16 | 3:3f75a7741b8f | 98 | this->led.K2000(1); |
fab16 | 3:3f75a7741b8f | 99 | break; |
fab16 | 3:3f75a7741b8f | 100 | } |
fab16 | 3:3f75a7741b8f | 101 | |
fab16 | 3:3f75a7741b8f | 102 | case 10 : |
fab16 | 3:3f75a7741b8f | 103 | { |
fab16 | 3:3f75a7741b8f | 104 | this->led.K3000(1); |
fab16 | 3:3f75a7741b8f | 105 | break; |
fab16 | 3:3f75a7741b8f | 106 | } |
fab16 | 3:3f75a7741b8f | 107 | |
fab16 | 3:3f75a7741b8f | 108 | case 11 : |
fab16 | 3:3f75a7741b8f | 109 | { |
fab16 | 3:3f75a7741b8f | 110 | this->led.K4000(1); |
fab16 | 3:3f75a7741b8f | 111 | break; |
fab16 | 3:3f75a7741b8f | 112 | } |
fab16 | 3:3f75a7741b8f | 113 | |
fab16 | 3:3f75a7741b8f | 114 | case 12 : |
fab16 | 3:3f75a7741b8f | 115 | { |
fab16 | 3:3f75a7741b8f | 116 | this->led.LED_desynchrone(1); |
fab16 | 3:3f75a7741b8f | 117 | break; |
fab16 | 3:3f75a7741b8f | 118 | } |
fab16 | 3:3f75a7741b8f | 119 | |
fab16 | 3:3f75a7741b8f | 120 | case 13 : |
fab16 | 3:3f75a7741b8f | 121 | { |
fab16 | 3:3f75a7741b8f | 122 | this->led.LED_Blinking(DigitalOut (LED1),1); |
fab16 | 3:3f75a7741b8f | 123 | break; |
fab16 | 3:3f75a7741b8f | 124 | } |
fab16 | 3:3f75a7741b8f | 125 | |
fab16 | 3:3f75a7741b8f | 126 | case 14 : |
fab16 | 3:3f75a7741b8f | 127 | { |
fab16 | 3:3f75a7741b8f | 128 | this->led.LED_Blinking(DigitalOut (LED2),1); |
fab16 | 3:3f75a7741b8f | 129 | break; |
fab16 | 3:3f75a7741b8f | 130 | } |
fab16 | 3:3f75a7741b8f | 131 | |
fab16 | 3:3f75a7741b8f | 132 | case 15 : |
fab16 | 3:3f75a7741b8f | 133 | { |
fab16 | 3:3f75a7741b8f | 134 | this->led.LED_Blinking(DigitalOut (LED3),1); |
fab16 | 3:3f75a7741b8f | 135 | break; |
fab16 | 3:3f75a7741b8f | 136 | } |
fab16 | 3:3f75a7741b8f | 137 | |
fab16 | 3:3f75a7741b8f | 138 | case 16 : |
fab16 | 3:3f75a7741b8f | 139 | { |
fab16 | 3:3f75a7741b8f | 140 | this->led.LED_Blinking(DigitalOut (LED4),1); |
fab16 | 3:3f75a7741b8f | 141 | break; |
fab16 | 3:3f75a7741b8f | 142 | } |
fab16 | 3:3f75a7741b8f | 143 | |
fab16 | 3:3f75a7741b8f | 144 | |
fab16 | 3:3f75a7741b8f | 145 | // affichage |
fab16 | 3:3f75a7741b8f | 146 | |
fab16 | 3:3f75a7741b8f | 147 | case 17 : |
fab16 | 3:3f75a7741b8f | 148 | { |
fab16 | 3:3f75a7741b8f | 149 | this->affichage.bonjour(); |
fab16 | 3:3f75a7741b8f | 150 | break; |
fab16 | 3:3f75a7741b8f | 151 | } |
fab16 | 3:3f75a7741b8f | 152 | } |
fab16 | 3:3f75a7741b8f | 153 | |
fab16 | 3:3f75a7741b8f | 154 | } |
fab16 | 3:3f75a7741b8f | 155 | |
fab16 | 3:3f75a7741b8f | 156 | /* SRF05 Robot::getSrf(){ |
fab16 | 3:3f75a7741b8f | 157 | |
fab16 | 3:3f75a7741b8f | 158 | } |
fab16 | 3:3f75a7741b8f | 159 | */ |
fab16 | 3:3f75a7741b8f | 160 | |
fab16 | 2:c17925c0ce25 | 161 |