Measure moving average of update rate

Okay, the threshoding is _kind_ of effective, and the version Glen
liked was actually doing it. In light of that, I've quantified the
update frequency a bit better.
This commit is contained in:
Aaron Fenyes 2019-09-28 23:01:11 +02:00
parent 963d68196e
commit c1b2b45dbd
1 changed files with 8 additions and 3 deletions

View File

@ -75,6 +75,7 @@ fullsat = 254
# --- control methods and diagnostics
updates = 0
new_updates = 0
def set_light_hsv(e, color, hit_bridge):
command = {
@ -85,14 +86,15 @@ def set_light_hsv(e, color, hit_bridge):
if hit_bridge:
if b != None:
b.set_light(edges[e].light_id, command)
global updates
updates += 1
global new_updates
new_updates += 1
rgb_color = tuple(255*c for c in colorsys.hsv_to_rgb(*color))
pygame.draw.aaline(screen, rgb_color, vertices[vertex_adj[e][0]], vertices[vertex_adj[e][1]])
# === interaction parameters ===
frame_rate = 24
ema_weight = 2/(frame_rate+1)
inductance = 0.001
@ -144,9 +146,12 @@ def set_wave_light(e, i):
def show_data(screen):
# light updates
global updates, new_updates
updates = ema_weight*new_updates + (1 - ema_weight)*updates
new_updates = 0
text = font.render('updates', True, (255, 255, 255))
screen.blit(text, (20, viewsize))
text = font.render(str(updates), True, (255, 255, 255))
text = font.render(str(updates / (1 - 0.9)), True, (255, 255, 255))
screen.blit(text, (120, viewsize))
# energy