diff --git a/Makefile b/Makefile index a145561..247122f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -build/index.html: src/routes/+page.svelte +build/index.html: src/routes/+page.svelte src/routes/control/+page.svelte npm run build .PHONY: run dev iframe diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index f310007..1897cfc 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -20,15 +20,26 @@ let score_midpoint_setpoint = 50; let coeff_p = 0.1; -function midpoint_timer(){ - // start with simple P control, maybe add ID later +let red_anim_x = 0; +let blue_anim_x = 0; +let offset = 0; + +function animation_timer(){ + // Midpoint calculation let delta = score_midpoint_setpoint - score_midpoint_current; score_midpoint_current = score_midpoint_current + (delta * coeff_p); + + let current = Date.now() + offset; + let x = (current % 1500) / 1500; + let percent = -((x - 1)*(x - 1)) + 1; + red_anim_x = score_midpoint_current * percent; + blue_anim_x = (100 - score_midpoint_current) * percent; } -let midpoint_timer_interval = setInterval(midpoint_timer, 10); +let animation_timer_interval = setInterval(animation_timer, 10); let event_name = "Mecha Mayhem 2024"; let match_name = "No Match"; +let match_name_show = "No Match"; let score_red = 0; let score_blue = 0; /** @type {string[]} */ @@ -40,7 +51,7 @@ let teams_blue = []; let timer_end = undefined; /** @type {undefined | ReturnType} */ let timer_next_tick = undefined; -let timer = "Scheduled"; +let timer = "Next Match"; /** @type {string} */ let display_state = "init"; @@ -50,7 +61,6 @@ let display_class = "side-display"; const client = mqtt.connect("ws://metznet.ca:8883"); -let offset = 0; client.on("connect", () => { console.log("connected to mqtt"); @@ -160,15 +170,18 @@ client.on("message", (topic, message) => { console.log(`Start_ms: ${start_ms}`); switch(state_obj.state) { case "Scheduled": - timer = "Scheduled"; + timer = match_name; + match_name_show = "Next Match"; break; case "Timeout": timer = "Timeout"; + match_name_show = match_name; break; case "Driver": timer_end = new Date(start_ms + 105000); tick_timer(); timer_next_tick = setInterval(tick_timer, 50); + match_name_show = match_name; break; case "DriverDone": timer = "0:00"; @@ -177,18 +190,23 @@ client.on("message", (topic, message) => { timer_end = new Date(start_ms + 15000); tick_timer(); timer_next_tick = setInterval(tick_timer, 50); + match_name_show = match_name; break; case "AutonomousDone": timer = "0:00"; + match_name_show = match_name; break; case "Abandoned": timer = "Abandoned"; + match_name_show = match_name; break; case "Stopped": timer = "Stopped"; + match_name_show = match_name; break; case "Scored": timer = "Scoring"; + match_name_show = match_name; break; } break; @@ -240,8 +258,10 @@ onMount(() => { {:else if (display_state == "timer")}

{event_name}

+

Red Alliance

+

Blue Alliance

{timer}

-

{match_name}

+

{match_name_show}

{score_red}

{score_blue}

@@ -257,10 +277,16 @@ onMount(() => { {/each}
+
+
-
+
+
+
+
+
-
+
{:else if (display_state == "pre-game")} @@ -273,6 +299,24 @@ onMount(() => { {:else if (display_state == "red-wins")} red-wins + {:else if (display_state == "blue-wins")} + blue-wins + {:else if (display_state == "rockies")} + rockies + {:else if (display_state == "prairies")} + prairies + {:else if (display_state == "ab-education")} + ab-education + {:else if (display_state == "ab-innovate")} + ab-innovate + {:else if (display_state == "tcenergy")} + tcenergy + {:else if (display_state == "tourismcalgary")} + tourismcalgary + {:else if (display_state == "encore")} + encore + {:else if (display_state == "westmech")} + westmech {:else} {/if} @@ -297,28 +341,48 @@ p { font-family: "apple2"; margin: 0px; color: white; - -webkit-text-stroke: 1px black; +} + +#score-midground { + z-index: 1; + position: relative; + top: -94%; + left: 1%; + height: 88%; + width: 98%; + background-color: black; + background-image: url("/gifs/wavy_background.gif"); } #score-background { z-index: 0; position: relative; - top: -100%; + top: -188%; display: flex; flex-direction: row; height: 100%; } -#score-background-blue { +#score-background-blue-1 { + height: 100%; + background-color: #0000ee; +} + +#score-background-blue-2 { height: 100%; background-color: blue; } -#score-background-red { +#score-background-red-1 { height: 100%; background-color: red; } +#score-background-red-2 { + height: 100%; + background-color: #ee0000; +} + .banner { display: flex; font-size: 5cqw; @@ -332,7 +396,7 @@ p { .teams { width: 100%; height: 100%; - font-size: 1.5cqw; + font-size: 2cqw; display: flex; justify-content: space-around; align-items: center; @@ -374,6 +438,16 @@ p { font-size: 2cqw; } +#blue-name { + grid-area: blue-top; + font-size: 1.5cqw; +} + +#red-name { + grid-area: red-top; + font-size: 1.5cqw; +} + #timer { grid-area: mid; font-size: 5cqw; @@ -382,7 +456,7 @@ p { div.score-grid { position: relative; background-color: transparent; - z-index: 1; + z-index: 2; width: 100%; height: 100%; display: grid; diff --git a/src/routes/control/+layout.js b/src/routes/control/+layout.js new file mode 100644 index 0000000..189f71e --- /dev/null +++ b/src/routes/control/+layout.js @@ -0,0 +1 @@ +export const prerender = true; diff --git a/src/routes/control/+page.svelte b/src/routes/control/+page.svelte new file mode 100644 index 0000000..6c5535e --- /dev/null +++ b/src/routes/control/+page.svelte @@ -0,0 +1,101 @@ + + +
+ {#each Object.entries(displays) as [name, info]} +
+

{name}

+ + +
+ {/each} +
diff --git a/static/gifs/ab_education.gif b/static/gifs/ab_education.gif new file mode 100644 index 0000000..fbf3e4f Binary files /dev/null and b/static/gifs/ab_education.gif differ diff --git a/static/gifs/ab_innovate.gif b/static/gifs/ab_innovate.gif new file mode 100644 index 0000000..420d4b4 Binary files /dev/null and b/static/gifs/ab_innovate.gif differ diff --git a/static/gifs/blue_win.gif b/static/gifs/blue_win.gif new file mode 100644 index 0000000..8f7d8b8 Binary files /dev/null and b/static/gifs/blue_win.gif differ diff --git a/static/gifs/canadaflag.gif b/static/gifs/canadaflag.gif new file mode 100644 index 0000000..ffdf1da Binary files /dev/null and b/static/gifs/canadaflag.gif differ diff --git a/static/gifs/encore.gif b/static/gifs/encore.gif new file mode 100644 index 0000000..4009f05 Binary files /dev/null and b/static/gifs/encore.gif differ diff --git a/static/gifs/prairies.gif b/static/gifs/prairies.gif new file mode 100644 index 0000000..ea9b9c7 Binary files /dev/null and b/static/gifs/prairies.gif differ diff --git a/static/gifs/rockies.gif b/static/gifs/rockies.gif new file mode 100644 index 0000000..3cc54cc Binary files /dev/null and b/static/gifs/rockies.gif differ diff --git a/static/gifs/tcenergy.gif b/static/gifs/tcenergy.gif new file mode 100644 index 0000000..3fbaa03 Binary files /dev/null and b/static/gifs/tcenergy.gif differ diff --git a/static/gifs/tourismcalgary.gif b/static/gifs/tourismcalgary.gif new file mode 100644 index 0000000..49f6a3b Binary files /dev/null and b/static/gifs/tourismcalgary.gif differ diff --git a/static/gifs/wavy_background.gif b/static/gifs/wavy_background.gif new file mode 100644 index 0000000..f332123 Binary files /dev/null and b/static/gifs/wavy_background.gif differ diff --git a/static/gifs/westmech.gif b/static/gifs/westmech.gif new file mode 100644 index 0000000..50281dd Binary files /dev/null and b/static/gifs/westmech.gif differ