Code:
#include "RP6ControlLib.h"
#include "RP6I2CmasterTWI.h"
#include "RP6Control_I2CMasterLib.h"
void Bumpers(void)
{
if (bumper_left || bumper_right)
{
moveAtSpeed(0,0);
if (bumper_left)
{
move(60,BWD,500,1);
rotate(60, RIGHT, 45, BLOCKING);
changeDirection(BWD);
moveAtSpeed(70,70);
}
else if (bumper_right)
{
move(60,BWD,500,1);
rotate(60, LEFT, 45, BLOCKING);
changeDirection(FWD);
moveAtSpeed(70,70);
}
else if (bumper_left && bumper_right)
{
move(60,BWD,500,1);
rotate(60, RIGHT, 180, BLOCKING);
changeDirection(FWD);
moveAtSpeed(70,70);
}
}
}
void watchDogRequest(void)
{
static uint8_t heartbeat2 = false;
if(heartbeat2)
{
clearPosLCD(0, 14, 1);
heartbeat2 = false;
}
else
{
setCursorPosLCD(0, 14);
writeStringLCD_P("#");
heartbeat2 = true;
}
}
void I2C_requestedDataReady(uint8_t dataRequestID)
{
checkRP6Status(dataRequestID);
}
void I2C_transmissionError(uint8_t errorState)
{
writeString_P("\nI2C ERROR - TWI STATE: 0x");
writeInteger(errorState, HEX);
writeChar('\n');
}
int main(void)
{
initRP6Control();
initLCD();
//ACS_setStateChangedHandler(ACS);
BUMPERS_setStateChangedHandler(Bumpers);
WDT_setRequestHandler(watchDogRequest);
I2CTWI_initMaster(100);
I2CTWI_setRequestedDataReadyHandler(I2C_requestedDataReady);
I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);
sound(180,80,25);
sound(220,80,25);
setLEDs(0b1111);
showScreenLCD("################", "################");
mSleep(500);
showScreenLCD("I2C-Master", "Movement...");
mSleep(1000);
setLEDs(0b0000);
I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_ACS_POWER, ACS_PWR_MED);
I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT, true);
I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT_RQ, true);
moveAtSpeed(70,70);
while(true)
{
task_checkINT0();
task_I2CTWI();
}
return 0;
}
er fährt vorwärts wie er soll, wenn ich nen bumper drücke hält er an und fährt n stück zurück. so und jetz kommt rotate und des macht er nicht. dann passiert nichts mehr
Lesezeichen