Skip to content

Commit

Permalink
base micropthon environment
Browse files Browse the repository at this point in the history
  • Loading branch information
ThijmenKetelaar committed Dec 6, 2024
1 parent 858147e commit 3afcd92
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 760 deletions.
558 changes: 0 additions & 558 deletions src/assets/toolbox/leaphy.xml

This file was deleted.

11 changes: 2 additions & 9 deletions src/assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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?"
}
11 changes: 2 additions & 9 deletions src/assets/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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?"
}
34 changes: 28 additions & 6 deletions src/lib/components/core/header/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -90,7 +90,6 @@ async function connect() {
async function newProject() {
popups.clear();
willRestore.set(false);
if ($workspace) $workspace.clear();
screen.set(Screen.START);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -302,7 +324,7 @@ function runPython() {
onclick={discord}
{open}
/>
<ContextItem icon={faEnvelope} name="{$_('EMAIL')} ([email protected])" onclick={email} {open} />
<ContextItem icon={faEnvelope} name={$_("EMAIL")} onclick={email} {open} />
<ContextItem icon={faComment} name={$_("FEEDBACK")} onclick={feedback} {open} />
{/snippet}
{#snippet moreContext(open: Writable<boolean>)}
Expand Down Expand Up @@ -368,7 +390,7 @@ function runPython() {
<ContextItem
icon={faDownload}
name={$_("DOWNLOAD_DRIVERS")}
onclick={downloadDrivers}
onclick={drivers}
{open}
/>
{/snippet}
Expand All @@ -384,7 +406,7 @@ function runPython() {
/>
<Button name={$_("HELP")} mode={"outlined"} context={helpContext} />
<Button name={$_("MORE")} mode={"outlined"} context={moreContext} />
{#if $mode !== Mode.PYTHON}
{#if $mode !== Mode.PYTHON && $mode !== Mode.PYTHONBLOCKS}
<Button
name={$_("CHOOSE_ROBOT")}
mode={"outlined"}
Expand Down Expand Up @@ -425,7 +447,7 @@ function runPython() {
mode={"outlined"}
onclick={saveDynamic}
/>
{#if $mode === Mode.PYTHON}
{#if $mode === Mode.PYTHON || $mode === Mode.PYTHONBLOCKS}
{#if $microPythonIO}
<Button
name={$_("RUN_CODE")}
Expand Down
10 changes: 0 additions & 10 deletions src/lib/components/core/popups/popups/Uploader.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { _ } from "svelte-i18n";
import DriverInstall from "$components/core/popups/popups/DriverInstall.svelte";
import Button from "$components/ui/Button.svelte";
import ProgressBar from "$components/ui/ProgressBar.svelte";
import { type PopupState, popups } from "$state/popup.svelte";
Expand All @@ -13,10 +12,8 @@ import {
port,
robot,
} from "$state/workspace.svelte";
import JSZip from "jszip";
import { getContext, onMount } from "svelte";
import type { Writable } from "svelte/store";
import { downloadDrivers } from "../../../../drivers";
interface Props {
source?: string;
Expand Down Expand Up @@ -143,13 +140,6 @@ async function connectUSB() {
{:else}
<ProgressBar {progress} />
{/if}
{#if failed}
<Button
name={$_("DOWNLOAD_DRIVERS")}
mode={"accent"}
onclick={() => {close(); downloadDrivers();}}
/>
{/if}
{/if}
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/workspace/Workspace.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function openCode() {
</script>

{#snippet actions()}
{#if $mode === Mode.BLOCKS}
{#if $mode === Mode.BLOCKS || $mode === Mode.PYTHONBLOCKS}
<SideButton icon={faCode} action="CODE" onclick={openCode} />
{/if}
{#if $mode !== Mode.PYTHON}
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/workspace/blocks/Blocks.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<script lang="ts">
import Dropper from "$components/ui/Dropper.svelte";
import {
loadToolbox,
setLocale,
setupWorkspace,
} from "$domain/blockly/blockly";
import {loadToolbox,setLocale,setupWorkspace } from "$domain/blockly/blockly";
import { dark, light } from "$domain/blockly/theme";
import { Theme, theme } from "$state/app.svelte";
import {
Expand Down
Loading

0 comments on commit 3afcd92

Please sign in to comment.