diff --git a/Code/Joystick/Joystick.ino b/Code/Joystick/Joystick.ino deleted file mode 100644 index dc68c00..0000000 --- a/Code/Joystick/Joystick.ino +++ /dev/null @@ -1,42 +0,0 @@ -#include -//Informationen Joystick -Joystick *joystick; -const uint16_t xAxisPin = 5; -const uint16_t yAxisPin = 4; -const int16_t lowestJoystickValue = 0; -const int16_t highestJoystickValue = 511; -const int16_t spaceing = 50; - -//Informationen linker Motor -Motor *left; -const int16_t lowestPWMValueLeftMotor = -255; -const int16_t highestPWMValueLeftMotor = 255; - -//Informationen rechter Motor -Motor *right; -const int16_t lowestPWMValueRightMotor = -255; -const int16_t highestPWMValueRightMotor = 255; - - -Steuerung *steuerung; - -void setup() { - joystick = new Joystick(xAxisPin, yAxisPin, lowestJoystickValue, highestJoystickValue, spaceing); - left = new Motor(lowestPWMValueLeftMotor, highestPWMValueLeftMotor); - right = new Motor(lowestPWMValueRightMotor, highestPWMValueRightMotor); - steuerung = new Steuerung(joystick, left, right); - Serial.begin(9600); -} - -void loop() { - steuerung -> updateValues(); - - //DEBUG - Serial.print("Left motor PWMValue: "); - Serial.println(left -> PWMValue); - Serial.print("Right motor PWMValue: "); - Serial.println(right -> PWMValue); - //SendValues - delay(500); - -} diff --git a/Code/Joystick/JoystickSteuerung.ino b/Code/Joystick/JoystickSteuerung.ino new file mode 100644 index 0000000..e3d4db9 --- /dev/null +++ b/Code/Joystick/JoystickSteuerung.ino @@ -0,0 +1,45 @@ +#include +//Informationen Joystick + +Joystick *joystick; +const uint16_t xAxisPin = 5; +const uint16_t yAxisPin = 4; +const int16_t lowestJoystickValue = 0; +const int16_t highestJoystickValue = 511; +const int16_t spaceing = 50; + +//Informationen linker Motor +Motor *left; +const int16_t lowestPWMValueLeftMotor = -255; +const int16_t highestPWMValueLeftMotor = 255; + +//Informationen rechter Motor +Motor *right; +const int16_t lowestPWMValueRightMotor = -255; +const int16_t highestPWMValueRightMotor = 255; + + +Steuerung *steuerung; + +void joystickInit() { + + joystick = new Joystick(xAxisPin, yAxisPin, lowestJoystickValue, highestJoystickValue, spaceing); + left = new Motor(lowestPWMValueLeftMotor, highestPWMValueLeftMotor); + right = new Motor(lowestPWMValueRightMotor, highestPWMValueRightMotor); + steuerung = new Steuerung(joystick, left, right); + //Serial.begin(9600); + } + + void joystickSteuerung() { + //Only updates if joystick is moved + steuerung -> updateValues(); + + //DEBUG + Serial.print("Left motor PWMValue: "); + Serial.println(left -> PWMValue); + Serial.print("Right motor PWMValue: "); + Serial.println(right -> PWMValue); + + //SendValues + send(); + } diff --git a/Code/miniRobotRC/JoystickSteuerung.ino b/Code/miniRobotRC/JoystickSteuerung.ino new file mode 100644 index 0000000..dc88ca9 --- /dev/null +++ b/Code/miniRobotRC/JoystickSteuerung.ino @@ -0,0 +1,59 @@ +#include +//Informationen Joystick + +Joystick *joystick; +const uint16_t xAxisPin = 5; +const uint16_t yAxisPin = 4; +const int16_t lowestJoystickValue = 0; +const int16_t highestJoystickValue = 511; +const int16_t spaceing = 50; + +//Informationen linker Motor +Motor *left; +const int16_t lowestPWMValueLeftMotor = -255; +const int16_t highestPWMValueLeftMotor = 255; + +//Informationen rechter Motor +Motor *right; +const int16_t lowestPWMValueRightMotor = -255; +const int16_t highestPWMValueRightMotor = 255; + + +Steuerung *steuerung; + +void joystickInit() { + + joystick = new Joystick(xAxisPin, yAxisPin, lowestJoystickValue, highestJoystickValue, spaceing); + left = new Motor(lowestPWMValueLeftMotor, highestPWMValueLeftMotor); + right = new Motor(lowestPWMValueRightMotor, highestPWMValueRightMotor); + steuerung = new Steuerung(joystick, left, right); + //Serial.begin(9600); + } + + void joystickSteuerung() { + //Only updates if joystick is moved + steuerung -> updateValues(); + + //DEBUG + Serial.print("Left motor PWMValue: "); + Serial.println(left -> PWMValue); + Serial.print("Right motor PWMValue: "); + Serial.println(right -> PWMValue); + + //SendValues + send(); + } + + void send(){ + commands[0] = speedA; + commands[1] = highByte(left -> PWMValue); + commands[2] = lowByte(left -> PWMValue); + commands[3] = speedB; + commands[4] = highByte(right -> PWMValue); + commands[5] = lowByte(right -> PWMValue); + commands[6] = timeToDrive; + commands[7] = highByte(driveTimeout); + commands[8] = lowByte(driveTimeout); + commands[9] = goDrive; + radio.write(&commands, sizeof(commands)); + } diff --git a/Code/miniRobotRC/_main.ino b/Code/miniRobotRC/_main.ino index 9f869fa..0311454 100644 --- a/Code/miniRobotRC/_main.ino +++ b/Code/miniRobotRC/_main.ino @@ -13,17 +13,23 @@ void setup() { funkInit(); Serial.begin(115200); driveTimeout = 10; - + joystickInit(); //TODO clearCommands(); } void loop() { //lcdMenu(); - while(!tasten.getButtonCycle(buttonStart)) { + /*while(!tasten.getButtonCycle(buttonStart)) { manualDigitalDrive(); - } + } */ + tasten.clearButton(buttonStart); + while(!tasten.getButtonCycle(buttonStart)){ + motorMapping(); + } tasten.clearButton(buttonStart); - while(!tasten.getButtonCycle(buttonStart)) motorMapping(); + while(!tasten.getButtonCycle(buttonStart)){ + joystickSteuerung(); //TODO () + } tasten.clearButton(buttonStart); } diff --git a/Code/miniRobotRC/fahrsteuerung.ino b/Code/miniRobotRC/fahrsteuerung_old.ino similarity index 97% rename from Code/miniRobotRC/fahrsteuerung.ino rename to Code/miniRobotRC/fahrsteuerung_old.ino index 915b3ba..dd797fb 100644 --- a/Code/miniRobotRC/fahrsteuerung.ino +++ b/Code/miniRobotRC/fahrsteuerung_old.ino @@ -1,4 +1,4 @@ -void manualDigitalDrive() { +/*void manualDigitalDrive() { bool goOn = false; // while(!tasten.getButtonCycle(buttonL1)) { clearCommands(); @@ -50,4 +50,4 @@ void manualDigitalDrive() { } // } // tasten.clearAllButtons(); -} +}*/