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

View File

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