From b52a94d2699fd35cd0f4af54a1f8b528c5a86944 Mon Sep 17 00:00:00 2001 From: Yves Ehrlich Date: Wed, 12 Feb 2020 19:08:21 +0100 Subject: [PATCH] Timeout fuer Temperaturmessung added --- Code/miniRobotRC/_main.ino | 2 +- Code/miniRobotRC/fahrsteuerung_old.ino | 4 ---- Code/miniRobotRC/temp.ino | 16 ++++++---------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Code/miniRobotRC/_main.ino b/Code/miniRobotRC/_main.ino index c845d9c..1b13811 100644 --- a/Code/miniRobotRC/_main.ino +++ b/Code/miniRobotRC/_main.ino @@ -23,7 +23,7 @@ void loop() { while(!tasten.getButtonCycle(buttonStart)) { manualDigitalDrive(); - //updateTemp(); + updateTemp(); String temp_str = "T: " + String(temperature) + " Grad C"; lcdLines[5] = temp_str; refreshLCD(); diff --git a/Code/miniRobotRC/fahrsteuerung_old.ino b/Code/miniRobotRC/fahrsteuerung_old.ino index 6df8ee4..2ddca74 100644 --- a/Code/miniRobotRC/fahrsteuerung_old.ino +++ b/Code/miniRobotRC/fahrsteuerung_old.ino @@ -1,7 +1,6 @@ void manualDigitalDrive() { bool goOn = false; - // while(!tasten.getButtonCycle(buttonL1)) { clearCommands(); if(!tasten.getAnyPressed()) { lcdLines[0] = "Warte..."; @@ -47,7 +46,4 @@ void manualDigitalDrive() { radio.write(&commands, sizeof(commands)); goOn = false; } - - // } - // tasten.clearAllButtons(); } diff --git a/Code/miniRobotRC/temp.ino b/Code/miniRobotRC/temp.ino index 0e645aa..b4fbf03 100644 --- a/Code/miniRobotRC/temp.ino +++ b/Code/miniRobotRC/temp.ino @@ -1,28 +1,24 @@ //Temperatur <3 void updateTemp(){ - unsigned long currentMillis = millis(); - if((unsigned long)(currentMillis - temp_time) >= 1000){ // jede Sekunden + if((unsigned long)(millis() - temp_time) >= 1000){ // jede Sekunden temp_time = millis(); bool err = false; clearCommands(); commands[0] = getTemp; - radio.write(&commands, sizeof(commands) /* && !err */); + radio.write(&commands, sizeof(commands)); unsigned long start = micros(); radio.startListening(); while(!radio.available()){ //Serial.println("nix"); - unsigned long currentMicros = micros(); + /* unsigned long currentMicros = micros(); if((unsigned long)(currentMicros - start) >= 1){ err = true; - } -/* - int16_t readData; - radio.read(&readData, sizeof(int16_t)); - temperature = readData; */ + } */ + if((millis() - temp_time) >= 10) break; } - if(!err){ + if(/* !err */ true){ int16_t readData; radio.read(&readData, sizeof(int16_t)); temperature = readData;