From 968dc11fdd1a3fb3abd818a5805b8f358b177f22 Mon Sep 17 00:00:00 2001 From: Yves Ehrlich Date: Mon, 10 Feb 2020 18:17:14 +0100 Subject: [PATCH] diverses --- .~lock.ideen_mechanik_und_elektronik.odt# | 1 - Code/miniRobotRC/JoystickSteuerung.ino | 2 +- Code/miniRobotRC/_main.ino | 26 +++++++++++++++++++---- Code/miniRobotRC/fahrsteuerung_old.ino | 3 +-- Code/miniRobotRC/interruptRoutinen.ino | 4 ++-- Code/miniRobotRC/miniRobotRC.ino | 3 ++- Code/miniRobotRC/temp.ino | 10 ++++++--- 7 files changed, 35 insertions(+), 14 deletions(-) delete mode 100644 .~lock.ideen_mechanik_und_elektronik.odt# diff --git a/.~lock.ideen_mechanik_und_elektronik.odt# b/.~lock.ideen_mechanik_und_elektronik.odt# deleted file mode 100644 index 0e6d32f..0000000 --- a/.~lock.ideen_mechanik_und_elektronik.odt# +++ /dev/null @@ -1 +0,0 @@ -,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/JoystickSteuerung.ino b/Code/miniRobotRC/JoystickSteuerung.ino index 36b917b..a001ea3 100644 --- a/Code/miniRobotRC/JoystickSteuerung.ino +++ b/Code/miniRobotRC/JoystickSteuerung.ino @@ -60,7 +60,7 @@ void joystickInit() { lcd.print("RightPWM: "); lcd.print(right -> PWMValue);*/ lcdLines[0] = "Links: " + String(left -> PWMValue, DEC); - lcdLines[1] = "Links: " + String(right -> PWMValue, DEC); + lcdLines[1] = "Rechts: " + String(right -> PWMValue, DEC); } void send(){ diff --git a/Code/miniRobotRC/_main.ino b/Code/miniRobotRC/_main.ino index 54c5548..6fc4f7b 100644 --- a/Code/miniRobotRC/_main.ino +++ b/Code/miniRobotRC/_main.ino @@ -15,7 +15,7 @@ void setup() { driveTimeout = 10; joystickInit(); //TODO clearCommands(); - + renderTime = millis(); } void loop() { @@ -23,17 +23,22 @@ void loop() { while(!tasten.getButtonCycle(buttonStart)) { manualDigitalDrive(); - updateTemp(); + //updateTemp(); + String temp_str = "T: " + String(temperature) + " Grad C"; + lcdLines[5] = temp_str; + refreshLCD(); } tasten.clearButton(buttonStart); while(!tasten.getButtonCycle(buttonStart)){ motorMapping(); - updateTemp(); + //updateTemp(); + refreshLCD(); } tasten.clearButton(buttonStart); while(!tasten.getButtonCycle(buttonStart)){ joystickSteuerung(); //TODO () - updateTemp(); + //updateTemp(); + refreshLCD(); } tasten.clearButton(buttonStart); } @@ -43,3 +48,16 @@ void lcdMenu() { } + +void refreshLCD() { + + if((millis() - renderTime) >= renderTimeout) { + lcd.clear(); + for(uint8_t i = 0; i < sizeof(lcdLines); i++) { + lcd.gotoXY(0, i); + lcd.print(lcdLines[i]); + } + lcd.renderAll(); + renderTime = millis(); + } +} diff --git a/Code/miniRobotRC/fahrsteuerung_old.ino b/Code/miniRobotRC/fahrsteuerung_old.ino index 3ba18ee..6df8ee4 100644 --- a/Code/miniRobotRC/fahrsteuerung_old.ino +++ b/Code/miniRobotRC/fahrsteuerung_old.ino @@ -1,12 +1,11 @@ void manualDigitalDrive() { bool goOn = false; - String temp_str = "T: " + String(temperature) + " Grad C"; - lcdLines[5] = temp_str; // while(!tasten.getButtonCycle(buttonL1)) { clearCommands(); if(!tasten.getAnyPressed()) { lcdLines[0] = "Warte..."; + lcdLines[1] = ""; } if(tasten.checkButton(buttonB) || tasten.checkButton(buttonUp)) { diff --git a/Code/miniRobotRC/interruptRoutinen.ino b/Code/miniRobotRC/interruptRoutinen.ino index 09ca807..7ae1637 100644 --- a/Code/miniRobotRC/interruptRoutinen.ino +++ b/Code/miniRobotRC/interruptRoutinen.ino @@ -1,7 +1,7 @@ //HIER KOMMT ALLES REIN WAS 1 MAL PRO ms AUFGERUFEN WERDEN SOLL!!! ISR(TIMER2_COMPA_vect) { tasten.checkButtons(); - renderTime++; + /*renderTime++; if(renderTime >= renderTimeout) { lcd.clear(); for(uint8_t i = 0; i < sizeof(lcdLines); i++) { @@ -10,6 +10,6 @@ ISR(TIMER2_COMPA_vect) { } lcd.renderAll(); renderTime = 0; - } + } */ } //ALLE anderen ISR kommen HIER drunter!!! diff --git a/Code/miniRobotRC/miniRobotRC.ino b/Code/miniRobotRC/miniRobotRC.ino index f93a12c..a4a6c07 100644 --- a/Code/miniRobotRC/miniRobotRC.ino +++ b/Code/miniRobotRC/miniRobotRC.ino @@ -16,7 +16,7 @@ volatile myInterrupts Timer2; volatile myInterrupts pwmBL; volatile shiftRegButton tasten; //LCD -uint8_t renderTime = 0; +/*uint8_t */long renderTime = 0; #define renderTimeout 100 //es wird alle 100ms gerendert String lcdLines[6]; //Strings welche alle 100ms ausgegeben werden @@ -42,6 +42,7 @@ uint16_t driveTimeout = 0; uint8_t distance; uint8_t temperature = 0; + unsigned long temp_time = millis(); //Funk diff --git a/Code/miniRobotRC/temp.ino b/Code/miniRobotRC/temp.ino index bd8485b..0e645aa 100644 --- a/Code/miniRobotRC/temp.ino +++ b/Code/miniRobotRC/temp.ino @@ -7,7 +7,7 @@ clearCommands(); commands[0] = getTemp; - radio.write(&commands, sizeof(commands) && !err); + radio.write(&commands, sizeof(commands) /* && !err */); unsigned long start = micros(); radio.startListening(); while(!radio.available()){ @@ -16,13 +16,17 @@ if((unsigned long)(currentMicros - start) >= 1){ err = true; - } + } +/* + int16_t readData; + radio.read(&readData, sizeof(int16_t)); + temperature = readData; */ } if(!err){ int16_t readData; radio.read(&readData, sizeof(int16_t)); temperature = readData; - } + } radio.stopListening(); clearCommands(); }