Browse Source

Timeout fuer Temperaturmessung added

master
Yves Ehrlich 4 years ago
parent
commit
b52a94d269
  1. 2
      Code/miniRobotRC/_main.ino
  2. 4
      Code/miniRobotRC/fahrsteuerung_old.ino
  3. 16
      Code/miniRobotRC/temp.ino

2
Code/miniRobotRC/_main.ino

@ -23,7 +23,7 @@ void loop() {
while(!tasten.getButtonCycle(buttonStart)) { while(!tasten.getButtonCycle(buttonStart)) {
manualDigitalDrive(); manualDigitalDrive();
//updateTemp();
updateTemp();
String temp_str = "T: " + String(temperature) + " Grad C"; String temp_str = "T: " + String(temperature) + " Grad C";
lcdLines[5] = temp_str; lcdLines[5] = temp_str;
refreshLCD(); refreshLCD();

4
Code/miniRobotRC/fahrsteuerung_old.ino

@ -1,7 +1,6 @@
void manualDigitalDrive() { void manualDigitalDrive() {
bool goOn = false; bool goOn = false;
// while(!tasten.getButtonCycle(buttonL1)) {
clearCommands(); clearCommands();
if(!tasten.getAnyPressed()) { if(!tasten.getAnyPressed()) {
lcdLines[0] = "Warte..."; lcdLines[0] = "Warte...";
@ -47,7 +46,4 @@ void manualDigitalDrive() {
radio.write(&commands, sizeof(commands)); radio.write(&commands, sizeof(commands));
goOn = false; goOn = false;
} }
// }
// tasten.clearAllButtons();
} }

16
Code/miniRobotRC/temp.ino

@ -1,28 +1,24 @@
//Temperatur <3 //Temperatur <3
void updateTemp(){ 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(); temp_time = millis();
bool err = false; bool err = false;
clearCommands(); clearCommands();
commands[0] = getTemp; commands[0] = getTemp;
radio.write(&commands, sizeof(commands) /* && !err */);
radio.write(&commands, sizeof(commands));
unsigned long start = micros(); unsigned long start = micros();
radio.startListening(); radio.startListening();
while(!radio.available()){ while(!radio.available()){
//Serial.println("nix"); //Serial.println("nix");
unsigned long currentMicros = micros();
/* unsigned long currentMicros = micros();
if((unsigned long)(currentMicros - start) >= 1){ if((unsigned long)(currentMicros - start) >= 1){
err = true; 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; int16_t readData;
radio.read(&readData, sizeof(int16_t)); radio.read(&readData, sizeof(int16_t));
temperature = readData; temperature = readData;

Loading…
Cancel
Save