From fd7b294410f8325d13d8f59e6e6a90316caa796d Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sat, 6 Jan 2024 13:39:10 -0700 Subject: [PATCH] Added apple2 font, and animated score background --- src/routes/+page.svelte | 61 ++++++++++++++++++++++++++++++++++++++-- static/apple2.woff2 | Bin 0 -> 49896 bytes 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 static/apple2.woff2 diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index c4ac2d7..db8c917 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -13,6 +13,20 @@ let display_state_topic; /** @type {string} */ let display_class_topic; +/** @type {number} */ +let score_midpoint_current = 50; +/** @type {number} */ +let score_midpoint_setpoint = 50; + +let coeff_p = 0.1; + +function midpoint_timer(){ + // start with simple P control, maybe add ID later + let delta = score_midpoint_setpoint - score_midpoint_current; + score_midpoint_current = score_midpoint_current + (delta * coeff_p); +} +let midpoint_timer_interval = setInterval(midpoint_timer, 10); + let event_name = "Mecha Mayhem 2024"; let match_name = "No Match"; let score_red = 0; @@ -24,7 +38,7 @@ let teams_blue = []; /** @type {undefined | Date} */ let timer_end = undefined; -/** @type {undefined | ReturnType} */ +/** @type {undefined | ReturnType} */ let timer_next_tick = undefined; let timer = "Scheduled"; @@ -91,6 +105,7 @@ function tick_timer() { if(timer_end === undefined) { stop_timer(); return + } const now = new Date() @@ -157,6 +172,7 @@ client.on("message", (topic, message) => { const score_obj = JSON.parse(message_str); score_red = score_obj.red.total; score_blue = score_obj.blue.total; + score_midpoint_setpoint = ((score_red + 1) / (score_red + score_blue + 2)) * 100; break; case display_state_topic: display_state = message_str; @@ -215,7 +231,15 @@ onMount(() => { {/each} +
+
+
+
+
+
{:else if (display_state == "init")} + + {:else if (display_state == "event-name")} {:else} @@ -223,6 +247,11 @@ onMount(() => {