From 3afcd927c04b57c094a821eb961d33117aca63e4 Mon Sep 17 00:00:00 2001 From: Thijmen <129296225+ThijmenKetelaar@users.noreply.github.com> Date: Fri, 6 Dec 2024 12:44:27 +0100 Subject: [PATCH] base micropthon environment --- src/assets/toolbox/leaphy.xml | 558 ------------------ src/assets/translations/en.json | 11 +- src/assets/translations/nl.json | 11 +- src/lib/components/core/header/Header.svelte | 34 +- .../core/popups/popups/Uploader.svelte | 10 - src/lib/components/workspace/Workspace.svelte | 2 +- .../components/workspace/blocks/Blocks.svelte | 6 +- .../components/workspace/python/Python.svelte | 282 ++++----- .../pythonblocks/pythonBlocks.svelte | 119 ++++ src/lib/domain/blockly/toolbox.ts | 28 + src/lib/domain/robots.ts | 8 + src/lib/state/popup.svelte.ts | 18 +- src/lib/state/workspace.svelte.ts | 18 +- 13 files changed, 345 insertions(+), 760 deletions(-) delete mode 100644 src/assets/toolbox/leaphy.xml create mode 100644 src/lib/components/workspace/pythonblocks/pythonBlocks.svelte diff --git a/src/assets/toolbox/leaphy.xml b/src/assets/toolbox/leaphy.xml deleted file mode 100644 index 1bc82a3..0000000 --- a/src/assets/toolbox/leaphy.xml +++ /dev/null @@ -1,558 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - 0 - - - - - 0 - - - - - - - - - 100 - - - - - - - - - - 100 - - - - - - - - - - 100 - - - - - - - - - - - - - - - 100 - - - - - - - - - - - - - - - 440 - - - - - - - 100 - - - - - - - - - text - - - - - - - - text - - - - - - 0 - - - - - - - - - - - - - 0 - - - - - - - - - - 90 - - - - - - - - - - - - 0 - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - 0 - - - - - - - 0 - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - 0 - - - - - - - 0 - - - - - - - - - - - - - - 0 - - - - - - - - text - - - - - - - - text - - - - - - 0 - - - - - - - - - - - - - - - - - 0 - - - - - - - 0 - - - - - - - - - - - - 100 - - - - - - - - - - - - - - 0 - - - - - - - - - - 0 - - - - - - - - - - - - - 1 - - - - - - - - - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - 0 - - - - - - - 0 - - - - - - - - - text - - - - - - - - text - - - - - 0 - - - - - - - - - - - - - - - - 0 - - - - - - - 0 - - - - - - - 0 - - - - - - - - - text - - - - - - - - text - - - - - 0 - - - - - - - - 90 - - - - - - - - - - - - diff --git a/src/assets/translations/en.json b/src/assets/translations/en.json index 5a70308..5f41402 100644 --- a/src/assets/translations/en.json +++ b/src/assets/translations/en.json @@ -14,7 +14,7 @@ "PROJECT": "My projects", "HELP": "Tips", "HELP_FORUM": "Leaphy Discord (Help forum)", - "DOWNLOAD_DRIVERS": "Download drivers", + "DOWNLOAD_DRIVERS": "Windows drivers", "MORE": "More...", "MORE_ABOUT": "About Easybloqs", "UPLOAD": "Upload to robot", @@ -125,18 +125,11 @@ "META_ATTRIBUTION": "Built with Meta Llama 3", "AI_RATE_LIMITED": "The explanation robot is a little too busy right now, please try again later.", "CHOOSING_ROBOT": "Choose your board", - "BROWSER_NOT_SUPPORTED": "The browser you are using doesn't support web-serial or web-usb.", - "BROWSER_NOT_SUPPORTED_1": "You won't be able to upload your code.", - "BROWSER_NOT_SUPPORTED_SUGGESTION": "A chromium based browser should work (Edge/Chrome/Brave)", - "ACKNOWLEDGE_BROWSER_NOT_SUPPORTED": "I understand", - "ACKNOWLEDGE_BROWSER_NOT_SUPPORTED_DONT_SHOW_AGAIN": "Don't show again", "INVALID_ROBOT_TITLE": "Incompatible device", "INVALID_ROBOT": "The selected robot {robot} does not work with the automatically detected {board}!", "INCOMPATIBLE_PROJECT": "Incompatible", "CONTINUE": "Continue", "UNKNOWN_BOARD": "Unknown", "CLEAR_PROJECT": "Clear project", - "CLEAR_PROJECT_DESC": "Selecting this robot will clear your project, are you sure?", - "DRIVER_INSTALL_TITLE": "How to install drivers?", - "DRIVER_INSTALL_TEXT": "Please follow the steps in the instruction video below to install the drivers." + "CLEAR_PROJECT_DESC": "Selecting this robot will clear your project, are you sure?" } diff --git a/src/assets/translations/nl.json b/src/assets/translations/nl.json index 8a4370e..cf7c49c 100644 --- a/src/assets/translations/nl.json +++ b/src/assets/translations/nl.json @@ -14,7 +14,7 @@ "PROJECT": "Mijn projecten", "HELP": "Tips", "HELP_FORUM": "Leaphy Discord (Help Forum)", - "DOWNLOAD_DRIVERS": "Download drivers", + "DOWNLOAD_DRIVERS": "Windows drivers", "MORE": "Meer...", "MORE_ABOUT": "Over Easybloqs", "UPLOAD": "Upload naar robot", @@ -125,18 +125,11 @@ "META_ATTRIBUTION": "Gemaakt met Meta Llama 3", "AI_RATE_LIMITED": "De uitleg robot is op dit moment erg druk, probeer het later nog eens.", "CHOOSING_ROBOT": "Kies je arduino", - "BROWSER_NOT_SUPPORTED": "De browser die je gebruikt support geen web-serial of web-usb.", - "BROWSER_NOT_SUPPORTED_1": "Je zal daardoor je code niet kunnen uploaden.", - "BROWSER_NOT_SUPPORTED_SUGGESTION": "Een chromium based browser zou werken (Edge/Chrome/Brave)", - "ACKNOWLEDGE_BROWSER_NOT_SUPPORTED": "Ik snap het", - "ACKNOWLEDGE_BROWSER_NOT_SUPPORTED_DONT_SHOW_AGAIN": "Laat niet meer zien", "INVALID_ROBOT_TITLE": "Ongeschikte robot", "INVALID_ROBOT": "De geselecteerde robot {robot} werkt niet met de automatisch gedetecteerde {board}!", "INCOMPATIBLE_PROJECT": "Ongeschikt", "CONTINUE": "Ga door", "UNKNOWN_BOARD": "Onbekend", "CLEAR_PROJECT": "Wis project", - "CLEAR_PROJECT_DESC": "Door deze robot te selecteren wis je je project, weet je het zeker?", - "DRIVER_INSTALL_TITLE": "Hoe installeer je drivers?", - "DRIVER_INSTALL_TEXT": "Bekijk het filmpje voor uitleg hoe je de drivers kunt installeren." + "CLEAR_PROJECT_DESC": "Door deze robot te selecteren wis je je project, weet je het zeker?" } diff --git a/src/lib/components/core/header/Header.svelte b/src/lib/components/core/header/Header.svelte index 6f742f4..6ae91af 100644 --- a/src/lib/components/core/header/Header.svelte +++ b/src/lib/components/core/header/Header.svelte @@ -6,6 +6,7 @@ import leaphyLogo from "$assets/leaphy-logo.svg"; import Connect from "$components/core/popups/popups/Connect.svelte"; import Button from "$components/ui/Button.svelte"; import ContextItem from "$components/ui/ContextItem.svelte"; +import Select from "$components/ui/Select.svelte"; import { loadWorkspaceFromString } from "$domain/blockly/blockly"; import { FileHandle } from "$domain/handles"; import { getSelector, robots } from "$domain/robots"; @@ -56,7 +57,6 @@ import { serialization } from "blockly"; import JSZip from "jszip"; import type { Writable } from "svelte/store"; import { get } from "svelte/store"; -import { downloadDrivers } from "../../../drivers"; import MicroPythonIO from "../../../micropython"; import About from "../popups/popups/About.svelte"; import Examples from "../popups/popups/Examples.svelte"; @@ -90,7 +90,6 @@ async function connect() { async function newProject() { popups.clear(); willRestore.set(false); - if ($workspace) $workspace.clear(); screen.set(Screen.START); } @@ -213,6 +212,29 @@ function about() { }); } +async function drivers() { + const response = await fetch( + "https://api.github.com/repos/leaphy-robotics/leaphy-firmware/contents/drivers", + ); + const data = await response.json(); + const files = data.map(({ download_url }) => download_url); + const zip = new JSZip(); + + await Promise.all( + files.map(async (url) => { + const res = await fetch(url); + zip.file(url.split("/").pop(), await res.blob()); + }), + ); + + const a = document.createElement("a"); + const url = URL.createObjectURL(await zip.generateAsync({ type: "blob" })); + a.href = url; + a.download = "leaphy-drivers.zip"; + a.click(); + URL.revokeObjectURL(url); +} + function undo() { if (!$workspace) return; @@ -302,7 +324,7 @@ function runPython() { onclick={discord} {open} /> - + {/snippet} {#snippet moreContext(open: Writable)} @@ -368,7 +390,7 @@ function runPython() { {/snippet} @@ -384,7 +406,7 @@ function runPython() { />