diff --git a/.~lock.ideen_mechanik_und_elektronik.odt# b/.~lock.ideen_mechanik_und_elektronik.odt# index affc95a..0e6d32f 100644 --- a/.~lock.ideen_mechanik_und_elektronik.odt# +++ b/.~lock.ideen_mechanik_und_elektronik.odt# @@ -1 +1 @@ -,yves,yves-UB,05.02.2020 13:15,file:///home/yves/.config/libreoffice/4; \ No newline at end of file +,yves,yves-UB,05.02.2020 13:51,file:///home/yves/.config/libreoffice/4; \ No newline at end of file diff --git a/Code/miniRobotRC/fahrsteuerung_old.ino b/Code/miniRobotRC/fahrsteuerung_old.ino index 915b3ba..ec64ad8 100644 --- a/Code/miniRobotRC/fahrsteuerung_old.ino +++ b/Code/miniRobotRC/fahrsteuerung_old.ino @@ -3,35 +3,30 @@ void manualDigitalDrive() { // while(!tasten.getButtonCycle(buttonL1)) { clearCommands(); if(!tasten.getAnyPressed()) { - lcd.clear(); - lcd.println("Warte..."); + lcdLines[0] = "Warte..."; } if(tasten.checkButton(buttonB) || tasten.checkButton(buttonUp)) { pwmA = -215; pwmB = -255; - lcd.clear(); - lcd.println("geradeaus fahren"); + lcdLines[0] = "geradeaus fahren"; goOn =true; } if(tasten.checkButton(buttonC) || tasten.checkButton(buttonDown)) { pwmA = 100; pwmB = 255; - lcd.clear(); - lcd.println("rueckwaerts fahren"); + lcdLines[0] = "rueckwaerts fahren"; goOn =true; } if(tasten.checkButton(buttonRight)) { pwmA = -100; //rechter Motor pwmB = 100; - lcd.clear(); - lcd.println("rechts lenken"); + lcdLines[0] = "rechts lenken"; goOn =true; } if(tasten.checkButton(buttonLeft)) { pwmB = -100; pwmA = 100; - lcd.clear(); - lcd.println("links lenken"); + lcdLines[0] = "links lenken"; goOn =true; } if(goOn) { diff --git a/Code/miniRobotRC/interruptRoutinen.ino b/Code/miniRobotRC/interruptRoutinen.ino index cce5cf5..09ca807 100644 --- a/Code/miniRobotRC/interruptRoutinen.ino +++ b/Code/miniRobotRC/interruptRoutinen.ino @@ -3,6 +3,11 @@ ISR(TIMER2_COMPA_vect) { tasten.checkButtons(); renderTime++; if(renderTime >= renderTimeout) { + lcd.clear(); + for(uint8_t i = 0; i < sizeof(lcdLines); i++) { + lcd.gotoXY(0, i); + lcd.print(lcdLines[i]); + } lcd.renderAll(); renderTime = 0; } diff --git a/Code/miniRobotRC/joystick.ino b/Code/miniRobotRC/joystick.ino index 70d8392..c2329e2 100644 --- a/Code/miniRobotRC/joystick.ino +++ b/Code/miniRobotRC/joystick.ino @@ -10,28 +10,8 @@ volatile int16_t yValue = 0; volatile int16_t leftPWM = 0; volatile int16_t rightPWM = 0; -const int16_t deadZone = 10; -/* -void setup() { - Serial.begin(115200); -} - -void loop() { - koordinaten(analogRead(xPin), analogRead(yPin)); - motorPWM(); - Serial.print("X: "); - Serial.println(xValue); - Serial.print("Y: "); - Serial.println(yValue); - Serial.print("links: "); - Serial.println(leftPWM); - Serial.print("rechts: "); - Serial.println(rightPWM); - - delay(200); +const int16_t deadZone = 40; -} -*/ void motorMapping() { static long temp = millis(); koordinaten(analogRead(xPin), analogRead(yPin)); @@ -40,12 +20,14 @@ void motorMapping() { pwmB = map(leftPWM, -255,255,leftMin,leftMax); pwmA = map(rightPWM, -255,255,rightMin,rightMax); if((millis() - temp) > 100) { - lcd.clear(); - lcd.println("Links: "); - lcd.println(pwmB); - lcd.gotoXY(0,2); - lcd.println("Rechts: "); - lcd.println(pwmA); + // lcd.clear(); + // lcd.println("Links: "); + lcdLines[0] = "Links: " + String(pwmB, DEC); + // lcd.println(pwmB); + // lcd.gotoXY(0,2); + // lcd.println("Rechts: "); + lcdLines[0] = "Rechts: " + String(pwmA, DEC); + // lcd.println(pwmA); } senden(); diff --git a/Code/miniRobotRC/miniRobotRC.ino b/Code/miniRobotRC/miniRobotRC.ino index 898b88b..038a595 100644 --- a/Code/miniRobotRC/miniRobotRC.ino +++ b/Code/miniRobotRC/miniRobotRC.ino @@ -4,7 +4,7 @@ #define CLR_BIT(p,n) ((p) &= ~((1) << (n))) #define SET_BIT(p,n) ((p) |= (1 << (n))) - +//Pinzuordnungen #define BL 10 //backlight, Hintergrundbeleuchtung LCD #define SD_CARD_CS 2 //D2 ist Chip Enable #define BAT_VOLTAGE A7 //Akkuspannung an A7 @@ -17,7 +17,8 @@ volatile myInterrupts pwmBL; volatile shiftRegButton tasten; //LCD uint8_t renderTime = 0; -#define renderTimeout 100 +#define renderTimeout 100 //es wird alle 100ms gerendert +String lcdLines[6]; //Strings welche alle 100ms ausgegeben werden //Kommandos #define nothing 9 //reset/nichts tun @@ -31,15 +32,15 @@ uint8_t renderTime = 0; #define timeToDrive 8 //Zeitdauer des fahrens #define getDistance 10 //Abstand zu Objekten -int pwmA = 0; -int pwmB = 0; +int16_t pwmA = 0; +int16_t pwmB = 0; bool forwardA = true; bool forwardB = true; bool driveOn = false; uint16_t driveTimeout = 0; -int distance; -int temperature; +int16_t distance; +int16_t temperature; //Funk #include @@ -51,23 +52,3 @@ RF24 radio(A2, A3); // CE, CSN const byte address[6] = "00001"; uint8_t commands[32]; -/* -const String mainMenu[] = { - "fahren", //0 - "stoppen", //1 - "manuell fahren", //2 - "", //3 - "", //4 - "", //5 - "", //6 - "", //7 - "", //8 - "" //9 -}; - -const String subMenuEntry0[] = { - "Zeitdauer", - "Speed A", - "Speed B", - "Starten" -}; */ diff --git a/ideen_mechanik_und_elektronik.odt b/ideen_mechanik_und_elektronik.odt index dd56f82..7690502 100644 Binary files a/ideen_mechanik_und_elektronik.odt and b/ideen_mechanik_und_elektronik.odt differ