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)) {
manualDigitalDrive();
//updateTemp();
updateTemp();
String temp_str = "T: " + String(temperature) + " Grad C";
lcdLines[5] = temp_str;
refreshLCD();

4
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();
}

16
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;

Loading…
Cancel
Save