diff --git a/Code/miniRobotRC/_main.ino b/Code/miniRobotRC/_main.ino index 5ae806e..9f869fa 100644 --- a/Code/miniRobotRC/_main.ino +++ b/Code/miniRobotRC/_main.ino @@ -12,104 +12,24 @@ void setup() { remoteControlInit(); funkInit(); Serial.begin(115200); - driveTimeout = 50; -/* - commands[0] = speedA; - commands[1] = 0xFF & (pwmA >> 8); - commands[2] = 0xFF & pwmA; - - commands[3] = speedB; - commands[4] = 0xFF & (pwmB >> 8); - commands[5] = 0xFF & pwmB; - - commands[6] = goDrive; + driveTimeout = 10; - commands[9] = timeToDrive; - commands[10] = 0xFF & (driveTimeout >> 8); - commands[11] = 0xFF & driveTimeout; */ clearCommands(); } void loop() { -//char text[32] = "Hello"; - // radio.write(&commands, sizeof(commands)); //lcdMenu(); - //delay(10000); - manualDrive(); + while(!tasten.getButtonCycle(buttonStart)) { + manualDigitalDrive(); + } + tasten.clearButton(buttonStart); + while(!tasten.getButtonCycle(buttonStart)) motorMapping(); + tasten.clearButton(buttonStart); + } void lcdMenu() { lcd.println("Platzhalter"); - - if(tasten.getButtonCycle(buttonUp)) { - - tasten.clearAllButtons(); - } - if(tasten.getButtonCycle(buttonDown)) { - tasten.clearAllButtons(); - } } - -void manualDrive() { - bool goOn = false; - while(!tasten.getButtonCycle(buttonStart)) { - clearCommands(); - if(!tasten.getAnyPressed()) { - lcd.clear(); - lcd.println("Warte..."); - } - if(tasten.checkButton(buttonB) || tasten.checkButton(buttonUp)) { - pwmA = -215; - pwmB = -255; - // tasten.clearButton(buttonB); - lcd.clear(); - lcd.println("geradeaus fahren"); - goOn =true; - } - if(tasten.checkButton(buttonC) || tasten.checkButton(buttonDown)) { - pwmA = 100; - pwmB = 255; - // tasten.clearButton(buttonC); - lcd.clear(); - lcd.println("rueckwaerts fahren"); - goOn =true; - } - if(tasten.checkButton(buttonRight)) { - pwmA = -100; //rechter Motor - pwmB = 100; - //tasten.clearButton(buttonRight); - lcd.clear(); - lcd.println("rechts lenken"); - goOn =true; - } - if(tasten.checkButton(buttonLeft)) { - pwmB = -100; - pwmA = 100; - //tasten.clearButton(buttonLeft); - lcd.clear(); - lcd.println("links lenken"); - goOn =true; - } - if(goOn) { - commands[0] = speedA; - commands[1] = highByte(pwmA); - commands[2] = lowByte(pwmA); - commands[3] = speedB; - commands[4] = highByte(pwmB); - commands[5] = lowByte(pwmB); - commands[6] = timeToDrive; - commands[7] = highByte(driveTimeout); - commands[8] = lowByte(driveTimeout); - commands[9] = goDrive; - radio.write(&commands, sizeof(commands)); - goOn = false; - } - } - tasten.clearAllButtons(); -} - -ISR(TIMER2_COMPA_vect) { // called by timer2 - tasten.checkButtons(); //Aufruf 1-mal pro Millisekunde -} diff --git a/Code/miniRobotRC/miniRobotRC.ino b/Code/miniRobotRC/miniRobotRC.ino index a73b7bc..0c622e6 100644 --- a/Code/miniRobotRC/miniRobotRC.ino +++ b/Code/miniRobotRC/miniRobotRC.ino @@ -1,4 +1,3 @@ -//template #include #include #include @@ -34,9 +33,7 @@ bool forwardA = true; bool forwardB = true; bool driveOn = false; uint16_t driveTimeout = 0; -//#define highByte(x) ( (x) >> (8) ) // keep upper 8 bits -//#define lowByte(x) ( (x) & (0xff) ) // keep lower 8 bits - +//Funk #include #include #include @@ -46,7 +43,7 @@ RF24 radio(A2, A3); // CE, CSN const byte address[6] = "00001"; uint8_t commands[32]; - +/* const String mainMenu[] = { "fahren", //0 "stoppen", //1 @@ -65,4 +62,4 @@ const String subMenuEntry0[] = { "Speed A", "Speed B", "Starten" -}; +}; */