|
@ -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; |
|
|
|
|
|
} */ |
|
|
|
|
|
if((millis() - temp_time) >= 10) break; |
|
|
} |
|
|
} |
|
|
/*
|
|
|
|
|
|
int16_t readData; |
|
|
|
|
|
radio.read(&readData, sizeof(int16_t)); |
|
|
|
|
|
temperature = readData; */ |
|
|
|
|
|
} |
|
|
|
|
|
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; |
|
|