Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3def1f28ab | ||
|
|
38b371caa2 | ||
|
|
1364a38c9e |
3
build.py
3
build.py
@@ -2,7 +2,7 @@ import glob
|
||||
from subprocess import PIPE, Popen
|
||||
from os import listdir, makedirs
|
||||
from os.path import join, splitext
|
||||
from shutil import copytree, copy
|
||||
from shutil import copytree, copy, rmtree
|
||||
from errno import ENOTDIR
|
||||
SRC = 'src'
|
||||
DST = 'build'
|
||||
@@ -25,6 +25,7 @@ def to_compile(s: str):
|
||||
return None
|
||||
|
||||
|
||||
rmtree(DST, ignore_errors=True)
|
||||
makedirs(DST, exist_ok=True)
|
||||
mpy_cross_bin = join(".", glob.glob("mpy-cross.static*")[0])
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from adafruit_hid.keycode import Keycode
|
||||
|
||||
import time
|
||||
from board import LED
|
||||
from logs import log
|
||||
from logs import info, warn
|
||||
|
||||
kbd = Keyboard(usb_hid.devices)
|
||||
layout = KeyboardLayout(kbd)
|
||||
@@ -40,7 +40,7 @@ def press_keys(line: str):
|
||||
kbd.press(command_keycode)
|
||||
continue
|
||||
# If it's not a known key name, log it for diagnosis
|
||||
log(f"warning: unknown key: <{key}>")
|
||||
warn(f"unknown key: <{key}>")
|
||||
kbd.release_all()
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ def run_script(contents):
|
||||
millis = default_delay
|
||||
delay(millis)
|
||||
elif message := after("PRINT"):
|
||||
log(message)
|
||||
info(message)
|
||||
elif path := after("IMPORT"):
|
||||
run_script_file(path)
|
||||
elif millis := after("DEFAULT_DELAY", "DEFAULTDELAY"):
|
||||
@@ -87,4 +87,4 @@ def run_script_file(path: str):
|
||||
with open(path, "r", encoding="utf-8") as handle:
|
||||
run_script(handle.read())
|
||||
except OSError as e:
|
||||
log(f"warning: unable to open file {path}: {e}")
|
||||
warn(f"unable to open file {path}: {e}")
|
||||
|
||||
@@ -8,5 +8,9 @@ def consume() -> str:
|
||||
return dump
|
||||
|
||||
|
||||
def log(message: str):
|
||||
def info(message: str):
|
||||
logs.append("info: " + message)
|
||||
|
||||
|
||||
def warn(message: str):
|
||||
logs.append("warning: " + message)
|
||||
|
||||
@@ -36,6 +36,8 @@ body {
|
||||
height: calc(30vh - 2rem);
|
||||
background: #000;
|
||||
padding: 1rem;
|
||||
overflow: scroll;
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
.files {
|
||||
@@ -93,6 +95,7 @@ body {
|
||||
.editor {
|
||||
background: #222;
|
||||
border: none;
|
||||
resize: none;
|
||||
min-width: max-content;
|
||||
height: calc(70vh - 3rem);
|
||||
padding: 0.5rem;
|
||||
|
||||
@@ -34,7 +34,8 @@ editor.addEventListener('keyup', (_) => {
|
||||
function reload_logs() {
|
||||
doApi({'action':'logs'}).then(r => r.json()).then(body => {
|
||||
body.map(entry => {
|
||||
logs.innerHTML += entry + '<br />'
|
||||
logs.innerText += entry + '\n'
|
||||
logs.scrollTo(0, logs.scrollHeight)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user