PES 2 - Gruppe 1 / Mbed 2 deprecated Robocode_Random

Dependencies:   mbed

Fork of Robocode by PES 2 - Gruppe 1

Committer:
cittecla
Date:
Sun Mar 05 12:18:04 2017 +0000
Revision:
25:08ee4525155b
Parent:
24:6c2fec64f890
Child:
27:df11ab63cda4
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cittecla 18:a82994e67297 1 /**
cittecla 18:a82994e67297 2 * Main File of Robocode
cittecla 18:a82994e67297 3 * Handels parallel processing and interupts
cittecla 18:a82994e67297 4 * Version 0.0.1
cittecla 18:a82994e67297 5 * PES2 Gruppe 1
cittecla 18:a82994e67297 6 **/
cittecla 25:08ee4525155b 7 /*
cittecla 18:a82994e67297 8 #include "mbed.h"
cittecla 18:a82994e67297 9 #include "pathfinding.h"
cittecla 18:a82994e67297 10 #include "time.h"
cittecla 18:a82994e67297 11 #include "IRsensor.h"
cittecla 18:a82994e67297 12 #include "move.h"
cittecla 18:a82994e67297 13
cittecla 18:a82994e67297 14 //static double time_counter = 0.0f;
cittecla 18:a82994e67297 15 //static double deltatime = 0.0f;
cittecla 18:a82994e67297 16
cittecla 25:08ee4525155b 17 InterruptIn EncoderLeftA(PB_6);
cittecla 25:08ee4525155b 18 InterruptIn EncoderLeftB(PB_7);
cittecla 22:c8e187b9d949 19 InterruptIn EncoderRightA(PA_6);
cittecla 22:c8e187b9d949 20 InterruptIn EncoderRightB(PC_7);
cittecla 22:c8e187b9d949 21
cittecla 24:6c2fec64f890 22 DigitalIn encoder(PB_6);
cittecla 24:6c2fec64f890 23
cittecla 21:cb40c0533bc2 24 //DigitalOut led(LED1); // Board LED
cittecla 18:a82994e67297 25
cittecla 18:a82994e67297 26 //Perophery for distance sensors
cittecla 18:a82994e67297 27 AnalogIn distance(PB_1);
cittecla 18:a82994e67297 28 DigitalOut enable(PC_1);
cittecla 18:a82994e67297 29 DigitalOut bit0(PH_1);
cittecla 18:a82994e67297 30 DigitalOut bit1(PC_2);
cittecla 18:a82994e67297 31 DigitalOut bit2(PC_3);
cittecla 18:a82994e67297 32 IRSensor sensors[6];
cittecla 18:a82994e67297 33
cittecla 18:a82994e67297 34 //indicator leds arround robot
cittecla 18:a82994e67297 35 DigitalOut leds[] = { PC_8, PC_6, PB_12, PA_7, PC_0, PC_9 };
cittecla 25:08ee4525155b 36
cittecla 19:baa8371d55b4 37
cittecla 18:a82994e67297 38
cittecla 18:a82994e67297 39
cittecla 18:a82994e67297 40 static double time_counter = 0.0f;
cittecla 18:a82994e67297 41 static double timer0 = 0.0f;
cittecla 18:a82994e67297 42 bool status = 0;
cittecla 18:a82994e67297 43
cittecla 18:a82994e67297 44 int main()
cittecla 18:a82994e67297 45 {
cittecla 25:08ee4525155b 46 //__enable_irq();
cittecla 22:c8e187b9d949 47
cittecla 25:08ee4525155b 48 EncoderLeftA.rise(&highPulseDetectedL);
cittecla 25:08ee4525155b 49 EncoderLeftB.rise(&highPulseDetectedL);
cittecla 25:08ee4525155b 50 EncoderRightA.rise(&highPulseDetectedR); // wird erkannt
cittecla 25:08ee4525155b 51 EncoderRightB.rise(&highPulseDetectedR); // wird erkannt
cittecla 22:c8e187b9d949 52
cittecla 19:baa8371d55b4 53 move_init();
cittecla 24:6c2fec64f890 54 while(1) {
cittecla 25:08ee4525155b 55 sync_movement(false,true);
cittecla 25:08ee4525155b 56
cittecla 24:6c2fec64f890 57 }
cittecla 25:08ee4525155b 58 }
cittecla 25:08ee4525155b 59
cittecla 25:08ee4525155b 60 */
cittecla 25:08ee4525155b 61
cittecla 25:08ee4525155b 62 #include "mbed.h"
cittecla 25:08ee4525155b 63
cittecla 25:08ee4525155b 64 InterruptIn EncoderLeftA(PB_6);
cittecla 25:08ee4525155b 65 InterruptIn EncoderLeftB(PB_7);
cittecla 25:08ee4525155b 66 InterruptIn EncoderRightA(PA_6);
cittecla 25:08ee4525155b 67 InterruptIn EncoderRightB(PC_7);
cittecla 25:08ee4525155b 68
cittecla 25:08ee4525155b 69 int EncoderCounterLeft = 0;
cittecla 25:08ee4525155b 70 int EncoderCounterRight = 0;
cittecla 24:6c2fec64f890 71
cittecla 24:6c2fec64f890 72
cittecla 25:08ee4525155b 73
cittecla 25:08ee4525155b 74 void highPulseDetectedL()
cittecla 25:08ee4525155b 75 {
cittecla 25:08ee4525155b 76 EncoderCounterLeft += 1;
cittecla 25:08ee4525155b 77 }
cittecla 25:08ee4525155b 78
cittecla 25:08ee4525155b 79 void highPulseDetectedR()
cittecla 25:08ee4525155b 80 {
cittecla 25:08ee4525155b 81 EncoderCounterRight += 1;
cittecla 18:a82994e67297 82 }
cittecla 18:a82994e67297 83
cittecla 21:cb40c0533bc2 84
cittecla 25:08ee4525155b 85 int main()
cittecla 25:08ee4525155b 86 {
cittecla 25:08ee4525155b 87 EncoderLeftA.rise(&highPulseDetectedL); // wird nicht erkannt
cittecla 25:08ee4525155b 88 EncoderLeftB.rise(&highPulseDetectedL); // wird nicht erkannt
cittecla 25:08ee4525155b 89 EncoderRightA.rise(&highPulseDetectedR); // wird erkannt
cittecla 25:08ee4525155b 90 EncoderRightB.rise(&highPulseDetectedR); // wird erkannt
cittecla 22:c8e187b9d949 91
cittecla 25:08ee4525155b 92 while(1) {
cittecla 25:08ee4525155b 93 printf("left: %d || right: %d\r\n",EncoderCounterLeft,EncoderCounterRight);
cittecla 25:08ee4525155b 94 }
cittecla 25:08ee4525155b 95 }