diff --git a/interactions.py b/interactions.py index cc5d9d8..ddaa5ce 100644 --- a/interactions.py +++ b/interactions.py @@ -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