From 9d59fab9a6303e7b11650add7baf04c9384de9db Mon Sep 17 00:00:00 2001 From: alkadienePhoton Date: Fri, 10 Apr 2026 17:19:14 -0500 Subject: [PATCH] Added multi-file support --- main-new.html | 525 ++++++++++++++++++++++++++++++++++++++++++++ main.bin | Bin 296 -> 0 bytes main.html | 333 ++++++++++++++++++---------- main.py | 16 +- project/bundle.py | 11 + project/imported.py | 3 + project/main.bin | Bin 0 -> 588 bytes project/main.py | 29 +++ 8 files changed, 799 insertions(+), 118 deletions(-) create mode 100644 main-new.html delete mode 100644 main.bin create mode 100644 project/bundle.py create mode 100644 project/imported.py create mode 100644 project/main.bin create mode 100644 project/main.py diff --git a/main-new.html b/main-new.html new file mode 100644 index 0000000..dfcac4f --- /dev/null +++ b/main-new.html @@ -0,0 +1,525 @@ + + + + + + + Pybricks Hub Loader + + + + +
+
+
Pybricks Hub Loader
+
Disconnected
+
+ +
+ Device: none + Max char size: - + Max program: 261512 bytes + Running: no +
+ +
+ + + + + +
+ + main.bin not selected +
+
+
Uses Web Bluetooth; open in Chrome/Edge over HTTPS or localhost.
+
+ +
+
+
+ + +
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/main.bin b/main.bin deleted file mode 100644 index 9e9ac350866a398ebfb65252e787c396a0e5ad73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 296 zcmX|*!D@p*5QayqTWf2gL_AcXwgnT4^%U{~Z6TLJQwqhC)npr&tgh@DLT={L=gyi! zVBq`apJ5nZ0m!l{Cv}#=JA%8RI_SHk*~8HO;H1LyZ2`B zZE~JhxW!z6vCByd!Fkj&Mg<(!CMD~#1&!5!KHpx!u5gu+`j-KcH{r0;tvRNY#o;&O zbafAU@Kq8K%4$m-iiT`(*z^yDazBB;AKO*pIF6#{$#~q^>XYJM1gfW|ovlgN1I^Q< xBk7j`@=)3>e8V#wbqb#4SfeY~bhOd+Oi3N|(5a)M*HH?uxjERUCQNIw7o diff --git a/main.html b/main.html index 7c8f1b2..d8e45d5 100644 --- a/main.html +++ b/main.html @@ -45,82 +45,131 @@ font-size: 12px; color: #888; } + + #stdinBar { + display: flex; + align-items: center; + margin-top: 12px; + gap: 8px; + } + + #stdinLabel { + font-size: 12px; + color: #e8ff47; + white-space: nowrap; + user-select: none; + min-width: 52px; + } + + #stdinInput { + flex: 1; + background: #111118; + color: #e0e0f0; + border: 1px solid #333; + padding: 6px 10px; + font-family: monospace; + font-size: 13px; + outline: none; + transition: border-color 0.15s; + } + + #stdinInput:focus { + border-color: #e8ff47; + } + + #stdinInput:disabled { + opacity: 0.35; + } + + #sendBtn { + background: #e8ff47; + color: #0a0a0f; + border: none; + padding: 6px 14px; + font-family: monospace; + font-weight: bold; + cursor: pointer; + white-space: nowrap; + } + + #sendBtn:disabled { + opacity: 0.4; + cursor: not-allowed; + } - +
Disconnected
+ +
+ stdin> + + +
+
diff --git a/main.py b/main.py index 723079f..b9b9cb1 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,6 @@ from pybricks.hubs import PrimeHub from pybricks.parameters import Color from pybricks.tools import wait -import micropython - hub = PrimeHub() hub.light.on(Color.RED) wait(100) @@ -15,4 +13,16 @@ print("This is the spike prime hub.") print("\x1b[?PYN;99;hubReady;spike-prime~") # Another test — event 6 (notify), level="info", message="Boot complete" -print("\x1b[?PYN;6;info;Boot complete~") \ No newline at end of file +print("\x1b[?PYN;6;info;Boot complete~") + +while True: + # This will stay here until you send a \n + answer = input("Type something: ") + + # This will now show up in your [stdout] log + print("Hub received:", answer) + + if answer == "stop": + break + +print("--- Program Ended ---") diff --git a/project/bundle.py b/project/bundle.py new file mode 100644 index 0000000..e366a3f --- /dev/null +++ b/project/bundle.py @@ -0,0 +1,11 @@ +# build.py +import asyncio +from pybricksdev.compile import compile_multi_file + +async def main(): + result = await compile_multi_file("main.py", 5) + with open("main.bin", "wb") as f: + f.write(result) + print(f"Written {len(result)} bytes to main.bin") + +asyncio.run(main()) \ No newline at end of file diff --git a/project/imported.py b/project/imported.py new file mode 100644 index 0000000..38e193c --- /dev/null +++ b/project/imported.py @@ -0,0 +1,3 @@ +def foo(): + x = "importing works :D" + print(x) \ No newline at end of file diff --git a/project/main.bin b/project/main.bin new file mode 100644 index 0000000000000000000000000000000000000000..3a6f9c23e5bdad70adaaa4000cdb3c8c20f880cd GIT binary patch literal 588 zcmX|8!D`z;5FN>qqPmHrby^)7LAG^kLy1fYA`t7)k~-i*Q=AYeA_pT&8*8zw6)QQ$ zmtyzWujwcBH~InnkB;Tm%ffr}=It=E^G5*~jbO9NmCG3Y;v0xJPg8@rZaZ0}mnZ_?cckU8iP`qWrXp!?N zqxq&uiqE^CpB&%69|m9iiwhrxTNcJkzjC>i>l+sM=Q#Iy_8|OAAxavFS)O9|n6~bg zITjW;Ov1BCk8WC+kEvu4u~<+$dkwi>J~4Y}@Uwuan5zULUWf!sv?#4&9%AgTv;gEWrn&z=(PX#ZRZ zi1BI_dx(cE*n+YJbqlo(m>vYgYH6Ng6Ey0Ccxph1b@01?iRU$H2KsKIYXI2oVY6{f vvH!=_)~i*m7kYE6;xEvJkkf+p`tTW4