Kaynağa Gözat

Use only valid measurements for the moving average

main
Julian 1 yıl önce
ebeveyn
işleme
5cd4e3839d
1 değiştirilmiş dosya ile 12 ekleme ve 4 silme
  1. +12
    -4
      src/program.py

+ 12
- 4
src/program.py Dosyayı Görüntüle

@@ -173,7 +173,6 @@ def measure(sensor):
except RuntimeError:
fails += 1
time.sleep(0.01)
#print(len(data), fails)
if fails < (NUM_SAMPLES / 2):
mid_count = NUM_SAMPLES // 2
start_index = (NUM_SAMPLES - mid_count) // 2
@@ -184,7 +183,6 @@ def measure(sensor):
val = 0
else:
val = 0
#val = random.uniform(5.0, 40.0)
return val

def store_value(config, val, meas, lvl, date):
@@ -394,8 +392,18 @@ if __name__ == '__main__':
elif state == States.SHUTDOWN:
shutdown(epd)
else:
cl, cl_status = mavg_cl.add_value(measure(sensor_cl))
ph, ph_status = mavg_cl.add_value(measure(sensor_ph))
tmp = measure(sensor_cl)
if tmp != 0:
cl, cl_status = mavg_cl.add_value(tmp)
else:
cl = 0
cl_status = False
tmp = measure(sensor_ph)
if tmp != 0:
ph, ph_status = mavg_ph.add_value(tmp)
else:
ph = 0
ph_status = False
clp = get_percent(cl_leer, cl_voll, cl)
php = get_percent(ph_leer, ph_voll, ph)
display_site_main(epd, clp, php)


Yükleniyor…
İptal
Kaydet