PES 2 - Gruppe 1 / Mbed 2 deprecated Robocode_Random

Dependencies:   mbed

Fork of Robocode by PES 2 - Gruppe 1

source/main.cpp

Committer:
cittecla
Date:
2017-03-05
Revision:
25:08ee4525155b
Parent:
24:6c2fec64f890
Child:
27:df11ab63cda4

File content as of revision 25:08ee4525155b:

/**
 *  Main File of Robocode
 *  Handels parallel processing and interupts
 *  Version 0.0.1
 *  PES2 Gruppe 1
 **/
/*
#include "mbed.h"
#include "pathfinding.h"
#include "time.h"
#include "IRsensor.h"
#include "move.h"

//static double time_counter = 0.0f;
//static double deltatime = 0.0f;

InterruptIn EncoderLeftA(PB_6);
InterruptIn EncoderLeftB(PB_7);
InterruptIn EncoderRightA(PA_6);
InterruptIn EncoderRightB(PC_7);

DigitalIn encoder(PB_6);

//DigitalOut led(LED1); // Board LED

//Perophery for distance sensors
AnalogIn distance(PB_1);
DigitalOut enable(PC_1);
DigitalOut bit0(PH_1);
DigitalOut bit1(PC_2);
DigitalOut bit2(PC_3);
IRSensor sensors[6];

//indicator leds arround robot
DigitalOut leds[] = { PC_8, PC_6, PB_12, PA_7, PC_0, PC_9 };




static double time_counter = 0.0f;
static double timer0 = 0.0f;
bool status = 0;

int main()
{
    //__enable_irq();

    EncoderLeftA.rise(&highPulseDetectedL);
    EncoderLeftB.rise(&highPulseDetectedL);
    EncoderRightA.rise(&highPulseDetectedR); // wird erkannt
    EncoderRightB.rise(&highPulseDetectedR); // wird erkannt

    move_init();
    while(1) {
        sync_movement(false,true);
        
    }
}

*/

#include "mbed.h"

InterruptIn EncoderLeftA(PB_6);
InterruptIn EncoderLeftB(PB_7);
InterruptIn EncoderRightA(PA_6);
InterruptIn EncoderRightB(PC_7);

int EncoderCounterLeft = 0;
int EncoderCounterRight = 0;



void highPulseDetectedL()
{
    EncoderCounterLeft += 1;
}

void highPulseDetectedR()
{
    EncoderCounterRight += 1;
}


int main()
{
    EncoderLeftA.rise(&highPulseDetectedL); // wird nicht erkannt
    EncoderLeftB.rise(&highPulseDetectedL); // wird nicht erkannt
    EncoderRightA.rise(&highPulseDetectedR); // wird erkannt
    EncoderRightB.rise(&highPulseDetectedR); // wird erkannt

    while(1) {
        printf("left: %d || right: %d\r\n",EncoderCounterLeft,EncoderCounterRight);
    }
}