always show avg power

old-commit-hash: d4f4809992c5c73e36ec1041445e6a11b2c68448
This commit is contained in:
Adeeb Shihadeh
2022-07-05 14:28:54 -07:00
parent 907c9f6815
commit fa29abe740

View File

@@ -27,8 +27,10 @@ if __name__ == "__main__":
while duration is None or time.monotonic() - start_time < duration:
fltr.update(z.read_power())
if rk.frame % rate == 0:
print(f"{fltr.x:.2f} W")
measurements.append(fltr.x)
t = datetime.timedelta(seconds=time.monotonic() - start_time)
avg = sum(measurements) / len(measurements)
print(f"Now: {fltr.x:.2f} W, Avg: {avg:.2f} W over {t}")
rk.keep_time()
except KeyboardInterrupt:
pass