test can console
Dependencies: mbed
Fork of CAN by
main.cpp@2:be902ab7d787, 2018-02-06 (annotated)
- Committer:
- protongamer
- Date:
- Tue Feb 06 11:01:08 2018 +0000
- Revision:
- 2:be902ab7d787
- Parent:
- 1:c022a879e21c
version 6 fevrier
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
protongamer | 1:c022a879e21c | 1 | //Terminal CAN projet bts sn Enzo |
protongamer | 1:c022a879e21c | 2 | |
LabSE | 0:cea062e60f85 | 3 | #include "mbed.h" |
LabSE | 0:cea062e60f85 | 4 | |
protongamer | 1:c022a879e21c | 5 | #define BIG_ENDIAN 0 |
protongamer | 1:c022a879e21c | 6 | #define LITTLE_ENDIAN 1 |
protongamer | 1:c022a879e21c | 7 | |
protongamer | 1:c022a879e21c | 8 | #define MENU_DISPLAY 0 |
protongamer | 1:c022a879e21c | 9 | #define MENU_CHOOSE 1 |
protongamer | 1:c022a879e21c | 10 | #define MENU_SENDING_DISPLAY 2 |
protongamer | 1:c022a879e21c | 11 | #define MENU_SENDING 3 |
protongamer | 1:c022a879e21c | 12 | #define SET_ID 4 |
protongamer | 1:c022a879e21c | 13 | |
LabSE | 0:cea062e60f85 | 14 | Ticker ticker; |
LabSE | 0:cea062e60f85 | 15 | DigitalOut led1(LED1); |
LabSE | 0:cea062e60f85 | 16 | DigitalOut led2(LED2); |
protongamer | 1:c022a879e21c | 17 | |
protongamer | 1:c022a879e21c | 18 | Serial pc(USBTX, USBRX); |
protongamer | 1:c022a879e21c | 19 | CAN can1(p9, p10); |
LabSE | 0:cea062e60f85 | 20 | CAN can2(p30, p29); |
protongamer | 1:c022a879e21c | 21 | |
protongamer | 1:c022a879e21c | 22 | char value = 0; |
protongamer | 1:c022a879e21c | 23 | uint8_t state = 0; |
protongamer | 1:c022a879e21c | 24 | uint16_t identifier = 0x0539; |
protongamer | 2:be902ab7d787 | 25 | uint8_t bytes; |
protongamer | 2:be902ab7d787 | 26 | char message[8]; |
protongamer | 1:c022a879e21c | 27 | |
protongamer | 2:be902ab7d787 | 28 | void send() { |
protongamer | 1:c022a879e21c | 29 | //pc.printf("send()\n"); |
protongamer | 2:be902ab7d787 | 30 | if(can1.write(CANMessage(identifier, message, bytes,CANRemote))) { |
protongamer | 1:c022a879e21c | 31 | //pc.printf("wloop()\n"); |
protongamer | 1:c022a879e21c | 32 | //counter++; |
protongamer | 2:be902ab7d787 | 33 | pc.printf("Message sent: %d\r\n", message); |
protongamer | 1:c022a879e21c | 34 | } |
protongamer | 1:c022a879e21c | 35 | led1 = !led1; |
LabSE | 0:cea062e60f85 | 36 | } |
LabSE | 0:cea062e60f85 | 37 | |
LabSE | 0:cea062e60f85 | 38 | int main() { |
protongamer | 1:c022a879e21c | 39 | |
protongamer | 1:c022a879e21c | 40 | //ticker.attach(&send, 1); |
LabSE | 0:cea062e60f85 | 41 | CANMessage msg; |
protongamer | 1:c022a879e21c | 42 | char c; |
protongamer | 2:be902ab7d787 | 43 | uint64_t instruction; |
protongamer | 2:be902ab7d787 | 44 | |
protongamer | 2:be902ab7d787 | 45 | |
protongamer | 1:c022a879e21c | 46 | int8_t state_val; |
protongamer | 1:c022a879e21c | 47 | uint8_t data_report[100]; |
protongamer | 1:c022a879e21c | 48 | uint8_t data_rc; |
protongamer | 1:c022a879e21c | 49 | uint8_t endianness = 0; |
LabSE | 0:cea062e60f85 | 50 | while(1) { |
protongamer | 1:c022a879e21c | 51 | |
protongamer | 1:c022a879e21c | 52 | |
protongamer | 1:c022a879e21c | 53 | |
protongamer | 1:c022a879e21c | 54 | |
protongamer | 1:c022a879e21c | 55 | switch(state){ |
protongamer | 1:c022a879e21c | 56 | |
protongamer | 1:c022a879e21c | 57 | case MENU_DISPLAY://menu affichage |
protongamer | 1:c022a879e21c | 58 | pc.printf("\r\n\n\n"); |
protongamer | 1:c022a879e21c | 59 | pc.printf("CAN BUS - TERMINAL \r\n"); |
protongamer | 1:c022a879e21c | 60 | pc.printf("1 - Set the value to be sent\r\n"); |
protongamer | 1:c022a879e21c | 61 | pc.printf("2 - Set Endianness \r\n"); |
protongamer | 1:c022a879e21c | 62 | pc.printf("3 - Set Identifier \r\n"); |
protongamer | 1:c022a879e21c | 63 | pc.printf("4 - Send the value \r\n"); |
protongamer | 1:c022a879e21c | 64 | state = 1; |
protongamer | 1:c022a879e21c | 65 | break; |
protongamer | 1:c022a879e21c | 66 | |
protongamer | 1:c022a879e21c | 67 | case MENU_CHOOSE://choix menu |
protongamer | 1:c022a879e21c | 68 | |
protongamer | 1:c022a879e21c | 69 | c = pc.getc(); |
protongamer | 1:c022a879e21c | 70 | |
protongamer | 1:c022a879e21c | 71 | |
protongamer | 1:c022a879e21c | 72 | if(c == '1'){//attribution valeur a envoyer |
protongamer | 1:c022a879e21c | 73 | instruction = 0; |
protongamer | 1:c022a879e21c | 74 | state_val = 0; |
protongamer | 1:c022a879e21c | 75 | pc.printf("1 \r\n\n"); |
protongamer | 1:c022a879e21c | 76 | wait(1.0); |
protongamer | 1:c022a879e21c | 77 | state = MENU_SENDING_DISPLAY; |
protongamer | 1:c022a879e21c | 78 | } |
protongamer | 1:c022a879e21c | 79 | |
protongamer | 1:c022a879e21c | 80 | |
protongamer | 1:c022a879e21c | 81 | if(c == '2'){ |
protongamer | 1:c022a879e21c | 82 | pc.printf("2 \r\n\n"); |
protongamer | 1:c022a879e21c | 83 | wait(1.0); |
protongamer | 1:c022a879e21c | 84 | |
protongamer | 1:c022a879e21c | 85 | pc.printf("Endianness Configuration \r\n"); |
protongamer | 2:be902ab7d787 | 86 | pc.printf("1 - Choose Big/Little Endian \r\n"); |
protongamer | 2:be902ab7d787 | 87 | pc.printf("2 - Back to menu \r\n"); |
protongamer | 1:c022a879e21c | 88 | |
protongamer | 1:c022a879e21c | 89 | c = pc.getc(); |
protongamer | 1:c022a879e21c | 90 | |
protongamer | 1:c022a879e21c | 91 | if(c == '1'){ |
protongamer | 1:c022a879e21c | 92 | endianness = BIG_ENDIAN; |
protongamer | 2:be902ab7d787 | 93 | instruction = message[0]; |
protongamer | 2:be902ab7d787 | 94 | message[0] = message[1]; |
protongamer | 1:c022a879e21c | 95 | pc.printf("\r\n1\r\n"); |
protongamer | 1:c022a879e21c | 96 | } |
protongamer | 1:c022a879e21c | 97 | |
protongamer | 1:c022a879e21c | 98 | if(c == '2'){ |
protongamer | 1:c022a879e21c | 99 | endianness = LITTLE_ENDIAN; |
protongamer | 2:be902ab7d787 | 100 | instruction = message[0]; |
protongamer | 2:be902ab7d787 | 101 | message[0] = message[1]; |
protongamer | 1:c022a879e21c | 102 | pc.printf("\r\n2\r\n"); |
protongamer | 1:c022a879e21c | 103 | } |
protongamer | 1:c022a879e21c | 104 | state = MENU_DISPLAY; |
protongamer | 1:c022a879e21c | 105 | wait(1.0); |
protongamer | 1:c022a879e21c | 106 | |
protongamer | 1:c022a879e21c | 107 | } |
protongamer | 1:c022a879e21c | 108 | |
protongamer | 1:c022a879e21c | 109 | |
protongamer | 1:c022a879e21c | 110 | if(c == '3'){ |
protongamer | 1:c022a879e21c | 111 | |
protongamer | 1:c022a879e21c | 112 | pc.printf("3 \r\n\n"); |
protongamer | 1:c022a879e21c | 113 | wait(1.0); |
protongamer | 1:c022a879e21c | 114 | |
protongamer | 1:c022a879e21c | 115 | pc.printf("Set the identifier(hexa) : 0x"); |
protongamer | 1:c022a879e21c | 116 | state = SET_ID; |
protongamer | 1:c022a879e21c | 117 | |
protongamer | 1:c022a879e21c | 118 | } |
protongamer | 1:c022a879e21c | 119 | |
protongamer | 1:c022a879e21c | 120 | |
protongamer | 1:c022a879e21c | 121 | if(c == '4'){//envoie valeur |
protongamer | 1:c022a879e21c | 122 | pc.printf("4 \r\n\n"); |
protongamer | 1:c022a879e21c | 123 | wait(1.0); |
protongamer | 2:be902ab7d787 | 124 | send(); |
protongamer | 2:be902ab7d787 | 125 | /* |
protongamer | 1:c022a879e21c | 126 | switch(bytes){//calcul nombre octet présent |
protongamer | 2:be902ab7d787 | 127 | case 1://si 1 octet present envoie 1 octet |
protongamer | 2:be902ab7d787 | 128 | send(); |
protongamer | 1:c022a879e21c | 129 | break; |
protongamer | 1:c022a879e21c | 130 | |
protongamer | 1:c022a879e21c | 131 | case 2://si 2 octets present envoie 2 octets 1 par 1 |
protongamer | 1:c022a879e21c | 132 | if(endianness == BIG_ENDIAN){ |
protongamer | 2:be902ab7d787 | 133 | // send(instruction_2); |
protongamer | 2:be902ab7d787 | 134 | send(); |
protongamer | 2:be902ab7d787 | 135 | } |
protongamer | 1:c022a879e21c | 136 | |
protongamer | 1:c022a879e21c | 137 | if(endianness == LITTLE_ENDIAN){ |
protongamer | 2:be902ab7d787 | 138 | //send(instruction); |
protongamer | 2:be902ab7d787 | 139 | //send(instruction_2); |
protongamer | 2:be902ab7d787 | 140 | } |
protongamer | 1:c022a879e21c | 141 | break; |
protongamer | 1:c022a879e21c | 142 | |
protongamer | 1:c022a879e21c | 143 | }//switch |
protongamer | 2:be902ab7d787 | 144 | */ |
protongamer | 1:c022a879e21c | 145 | |
protongamer | 1:c022a879e21c | 146 | state = MENU_DISPLAY; //on revient au menu de départ apres la capture de données |
protongamer | 1:c022a879e21c | 147 | |
protongamer | 1:c022a879e21c | 148 | //sequence de capture de données de retour |
protongamer | 1:c022a879e21c | 149 | for(int i = 0; i <= 500; i++){ |
protongamer | 1:c022a879e21c | 150 | if(!can1.read(msg)) { |
protongamer | 1:c022a879e21c | 151 | pc.printf("awaiting data\r\n");} |
protongamer | 1:c022a879e21c | 152 | |
protongamer | 1:c022a879e21c | 153 | if(can1.read(msg)) { |
protongamer | 1:c022a879e21c | 154 | pc.printf("Message received: %d \r\n", msg.data[0]); |
protongamer | 1:c022a879e21c | 155 | data_report[data_rc] = msg.data[0]; |
protongamer | 1:c022a879e21c | 156 | data_rc++; |
protongamer | 1:c022a879e21c | 157 | led2 = !led2; |
protongamer | 1:c022a879e21c | 158 | wait(0.1); |
protongamer | 1:c022a879e21c | 159 | } |
protongamer | 1:c022a879e21c | 160 | |
protongamer | 1:c022a879e21c | 161 | }//for int i |
protongamer | 1:c022a879e21c | 162 | pc.printf("\r\nDone\r\n\n"); |
protongamer | 1:c022a879e21c | 163 | //capture de données terminées, on fait un rapport des données collectées |
protongamer | 1:c022a879e21c | 164 | for(int i = 0; i < data_rc; i++){ |
protongamer | 1:c022a879e21c | 165 | pc.printf("Message captured: %d \r\n", data_report[i]); |
protongamer | 1:c022a879e21c | 166 | } |
protongamer | 1:c022a879e21c | 167 | data_rc = 0; |
protongamer | 1:c022a879e21c | 168 | |
protongamer | 1:c022a879e21c | 169 | }//if c == '2' |
protongamer | 1:c022a879e21c | 170 | |
protongamer | 1:c022a879e21c | 171 | break;// |
protongamer | 1:c022a879e21c | 172 | |
protongamer | 1:c022a879e21c | 173 | case MENU_SENDING_DISPLAY://choix de la valeur a envoyer |
protongamer | 1:c022a879e21c | 174 | pc.printf("Set the value to be sent(hex value) : 0x"); |
protongamer | 1:c022a879e21c | 175 | state = 3; |
protongamer | 1:c022a879e21c | 176 | break; |
protongamer | 1:c022a879e21c | 177 | |
protongamer | 1:c022a879e21c | 178 | case MENU_SENDING://demande de valeur a envoyer |
protongamer | 1:c022a879e21c | 179 | |
protongamer | 1:c022a879e21c | 180 | c = pc.getc(); |
protongamer | 1:c022a879e21c | 181 | |
protongamer | 1:c022a879e21c | 182 | |
protongamer | 1:c022a879e21c | 183 | //state_val correspond a la premiere valeur, si la premiere valeur n'est pas encore entrée, elle attribué a la variable instruction |
protongamer | 1:c022a879e21c | 184 | //dans l'autre cas, on décale de 4 rang les 4 bits de l'ancienne valeur pour l'ajouter à la nouvelle |
protongamer | 1:c022a879e21c | 185 | switch(c){ |
protongamer | 1:c022a879e21c | 186 | |
protongamer | 1:c022a879e21c | 187 | |
protongamer | 1:c022a879e21c | 188 | |
protongamer | 1:c022a879e21c | 189 | case '0': |
protongamer | 1:c022a879e21c | 190 | pc.printf("0"); |
protongamer | 1:c022a879e21c | 191 | |
protongamer | 1:c022a879e21c | 192 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 193 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 194 | instruction |= 0b0000; |
protongamer | 1:c022a879e21c | 195 | } |
protongamer | 1:c022a879e21c | 196 | |
protongamer | 1:c022a879e21c | 197 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 198 | instruction = 0b0000; |
protongamer | 1:c022a879e21c | 199 | state_val++; |
protongamer | 1:c022a879e21c | 200 | } |
protongamer | 1:c022a879e21c | 201 | |
protongamer | 1:c022a879e21c | 202 | break; |
protongamer | 1:c022a879e21c | 203 | |
protongamer | 1:c022a879e21c | 204 | case '1': |
protongamer | 1:c022a879e21c | 205 | |
protongamer | 1:c022a879e21c | 206 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 207 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 208 | instruction |= 0b0001; |
protongamer | 1:c022a879e21c | 209 | } |
protongamer | 1:c022a879e21c | 210 | |
protongamer | 1:c022a879e21c | 211 | pc.printf("1"); |
protongamer | 1:c022a879e21c | 212 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 213 | instruction = 0b0001; |
protongamer | 1:c022a879e21c | 214 | state_val++; |
protongamer | 1:c022a879e21c | 215 | } |
protongamer | 1:c022a879e21c | 216 | |
protongamer | 1:c022a879e21c | 217 | break; |
protongamer | 1:c022a879e21c | 218 | |
protongamer | 1:c022a879e21c | 219 | case '2': |
protongamer | 1:c022a879e21c | 220 | |
protongamer | 1:c022a879e21c | 221 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 222 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 223 | instruction |= 0b0010; |
protongamer | 1:c022a879e21c | 224 | } |
protongamer | 1:c022a879e21c | 225 | |
protongamer | 1:c022a879e21c | 226 | pc.printf("2"); |
protongamer | 1:c022a879e21c | 227 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 228 | instruction = 0b0010; |
protongamer | 1:c022a879e21c | 229 | state_val++; |
protongamer | 1:c022a879e21c | 230 | } |
protongamer | 1:c022a879e21c | 231 | |
protongamer | 1:c022a879e21c | 232 | break; |
protongamer | 1:c022a879e21c | 233 | |
protongamer | 1:c022a879e21c | 234 | case '3': |
protongamer | 1:c022a879e21c | 235 | pc.printf("3"); |
protongamer | 1:c022a879e21c | 236 | |
protongamer | 1:c022a879e21c | 237 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 238 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 239 | instruction |= 0b0011; |
protongamer | 1:c022a879e21c | 240 | } |
protongamer | 1:c022a879e21c | 241 | |
protongamer | 1:c022a879e21c | 242 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 243 | instruction = 0b0011; |
protongamer | 1:c022a879e21c | 244 | state_val++; |
protongamer | 1:c022a879e21c | 245 | } |
protongamer | 1:c022a879e21c | 246 | |
protongamer | 1:c022a879e21c | 247 | break; |
protongamer | 1:c022a879e21c | 248 | |
protongamer | 1:c022a879e21c | 249 | case '4': |
protongamer | 1:c022a879e21c | 250 | |
protongamer | 1:c022a879e21c | 251 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 252 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 253 | instruction |= 0b0100; |
protongamer | 1:c022a879e21c | 254 | } |
protongamer | 1:c022a879e21c | 255 | |
protongamer | 1:c022a879e21c | 256 | pc.printf("4"); |
protongamer | 1:c022a879e21c | 257 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 258 | instruction = 0b0100; |
protongamer | 1:c022a879e21c | 259 | state_val++; |
protongamer | 1:c022a879e21c | 260 | } |
protongamer | 1:c022a879e21c | 261 | |
protongamer | 1:c022a879e21c | 262 | break; |
protongamer | 1:c022a879e21c | 263 | |
protongamer | 1:c022a879e21c | 264 | case '5': |
protongamer | 1:c022a879e21c | 265 | pc.printf("5"); |
protongamer | 1:c022a879e21c | 266 | |
protongamer | 1:c022a879e21c | 267 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 268 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 269 | instruction |= 0b0101; |
protongamer | 1:c022a879e21c | 270 | } |
protongamer | 1:c022a879e21c | 271 | |
protongamer | 1:c022a879e21c | 272 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 273 | instruction = 0b0101; |
protongamer | 1:c022a879e21c | 274 | state_val++; |
protongamer | 1:c022a879e21c | 275 | } |
protongamer | 1:c022a879e21c | 276 | |
protongamer | 1:c022a879e21c | 277 | break; |
protongamer | 1:c022a879e21c | 278 | |
protongamer | 1:c022a879e21c | 279 | case '6': |
protongamer | 1:c022a879e21c | 280 | pc.printf("6"); |
protongamer | 1:c022a879e21c | 281 | |
protongamer | 1:c022a879e21c | 282 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 283 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 284 | instruction |= 0b0110; |
protongamer | 1:c022a879e21c | 285 | } |
protongamer | 1:c022a879e21c | 286 | |
protongamer | 1:c022a879e21c | 287 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 288 | instruction = 0b0110; |
protongamer | 1:c022a879e21c | 289 | state_val++; |
protongamer | 1:c022a879e21c | 290 | } |
protongamer | 1:c022a879e21c | 291 | |
protongamer | 1:c022a879e21c | 292 | break; |
protongamer | 1:c022a879e21c | 293 | |
protongamer | 1:c022a879e21c | 294 | case '7': |
protongamer | 1:c022a879e21c | 295 | pc.printf("7"); |
protongamer | 1:c022a879e21c | 296 | |
protongamer | 1:c022a879e21c | 297 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 298 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 299 | instruction |= 0b0111; |
protongamer | 1:c022a879e21c | 300 | } |
protongamer | 1:c022a879e21c | 301 | |
protongamer | 1:c022a879e21c | 302 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 303 | instruction = 0b0111; |
protongamer | 1:c022a879e21c | 304 | state_val++; |
protongamer | 1:c022a879e21c | 305 | } |
protongamer | 1:c022a879e21c | 306 | |
protongamer | 1:c022a879e21c | 307 | break; |
protongamer | 1:c022a879e21c | 308 | |
protongamer | 1:c022a879e21c | 309 | case '8': |
protongamer | 1:c022a879e21c | 310 | pc.printf("8"); |
protongamer | 1:c022a879e21c | 311 | |
protongamer | 1:c022a879e21c | 312 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 313 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 314 | instruction |= 0b1000; |
protongamer | 1:c022a879e21c | 315 | } |
protongamer | 1:c022a879e21c | 316 | |
protongamer | 1:c022a879e21c | 317 | |
protongamer | 1:c022a879e21c | 318 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 319 | instruction = 0b1000; |
protongamer | 1:c022a879e21c | 320 | state_val++; |
protongamer | 1:c022a879e21c | 321 | } |
protongamer | 1:c022a879e21c | 322 | |
protongamer | 1:c022a879e21c | 323 | break; |
protongamer | 1:c022a879e21c | 324 | |
protongamer | 1:c022a879e21c | 325 | case '9': |
protongamer | 1:c022a879e21c | 326 | pc.printf("9"); |
protongamer | 1:c022a879e21c | 327 | |
protongamer | 1:c022a879e21c | 328 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 329 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 330 | instruction |= 0b1001; |
protongamer | 1:c022a879e21c | 331 | } |
protongamer | 1:c022a879e21c | 332 | |
protongamer | 1:c022a879e21c | 333 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 334 | instruction = 0b1001; |
protongamer | 1:c022a879e21c | 335 | state_val++; |
protongamer | 1:c022a879e21c | 336 | } |
protongamer | 1:c022a879e21c | 337 | |
protongamer | 1:c022a879e21c | 338 | break; |
protongamer | 1:c022a879e21c | 339 | |
protongamer | 1:c022a879e21c | 340 | case 'a': |
protongamer | 1:c022a879e21c | 341 | pc.printf("a"); |
protongamer | 1:c022a879e21c | 342 | |
protongamer | 1:c022a879e21c | 343 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 344 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 345 | instruction |= 0b1010; |
protongamer | 1:c022a879e21c | 346 | } |
protongamer | 1:c022a879e21c | 347 | |
protongamer | 1:c022a879e21c | 348 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 349 | instruction = 0b1010; |
protongamer | 1:c022a879e21c | 350 | state_val++; |
protongamer | 1:c022a879e21c | 351 | } |
protongamer | 1:c022a879e21c | 352 | |
protongamer | 1:c022a879e21c | 353 | break; |
protongamer | 1:c022a879e21c | 354 | |
protongamer | 1:c022a879e21c | 355 | case 'b': |
protongamer | 1:c022a879e21c | 356 | pc.printf("b"); |
protongamer | 1:c022a879e21c | 357 | |
protongamer | 1:c022a879e21c | 358 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 359 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 360 | instruction |= 0b1011; |
protongamer | 1:c022a879e21c | 361 | } |
protongamer | 1:c022a879e21c | 362 | |
protongamer | 1:c022a879e21c | 363 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 364 | instruction = 0b1011; |
protongamer | 1:c022a879e21c | 365 | state_val++; |
protongamer | 1:c022a879e21c | 366 | } |
protongamer | 1:c022a879e21c | 367 | |
protongamer | 1:c022a879e21c | 368 | break; |
protongamer | 1:c022a879e21c | 369 | |
protongamer | 1:c022a879e21c | 370 | case 'c': |
protongamer | 1:c022a879e21c | 371 | pc.printf("c"); |
protongamer | 1:c022a879e21c | 372 | |
protongamer | 1:c022a879e21c | 373 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 374 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 375 | instruction |= 0b1100; |
protongamer | 1:c022a879e21c | 376 | } |
protongamer | 1:c022a879e21c | 377 | |
protongamer | 1:c022a879e21c | 378 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 379 | instruction = 0b1100; |
protongamer | 1:c022a879e21c | 380 | state_val++; |
protongamer | 1:c022a879e21c | 381 | } |
protongamer | 1:c022a879e21c | 382 | |
protongamer | 1:c022a879e21c | 383 | break; |
protongamer | 1:c022a879e21c | 384 | |
protongamer | 1:c022a879e21c | 385 | case 'd': |
protongamer | 1:c022a879e21c | 386 | pc.printf("d"); |
protongamer | 1:c022a879e21c | 387 | |
protongamer | 1:c022a879e21c | 388 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 389 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 390 | instruction |= 0b1101; |
protongamer | 1:c022a879e21c | 391 | } |
protongamer | 1:c022a879e21c | 392 | |
protongamer | 1:c022a879e21c | 393 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 394 | instruction = 0b1101; |
protongamer | 1:c022a879e21c | 395 | state_val++; |
protongamer | 1:c022a879e21c | 396 | } |
protongamer | 1:c022a879e21c | 397 | |
protongamer | 1:c022a879e21c | 398 | break; |
protongamer | 1:c022a879e21c | 399 | |
protongamer | 1:c022a879e21c | 400 | case 'e': |
protongamer | 1:c022a879e21c | 401 | pc.printf("e"); |
protongamer | 1:c022a879e21c | 402 | |
protongamer | 1:c022a879e21c | 403 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 404 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 405 | instruction |= 0b1110; |
protongamer | 1:c022a879e21c | 406 | } |
protongamer | 1:c022a879e21c | 407 | |
protongamer | 1:c022a879e21c | 408 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 409 | instruction = 0b1110; |
protongamer | 1:c022a879e21c | 410 | state_val++; |
protongamer | 1:c022a879e21c | 411 | } |
protongamer | 1:c022a879e21c | 412 | |
protongamer | 1:c022a879e21c | 413 | break; |
protongamer | 1:c022a879e21c | 414 | |
protongamer | 1:c022a879e21c | 415 | case 'f': |
protongamer | 1:c022a879e21c | 416 | pc.printf("f"); |
protongamer | 1:c022a879e21c | 417 | |
protongamer | 1:c022a879e21c | 418 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 419 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 420 | instruction |= 0b1111; |
protongamer | 1:c022a879e21c | 421 | } |
protongamer | 1:c022a879e21c | 422 | |
protongamer | 1:c022a879e21c | 423 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 424 | instruction = 0b1111; |
protongamer | 1:c022a879e21c | 425 | state_val++; |
protongamer | 1:c022a879e21c | 426 | } |
protongamer | 1:c022a879e21c | 427 | |
protongamer | 1:c022a879e21c | 428 | break; |
protongamer | 1:c022a879e21c | 429 | |
protongamer | 1:c022a879e21c | 430 | case 'A': |
protongamer | 1:c022a879e21c | 431 | pc.printf("a"); |
protongamer | 1:c022a879e21c | 432 | |
protongamer | 1:c022a879e21c | 433 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 434 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 435 | instruction |= 0b1010; |
protongamer | 1:c022a879e21c | 436 | } |
protongamer | 1:c022a879e21c | 437 | |
protongamer | 1:c022a879e21c | 438 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 439 | instruction = 0b1010; |
protongamer | 1:c022a879e21c | 440 | state_val++; |
protongamer | 1:c022a879e21c | 441 | } |
protongamer | 1:c022a879e21c | 442 | |
protongamer | 1:c022a879e21c | 443 | break; |
protongamer | 1:c022a879e21c | 444 | |
protongamer | 1:c022a879e21c | 445 | case 'B': |
protongamer | 1:c022a879e21c | 446 | pc.printf("b"); |
protongamer | 1:c022a879e21c | 447 | |
protongamer | 1:c022a879e21c | 448 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 449 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 450 | instruction |= 0b1011; |
protongamer | 1:c022a879e21c | 451 | } |
protongamer | 1:c022a879e21c | 452 | |
protongamer | 1:c022a879e21c | 453 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 454 | instruction = 0b1011; |
protongamer | 1:c022a879e21c | 455 | state_val++; |
protongamer | 1:c022a879e21c | 456 | } |
protongamer | 1:c022a879e21c | 457 | |
protongamer | 1:c022a879e21c | 458 | break; |
protongamer | 1:c022a879e21c | 459 | |
protongamer | 1:c022a879e21c | 460 | case 'C': |
protongamer | 1:c022a879e21c | 461 | pc.printf("c"); |
protongamer | 1:c022a879e21c | 462 | |
protongamer | 1:c022a879e21c | 463 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 464 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 465 | instruction |= 0b1100; |
protongamer | 1:c022a879e21c | 466 | } |
protongamer | 1:c022a879e21c | 467 | |
protongamer | 1:c022a879e21c | 468 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 469 | instruction = 0b1100; |
protongamer | 1:c022a879e21c | 470 | state_val++; |
protongamer | 1:c022a879e21c | 471 | } |
protongamer | 1:c022a879e21c | 472 | |
protongamer | 1:c022a879e21c | 473 | break; |
protongamer | 1:c022a879e21c | 474 | |
protongamer | 1:c022a879e21c | 475 | case 'D': |
protongamer | 1:c022a879e21c | 476 | pc.printf("d"); |
protongamer | 1:c022a879e21c | 477 | |
protongamer | 1:c022a879e21c | 478 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 479 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 480 | instruction |= 0b1101; |
protongamer | 1:c022a879e21c | 481 | } |
protongamer | 1:c022a879e21c | 482 | |
protongamer | 1:c022a879e21c | 483 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 484 | instruction = 0b1101; |
protongamer | 1:c022a879e21c | 485 | state_val++; |
protongamer | 1:c022a879e21c | 486 | } |
protongamer | 1:c022a879e21c | 487 | |
protongamer | 1:c022a879e21c | 488 | break; |
protongamer | 1:c022a879e21c | 489 | |
protongamer | 1:c022a879e21c | 490 | case 'E': |
protongamer | 1:c022a879e21c | 491 | pc.printf("e"); |
protongamer | 1:c022a879e21c | 492 | |
protongamer | 1:c022a879e21c | 493 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 494 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 495 | instruction |= 0b1110; |
protongamer | 1:c022a879e21c | 496 | } |
protongamer | 1:c022a879e21c | 497 | |
protongamer | 1:c022a879e21c | 498 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 499 | instruction = 0b1110; |
protongamer | 1:c022a879e21c | 500 | state_val++; |
protongamer | 1:c022a879e21c | 501 | } |
protongamer | 1:c022a879e21c | 502 | |
protongamer | 1:c022a879e21c | 503 | break; |
protongamer | 1:c022a879e21c | 504 | |
protongamer | 1:c022a879e21c | 505 | case 'F': |
protongamer | 1:c022a879e21c | 506 | pc.printf("f"); |
protongamer | 1:c022a879e21c | 507 | |
protongamer | 1:c022a879e21c | 508 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 509 | instruction = instruction << 4; |
protongamer | 1:c022a879e21c | 510 | instruction |= 0b1111; |
protongamer | 1:c022a879e21c | 511 | } |
protongamer | 1:c022a879e21c | 512 | |
protongamer | 1:c022a879e21c | 513 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 514 | instruction = 0b1111; |
protongamer | 1:c022a879e21c | 515 | state_val++; |
protongamer | 1:c022a879e21c | 516 | } |
protongamer | 1:c022a879e21c | 517 | |
protongamer | 1:c022a879e21c | 518 | break; |
protongamer | 1:c022a879e21c | 519 | |
protongamer | 1:c022a879e21c | 520 | case '\r': //si au sérial nous avons le retour de ligne |
protongamer | 2:be902ab7d787 | 521 | pc.printf("\r\Done \r\n"); |
protongamer | 1:c022a879e21c | 522 | wait(1.0); |
protongamer | 1:c022a879e21c | 523 | state_val = 0; |
protongamer | 1:c022a879e21c | 524 | state = MENU_DISPLAY; |
protongamer | 1:c022a879e21c | 525 | //calcul du nombre d'octet en fonction de la valeur finale |
protongamer | 2:be902ab7d787 | 526 | if(instruction <= 0xFF){ |
protongamer | 1:c022a879e21c | 527 | bytes = 1; |
protongamer | 2:be902ab7d787 | 528 | message[0] = instruction; |
protongamer | 2:be902ab7d787 | 529 | message[1] = 0; |
protongamer | 2:be902ab7d787 | 530 | message[2] = 0; |
protongamer | 2:be902ab7d787 | 531 | message[3] = 0; |
protongamer | 2:be902ab7d787 | 532 | message[4] = 0; |
protongamer | 2:be902ab7d787 | 533 | message[5] = 0; |
protongamer | 2:be902ab7d787 | 534 | message[6] = 0; |
protongamer | 2:be902ab7d787 | 535 | message[7] = 0; |
protongamer | 2:be902ab7d787 | 536 | |
protongamer | 2:be902ab7d787 | 537 | } |
protongamer | 2:be902ab7d787 | 538 | if(instruction > 0xFF && instruction <= 0xFFFF){ |
protongamer | 2:be902ab7d787 | 539 | bytes = 2; |
protongamer | 2:be902ab7d787 | 540 | message[1] = instruction & 0x00FF; |
protongamer | 2:be902ab7d787 | 541 | instruction = instruction >> 8; |
protongamer | 2:be902ab7d787 | 542 | message[0] = instruction; |
protongamer | 2:be902ab7d787 | 543 | message[2] = 0; |
protongamer | 2:be902ab7d787 | 544 | message[3] = 0; |
protongamer | 2:be902ab7d787 | 545 | message[4] = 0; |
protongamer | 2:be902ab7d787 | 546 | message[5] = 0; |
protongamer | 2:be902ab7d787 | 547 | message[6] = 0; |
protongamer | 2:be902ab7d787 | 548 | message[7] = 0; |
protongamer | 2:be902ab7d787 | 549 | } |
protongamer | 2:be902ab7d787 | 550 | if(instruction > 0xFFFF && instruction <= 0xFFFFFF){ |
protongamer | 2:be902ab7d787 | 551 | bytes = 3; |
protongamer | 2:be902ab7d787 | 552 | message[2] = instruction & 0x0000FF; |
protongamer | 2:be902ab7d787 | 553 | message[1] = (instruction >> 8) & 0x00FF; |
protongamer | 2:be902ab7d787 | 554 | instruction = instruction >> 16; |
protongamer | 2:be902ab7d787 | 555 | message[0] = instruction & 0xFF; |
protongamer | 2:be902ab7d787 | 556 | message[3] = 0; |
protongamer | 2:be902ab7d787 | 557 | message[4] = 0; |
protongamer | 2:be902ab7d787 | 558 | message[5] = 0; |
protongamer | 2:be902ab7d787 | 559 | message[6] = 0; |
protongamer | 2:be902ab7d787 | 560 | message[7] = 0; |
protongamer | 2:be902ab7d787 | 561 | } |
protongamer | 2:be902ab7d787 | 562 | |
protongamer | 2:be902ab7d787 | 563 | if(instruction > 0xFFFFFF && instruction <= 0xFFFFFFFF){ |
protongamer | 2:be902ab7d787 | 564 | bytes = 4; |
protongamer | 2:be902ab7d787 | 565 | message[3] = instruction & 0x000000FF; |
protongamer | 2:be902ab7d787 | 566 | message[2] = (instruction >> 8) & 0x0000FF; |
protongamer | 2:be902ab7d787 | 567 | message[1] = (instruction >> 16) & 0x00FF; |
protongamer | 2:be902ab7d787 | 568 | instruction = instruction >> 24; |
protongamer | 2:be902ab7d787 | 569 | message[0] = instruction & 0xFF; |
protongamer | 2:be902ab7d787 | 570 | message[4] = 0; |
protongamer | 2:be902ab7d787 | 571 | message[5] = 0; |
protongamer | 2:be902ab7d787 | 572 | message[6] = 0; |
protongamer | 2:be902ab7d787 | 573 | message[7] = 0; |
protongamer | 1:c022a879e21c | 574 | } |
protongamer | 2:be902ab7d787 | 575 | |
protongamer | 2:be902ab7d787 | 576 | if(instruction > 0xFFFFFFFF && instruction <= 0xFFFFFFFFFF){ |
protongamer | 2:be902ab7d787 | 577 | bytes = 5; |
protongamer | 2:be902ab7d787 | 578 | message[4] = instruction & 0x00000000FF; |
protongamer | 2:be902ab7d787 | 579 | message[3] = (instruction >> 8) & 0x000000FF; |
protongamer | 2:be902ab7d787 | 580 | message[2] = (instruction >> 16) & 0x0000FF; |
protongamer | 2:be902ab7d787 | 581 | message[1] = (instruction >> 24) & 0x00FF; |
protongamer | 2:be902ab7d787 | 582 | instruction = instruction >> 32; |
protongamer | 2:be902ab7d787 | 583 | message[0] = instruction & 0xFF; |
protongamer | 2:be902ab7d787 | 584 | message[5] = 0; |
protongamer | 2:be902ab7d787 | 585 | message[6] = 0; |
protongamer | 2:be902ab7d787 | 586 | message[7] = 0; |
protongamer | 2:be902ab7d787 | 587 | } |
protongamer | 2:be902ab7d787 | 588 | |
protongamer | 2:be902ab7d787 | 589 | if(instruction > 0xFFFFFFFFFF && instruction <= 0xFFFFFFFFFFFF){ |
protongamer | 2:be902ab7d787 | 590 | bytes = 6; |
protongamer | 2:be902ab7d787 | 591 | message[5] = instruction & 0x0000000000FF; |
protongamer | 2:be902ab7d787 | 592 | message[4] = (instruction >> 8) & 0x00000000FF; |
protongamer | 2:be902ab7d787 | 593 | message[3] = (instruction >> 16) & 0x000000FF; |
protongamer | 2:be902ab7d787 | 594 | message[2] = (instruction >> 24) & 0x0000FF; |
protongamer | 2:be902ab7d787 | 595 | message[1] = (instruction >> 32) & 0x00FF; |
protongamer | 2:be902ab7d787 | 596 | instruction = instruction >> 40; |
protongamer | 2:be902ab7d787 | 597 | message[0] = instruction & 0xFF; |
protongamer | 2:be902ab7d787 | 598 | message[6] = 0; |
protongamer | 2:be902ab7d787 | 599 | message[7] = 0; |
protongamer | 2:be902ab7d787 | 600 | } |
protongamer | 2:be902ab7d787 | 601 | |
protongamer | 2:be902ab7d787 | 602 | if(instruction > 0xFFFFFFFFFFFF && instruction <= 0xFFFFFFFFFFFFFF){ |
protongamer | 2:be902ab7d787 | 603 | bytes = 7; |
protongamer | 2:be902ab7d787 | 604 | message[6] = instruction & 0x000000000000FF; |
protongamer | 2:be902ab7d787 | 605 | message[5] = (instruction >> 8) & 0x0000000000FF; |
protongamer | 2:be902ab7d787 | 606 | message[4] = (instruction >> 16) & 0x00000000FF; |
protongamer | 2:be902ab7d787 | 607 | message[3] = (instruction >> 24) & 0x000000FF; |
protongamer | 2:be902ab7d787 | 608 | message[2] = (instruction >> 32) & 0x0000FF; |
protongamer | 2:be902ab7d787 | 609 | message[1] = (instruction >> 40) & 0x00FF; |
protongamer | 2:be902ab7d787 | 610 | instruction = instruction >> 48; |
protongamer | 2:be902ab7d787 | 611 | message[0] = instruction & 0xFF; |
protongamer | 2:be902ab7d787 | 612 | message[7] = 0; |
protongamer | 2:be902ab7d787 | 613 | } |
protongamer | 2:be902ab7d787 | 614 | if(instruction > 0xFFFFFFFFFFFFFF && instruction <= 0xFFFFFFFFFFFFFFFF){ |
protongamer | 2:be902ab7d787 | 615 | bytes = 8; |
protongamer | 2:be902ab7d787 | 616 | message[7] = instruction & 0x00000000000000FF; |
protongamer | 2:be902ab7d787 | 617 | message[6] = (instruction >> 8) & 0x000000000000FF; |
protongamer | 2:be902ab7d787 | 618 | message[5] = (instruction >> 16) & 0x0000000000FF; |
protongamer | 2:be902ab7d787 | 619 | message[4] = (instruction >> 24) & 0x00000000FF; |
protongamer | 2:be902ab7d787 | 620 | message[3] = (instruction >> 32) & 0x000000FF; |
protongamer | 2:be902ab7d787 | 621 | message[2] = (instruction >> 40) & 0x0000FF; |
protongamer | 2:be902ab7d787 | 622 | message[1] = (instruction >> 48) & 0x00FF; |
protongamer | 2:be902ab7d787 | 623 | instruction = instruction >> 56; |
protongamer | 2:be902ab7d787 | 624 | message[0] = instruction & 0xFF; |
protongamer | 1:c022a879e21c | 625 | } |
protongamer | 1:c022a879e21c | 626 | break; |
protongamer | 1:c022a879e21c | 627 | |
protongamer | 1:c022a879e21c | 628 | |
protongamer | 1:c022a879e21c | 629 | } |
protongamer | 1:c022a879e21c | 630 | |
protongamer | 1:c022a879e21c | 631 | break; |
protongamer | 1:c022a879e21c | 632 | |
protongamer | 1:c022a879e21c | 633 | case SET_ID: |
protongamer | 1:c022a879e21c | 634 | |
protongamer | 1:c022a879e21c | 635 | c = pc.getc(); |
protongamer | 1:c022a879e21c | 636 | |
protongamer | 1:c022a879e21c | 637 | switch(c){ |
protongamer | 1:c022a879e21c | 638 | |
protongamer | 1:c022a879e21c | 639 | |
protongamer | 1:c022a879e21c | 640 | |
protongamer | 1:c022a879e21c | 641 | case '0': |
protongamer | 1:c022a879e21c | 642 | pc.printf("0"); |
protongamer | 1:c022a879e21c | 643 | |
protongamer | 1:c022a879e21c | 644 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 645 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 646 | identifier |= 0b0000; |
protongamer | 1:c022a879e21c | 647 | } |
protongamer | 1:c022a879e21c | 648 | |
protongamer | 1:c022a879e21c | 649 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 650 | identifier = 0b0000; |
protongamer | 1:c022a879e21c | 651 | state_val++; |
protongamer | 1:c022a879e21c | 652 | } |
protongamer | 1:c022a879e21c | 653 | |
protongamer | 1:c022a879e21c | 654 | break; |
protongamer | 1:c022a879e21c | 655 | |
protongamer | 1:c022a879e21c | 656 | case '1': |
protongamer | 1:c022a879e21c | 657 | |
protongamer | 1:c022a879e21c | 658 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 659 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 660 | identifier |= 0b0001; |
protongamer | 1:c022a879e21c | 661 | } |
protongamer | 1:c022a879e21c | 662 | |
protongamer | 1:c022a879e21c | 663 | pc.printf("1"); |
protongamer | 1:c022a879e21c | 664 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 665 | identifier = 0b0001; |
protongamer | 1:c022a879e21c | 666 | state_val++; |
protongamer | 1:c022a879e21c | 667 | } |
protongamer | 1:c022a879e21c | 668 | |
protongamer | 1:c022a879e21c | 669 | break; |
protongamer | 1:c022a879e21c | 670 | |
protongamer | 1:c022a879e21c | 671 | case '2': |
protongamer | 1:c022a879e21c | 672 | |
protongamer | 1:c022a879e21c | 673 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 674 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 675 | identifier |= 0b0010; |
protongamer | 1:c022a879e21c | 676 | } |
protongamer | 1:c022a879e21c | 677 | |
protongamer | 1:c022a879e21c | 678 | pc.printf("2"); |
protongamer | 1:c022a879e21c | 679 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 680 | identifier = 0b0010; |
protongamer | 1:c022a879e21c | 681 | state_val++; |
protongamer | 1:c022a879e21c | 682 | } |
protongamer | 1:c022a879e21c | 683 | |
protongamer | 1:c022a879e21c | 684 | break; |
protongamer | 1:c022a879e21c | 685 | |
protongamer | 1:c022a879e21c | 686 | case '3': |
protongamer | 1:c022a879e21c | 687 | pc.printf("3"); |
protongamer | 1:c022a879e21c | 688 | |
protongamer | 1:c022a879e21c | 689 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 690 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 691 | identifier |= 0b0011; |
protongamer | 1:c022a879e21c | 692 | } |
protongamer | 1:c022a879e21c | 693 | |
protongamer | 1:c022a879e21c | 694 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 695 | identifier = 0b0011; |
protongamer | 1:c022a879e21c | 696 | state_val++; |
protongamer | 1:c022a879e21c | 697 | } |
protongamer | 1:c022a879e21c | 698 | |
protongamer | 1:c022a879e21c | 699 | break; |
protongamer | 1:c022a879e21c | 700 | |
protongamer | 1:c022a879e21c | 701 | case '4': |
protongamer | 1:c022a879e21c | 702 | |
protongamer | 1:c022a879e21c | 703 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 704 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 705 | identifier |= 0b0100; |
protongamer | 1:c022a879e21c | 706 | } |
protongamer | 1:c022a879e21c | 707 | |
protongamer | 1:c022a879e21c | 708 | pc.printf("4"); |
protongamer | 1:c022a879e21c | 709 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 710 | identifier = 0b0100; |
protongamer | 1:c022a879e21c | 711 | state_val++; |
protongamer | 1:c022a879e21c | 712 | } |
protongamer | 1:c022a879e21c | 713 | |
protongamer | 1:c022a879e21c | 714 | break; |
protongamer | 1:c022a879e21c | 715 | |
protongamer | 1:c022a879e21c | 716 | case '5': |
protongamer | 1:c022a879e21c | 717 | pc.printf("5"); |
protongamer | 1:c022a879e21c | 718 | |
protongamer | 1:c022a879e21c | 719 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 720 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 721 | identifier |= 0b0101; |
protongamer | 1:c022a879e21c | 722 | } |
protongamer | 1:c022a879e21c | 723 | |
protongamer | 1:c022a879e21c | 724 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 725 | identifier = 0b0101; |
protongamer | 1:c022a879e21c | 726 | state_val++; |
protongamer | 1:c022a879e21c | 727 | } |
protongamer | 1:c022a879e21c | 728 | |
protongamer | 1:c022a879e21c | 729 | break; |
protongamer | 1:c022a879e21c | 730 | |
protongamer | 1:c022a879e21c | 731 | case '6': |
protongamer | 1:c022a879e21c | 732 | pc.printf("6"); |
protongamer | 1:c022a879e21c | 733 | |
protongamer | 1:c022a879e21c | 734 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 735 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 736 | identifier |= 0b0110; |
protongamer | 1:c022a879e21c | 737 | } |
protongamer | 1:c022a879e21c | 738 | |
protongamer | 1:c022a879e21c | 739 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 740 | identifier = 0b0110; |
protongamer | 1:c022a879e21c | 741 | state_val++; |
protongamer | 1:c022a879e21c | 742 | } |
protongamer | 1:c022a879e21c | 743 | |
protongamer | 1:c022a879e21c | 744 | break; |
protongamer | 1:c022a879e21c | 745 | |
protongamer | 1:c022a879e21c | 746 | case '7': |
protongamer | 1:c022a879e21c | 747 | pc.printf("7"); |
protongamer | 1:c022a879e21c | 748 | |
protongamer | 1:c022a879e21c | 749 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 750 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 751 | identifier |= 0b0111; |
protongamer | 1:c022a879e21c | 752 | } |
protongamer | 1:c022a879e21c | 753 | |
protongamer | 1:c022a879e21c | 754 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 755 | identifier = 0b0111; |
protongamer | 1:c022a879e21c | 756 | state_val++; |
protongamer | 1:c022a879e21c | 757 | } |
protongamer | 1:c022a879e21c | 758 | |
protongamer | 1:c022a879e21c | 759 | break; |
protongamer | 1:c022a879e21c | 760 | |
protongamer | 1:c022a879e21c | 761 | case '8': |
protongamer | 1:c022a879e21c | 762 | pc.printf("8"); |
protongamer | 1:c022a879e21c | 763 | |
protongamer | 1:c022a879e21c | 764 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 765 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 766 | identifier |= 0b1000; |
protongamer | 1:c022a879e21c | 767 | } |
protongamer | 1:c022a879e21c | 768 | |
protongamer | 1:c022a879e21c | 769 | |
protongamer | 1:c022a879e21c | 770 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 771 | identifier = 0b1000; |
protongamer | 1:c022a879e21c | 772 | state_val++; |
protongamer | 1:c022a879e21c | 773 | } |
protongamer | 1:c022a879e21c | 774 | |
protongamer | 1:c022a879e21c | 775 | break; |
protongamer | 1:c022a879e21c | 776 | |
protongamer | 1:c022a879e21c | 777 | case '9': |
protongamer | 1:c022a879e21c | 778 | pc.printf("9"); |
protongamer | 1:c022a879e21c | 779 | |
protongamer | 1:c022a879e21c | 780 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 781 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 782 | identifier |= 0b1001; |
protongamer | 1:c022a879e21c | 783 | } |
protongamer | 1:c022a879e21c | 784 | |
protongamer | 1:c022a879e21c | 785 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 786 | identifier = 0b1001; |
protongamer | 1:c022a879e21c | 787 | state_val++; |
protongamer | 1:c022a879e21c | 788 | } |
protongamer | 1:c022a879e21c | 789 | |
protongamer | 1:c022a879e21c | 790 | break; |
protongamer | 1:c022a879e21c | 791 | |
protongamer | 1:c022a879e21c | 792 | case 'a': |
protongamer | 1:c022a879e21c | 793 | pc.printf("a"); |
protongamer | 1:c022a879e21c | 794 | |
protongamer | 1:c022a879e21c | 795 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 796 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 797 | identifier |= 0b1010; |
protongamer | 1:c022a879e21c | 798 | } |
protongamer | 1:c022a879e21c | 799 | |
protongamer | 1:c022a879e21c | 800 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 801 | identifier = 0b1010; |
protongamer | 1:c022a879e21c | 802 | state_val++; |
protongamer | 1:c022a879e21c | 803 | } |
protongamer | 1:c022a879e21c | 804 | |
protongamer | 1:c022a879e21c | 805 | break; |
protongamer | 1:c022a879e21c | 806 | |
protongamer | 1:c022a879e21c | 807 | case 'b': |
protongamer | 1:c022a879e21c | 808 | pc.printf("b"); |
protongamer | 1:c022a879e21c | 809 | |
protongamer | 1:c022a879e21c | 810 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 811 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 812 | identifier |= 0b1011; |
protongamer | 1:c022a879e21c | 813 | } |
protongamer | 1:c022a879e21c | 814 | |
protongamer | 1:c022a879e21c | 815 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 816 | identifier = 0b1011; |
protongamer | 1:c022a879e21c | 817 | state_val++; |
protongamer | 1:c022a879e21c | 818 | } |
protongamer | 1:c022a879e21c | 819 | |
protongamer | 1:c022a879e21c | 820 | break; |
protongamer | 1:c022a879e21c | 821 | |
protongamer | 1:c022a879e21c | 822 | case 'c': |
protongamer | 1:c022a879e21c | 823 | pc.printf("c"); |
protongamer | 1:c022a879e21c | 824 | |
protongamer | 1:c022a879e21c | 825 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 826 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 827 | identifier |= 0b1100; |
protongamer | 1:c022a879e21c | 828 | } |
protongamer | 1:c022a879e21c | 829 | |
protongamer | 1:c022a879e21c | 830 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 831 | identifier = 0b1100; |
protongamer | 1:c022a879e21c | 832 | state_val++; |
protongamer | 1:c022a879e21c | 833 | } |
protongamer | 1:c022a879e21c | 834 | |
protongamer | 1:c022a879e21c | 835 | break; |
protongamer | 1:c022a879e21c | 836 | |
protongamer | 1:c022a879e21c | 837 | case 'd': |
protongamer | 1:c022a879e21c | 838 | pc.printf("d"); |
protongamer | 1:c022a879e21c | 839 | |
protongamer | 1:c022a879e21c | 840 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 841 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 842 | identifier |= 0b1101; |
protongamer | 1:c022a879e21c | 843 | } |
protongamer | 1:c022a879e21c | 844 | |
protongamer | 1:c022a879e21c | 845 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 846 | identifier = 0b1101; |
protongamer | 1:c022a879e21c | 847 | state_val++; |
protongamer | 1:c022a879e21c | 848 | } |
protongamer | 1:c022a879e21c | 849 | |
protongamer | 1:c022a879e21c | 850 | break; |
protongamer | 1:c022a879e21c | 851 | |
protongamer | 1:c022a879e21c | 852 | case 'e': |
protongamer | 1:c022a879e21c | 853 | pc.printf("e"); |
protongamer | 1:c022a879e21c | 854 | |
protongamer | 1:c022a879e21c | 855 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 856 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 857 | identifier |= 0b1110; |
protongamer | 1:c022a879e21c | 858 | } |
protongamer | 1:c022a879e21c | 859 | |
protongamer | 1:c022a879e21c | 860 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 861 | identifier = 0b1110; |
protongamer | 1:c022a879e21c | 862 | state_val++; |
protongamer | 1:c022a879e21c | 863 | } |
protongamer | 1:c022a879e21c | 864 | |
protongamer | 1:c022a879e21c | 865 | break; |
protongamer | 1:c022a879e21c | 866 | |
protongamer | 1:c022a879e21c | 867 | case 'f': |
protongamer | 1:c022a879e21c | 868 | pc.printf("f"); |
protongamer | 1:c022a879e21c | 869 | |
protongamer | 1:c022a879e21c | 870 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 871 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 872 | identifier |= 0b1111; |
protongamer | 1:c022a879e21c | 873 | } |
protongamer | 1:c022a879e21c | 874 | |
protongamer | 1:c022a879e21c | 875 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 876 | identifier = 0b1111; |
protongamer | 1:c022a879e21c | 877 | state_val++; |
protongamer | 1:c022a879e21c | 878 | } |
protongamer | 1:c022a879e21c | 879 | |
protongamer | 1:c022a879e21c | 880 | break; |
protongamer | 1:c022a879e21c | 881 | |
protongamer | 1:c022a879e21c | 882 | case 'A': |
protongamer | 1:c022a879e21c | 883 | pc.printf("a"); |
protongamer | 1:c022a879e21c | 884 | |
protongamer | 1:c022a879e21c | 885 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 886 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 887 | identifier |= 0b1010; |
protongamer | 1:c022a879e21c | 888 | } |
protongamer | 1:c022a879e21c | 889 | |
protongamer | 1:c022a879e21c | 890 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 891 | identifier = 0b1010; |
protongamer | 1:c022a879e21c | 892 | state_val++; |
protongamer | 1:c022a879e21c | 893 | } |
protongamer | 1:c022a879e21c | 894 | |
protongamer | 1:c022a879e21c | 895 | break; |
protongamer | 1:c022a879e21c | 896 | |
protongamer | 1:c022a879e21c | 897 | case 'B': |
protongamer | 1:c022a879e21c | 898 | pc.printf("b"); |
protongamer | 1:c022a879e21c | 899 | |
protongamer | 1:c022a879e21c | 900 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 901 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 902 | identifier |= 0b1011; |
protongamer | 1:c022a879e21c | 903 | } |
protongamer | 1:c022a879e21c | 904 | |
protongamer | 1:c022a879e21c | 905 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 906 | identifier = 0b1011; |
protongamer | 1:c022a879e21c | 907 | state_val++; |
protongamer | 1:c022a879e21c | 908 | } |
protongamer | 1:c022a879e21c | 909 | |
protongamer | 1:c022a879e21c | 910 | break; |
protongamer | 1:c022a879e21c | 911 | |
protongamer | 1:c022a879e21c | 912 | case 'C': |
protongamer | 1:c022a879e21c | 913 | pc.printf("c"); |
protongamer | 1:c022a879e21c | 914 | |
protongamer | 1:c022a879e21c | 915 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 916 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 917 | identifier |= 0b1100; |
protongamer | 1:c022a879e21c | 918 | } |
protongamer | 1:c022a879e21c | 919 | |
protongamer | 1:c022a879e21c | 920 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 921 | identifier = 0b1100; |
protongamer | 1:c022a879e21c | 922 | state_val++; |
protongamer | 1:c022a879e21c | 923 | } |
protongamer | 1:c022a879e21c | 924 | |
protongamer | 1:c022a879e21c | 925 | break; |
protongamer | 1:c022a879e21c | 926 | |
protongamer | 1:c022a879e21c | 927 | case 'D': |
protongamer | 1:c022a879e21c | 928 | pc.printf("d"); |
protongamer | 1:c022a879e21c | 929 | |
protongamer | 1:c022a879e21c | 930 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 931 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 932 | identifier |= 0b1101; |
protongamer | 1:c022a879e21c | 933 | } |
protongamer | 1:c022a879e21c | 934 | |
protongamer | 1:c022a879e21c | 935 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 936 | identifier = 0b1101; |
protongamer | 1:c022a879e21c | 937 | state_val++; |
protongamer | 1:c022a879e21c | 938 | } |
protongamer | 1:c022a879e21c | 939 | |
protongamer | 1:c022a879e21c | 940 | break; |
protongamer | 1:c022a879e21c | 941 | |
protongamer | 1:c022a879e21c | 942 | case 'E': |
protongamer | 1:c022a879e21c | 943 | pc.printf("e"); |
protongamer | 1:c022a879e21c | 944 | |
protongamer | 1:c022a879e21c | 945 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 946 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 947 | identifier |= 0b1110; |
protongamer | 1:c022a879e21c | 948 | } |
protongamer | 1:c022a879e21c | 949 | |
protongamer | 1:c022a879e21c | 950 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 951 | identifier = 0b1110; |
protongamer | 1:c022a879e21c | 952 | state_val++; |
protongamer | 1:c022a879e21c | 953 | } |
protongamer | 1:c022a879e21c | 954 | |
protongamer | 1:c022a879e21c | 955 | break; |
protongamer | 1:c022a879e21c | 956 | |
protongamer | 1:c022a879e21c | 957 | case 'F': |
protongamer | 1:c022a879e21c | 958 | pc.printf("f"); |
protongamer | 1:c022a879e21c | 959 | |
protongamer | 1:c022a879e21c | 960 | if(state_val > 0){ |
protongamer | 1:c022a879e21c | 961 | identifier = identifier << 4; |
protongamer | 1:c022a879e21c | 962 | identifier |= 0b1111; |
protongamer | 1:c022a879e21c | 963 | } |
protongamer | 1:c022a879e21c | 964 | |
protongamer | 1:c022a879e21c | 965 | if(state_val == 0){ |
protongamer | 1:c022a879e21c | 966 | identifier = 0b1111; |
protongamer | 1:c022a879e21c | 967 | state_val++; |
protongamer | 1:c022a879e21c | 968 | } |
protongamer | 1:c022a879e21c | 969 | |
protongamer | 1:c022a879e21c | 970 | break; |
protongamer | 1:c022a879e21c | 971 | |
protongamer | 1:c022a879e21c | 972 | case '\r': //si au sérial nous avons le retour de ligne |
protongamer | 1:c022a879e21c | 973 | pc.printf("\r\n0x%x \r\n", identifier); |
protongamer | 1:c022a879e21c | 974 | wait(1.0); |
protongamer | 1:c022a879e21c | 975 | state = MENU_DISPLAY; |
protongamer | 1:c022a879e21c | 976 | state_val = 0; |
protongamer | 1:c022a879e21c | 977 | break; |
protongamer | 1:c022a879e21c | 978 | |
protongamer | 1:c022a879e21c | 979 | |
protongamer | 1:c022a879e21c | 980 | } |
protongamer | 1:c022a879e21c | 981 | |
protongamer | 1:c022a879e21c | 982 | |
protongamer | 1:c022a879e21c | 983 | break; |
protongamer | 1:c022a879e21c | 984 | |
protongamer | 1:c022a879e21c | 985 | |
protongamer | 1:c022a879e21c | 986 | |
protongamer | 1:c022a879e21c | 987 | |
protongamer | 1:c022a879e21c | 988 | } |
protongamer | 1:c022a879e21c | 989 | |
protongamer | 1:c022a879e21c | 990 | |
protongamer | 1:c022a879e21c | 991 | |
protongamer | 1:c022a879e21c | 992 | |
protongamer | 1:c022a879e21c | 993 | //wait(0.2); |
protongamer | 1:c022a879e21c | 994 | } |
protongamer | 1:c022a879e21c | 995 | } |