diff --git a/include/flow.h b/include/flow.h index 53f2e44..8fb95f8 100644 --- a/include/flow.h +++ b/include/flow.h @@ -19,8 +19,8 @@ void flow_setup() { attachInterrupt(FLOW_PIN, isr_flow, CHANGE); } -void flow_loop(unsigned long loopmillis, unsigned long pInterval) { - if (loopmillis>=last_read_flow+pInterval) { +void flow_loop(unsigned long loopmillis) { + if (loopmillis>=last_read_flow+READINTERVAL_FLOW) { flow=flow_counter*1000.0/(loopmillis-last_read_flow)/2.0; //Frequency [Hz] flow/=flow_factor; //[L/min] diff --git a/include/temperature.h b/include/temperature.h index a3355c9..392e3ad 100644 --- a/include/temperature.h +++ b/include/temperature.h @@ -78,12 +78,12 @@ void temperature_setup() { } -void temperature_loop(unsigned long loopmillis, unsigned long pInterval) { +void temperature_loop(unsigned long loopmillis) { static unsigned long last_read_ds18b20; static bool flag_requestTemperatures=false; - if (loopmillis>last_read_ds18b20+pInterval) { - if (loopmillis>last_read_ds18b20+pInterval*10) { //timeout + if (loopmillis>last_read_ds18b20+READINTERVAL_DS18B20) { + if (loopmillis>last_read_ds18b20+READINTERVAL_DS18B20*10) { //timeout Serial.println("Warn: Request Temperatures Timeout!"); flag_requestTemperatures=false; } diff --git a/include/waterlevel.h b/include/waterlevel.h index c34d792..323b3f4 100644 --- a/include/waterlevel.h +++ b/include/waterlevel.h @@ -24,10 +24,10 @@ void waterlevel_setup() { } } -void waterlevel_loop(unsigned long loopmillis, unsigned long pInterval) { +void waterlevel_loop(unsigned long loopmillis) { static unsigned long last_read_hcsr04; - if (loopmillis>=last_read_hcsr04+pInterval) { + if (loopmillis>=last_read_hcsr04+READINTERVAL_HCSR04) { last_read_hcsr04=loopmillis; float temperature=20.0; if (tempC_air!=DEVICE_DISCONNECTED_C && isValueArrayOKf(tempCmean_air,TEMPMEAN_SIZE,DEVICE_DISCONNECTED_C)) { //sensor ok diff --git a/src/main.cpp b/src/main.cpp index 9d85f6b..359a672 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,22 +51,24 @@ void loop() { flag_print=false; - ec_loop(loopmillis, EC_READ_INTERVAL); + ec_loop(loopmillis); - temperature_loop(loopmillis, READINTERVAL_DS18B20); + temperature_loop(loopmillis); - waterlevel_loop(loopmillis, READINTERVAL_HCSR04); + waterlevel_loop(loopmillis); - flow_loop(loopmillis, READINTERVAL_FLOW); + flow_loop(loopmillis); if (loopmillis>last_print+500) { last_print=loopmillis; + + /* if (isValueArrayOK(ec_array,EC_ARRAY_SIZE,0)) { Serial.print("EC="); @@ -75,6 +77,7 @@ void loop() { }else{ Serial.print("Waiting for EC"); } + if (isValueArrayOKf(tempCmean_reservoir,TEMPMEAN_SIZE,DEVICE_DISCONNECTED_C)){ Serial.print("\t Treservoir="); Serial.print(getMeanf(tempCmean_reservoir,TEMPMEAN_SIZE)); Serial.print("\t Tair="); Serial.print(getMeanf(tempCmean_air,TEMPMEAN_SIZE)); @@ -103,6 +106,7 @@ void loop() { Serial.println(); + */ }