Skip to content

Commit

Permalink
chore(web_simulator): Show errors
Browse files Browse the repository at this point in the history
  • Loading branch information
reemo3dp committed Mar 2, 2024
1 parent acf417e commit a098845
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/klippermock/src/klippermock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from led_effect.led_effect_plugin import ledEffect, ledFrameHandler

class mockPrinter:
NOW = 0
def __init__(self, config):
self.config = config
self.config.set_printer(self)
Expand Down
15 changes: 11 additions & 4 deletions packages/web_simulator/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
let kmock: any = undefined;
let printer: any = undefined;
let error: string | undefined = undefined
const init = async () => {
const pyodide = await (window as any).loadPyodide();
await pyodide.loadPackage("micropip");
Expand All @@ -22,13 +23,13 @@
if (kmock === undefined) {
return;
}
currentFrame = 0;
const config = kmock.mockConfig();
config.setint("ledcount", ledCount);
config.set("layers", layers);
const printer = kmock.mockPrinter(config);
printer._handle_ready();
printer.led_effect.set_enabled(true);
currentFrame = 0;
return printer;
};
Expand Down Expand Up @@ -60,9 +61,11 @@
$: {
try {
console.log("Resetting printer");
printer = initPrinter(layers, ledCount, kmock);
} catch (e) {}
error = undefined;
} catch (e: any) {
error = e;
}
}
let interval: number | undefined = undefined;
Expand Down Expand Up @@ -117,12 +120,16 @@
</td>
</tr>
</table>

<div>
{#each currentLeds as led, i}
<div
style={`background-color: rgb(${led.join(",")}); width: 50px; height: 50px; border-radius: 25px; margin: 5px; display: inline-block;`}
></div>
{/each}
</div>
{#if error}
<pre style="color: red; font-weight: bold">{error}</pre>
{/if}


</main>

0 comments on commit a098845

Please sign in to comment.