Initial commit

This commit is contained in:
2022-12-29 14:16:09 -05:00
parent 261c9aada1
commit 2fcf93d1dd
4 changed files with 40 additions and 11 deletions

View File

@@ -44,8 +44,8 @@ build_flags =
build_src_filter = build_src_filter =
${common.src_filter} ${common.src_filter}
+<pico*.c> +<pico*.c>
upload_protocol = uf2 upload_protocol = picotool
upload_port = /run/media/max/RPI-RP2 ;; upload_port = /run/media/max/RPI-RP2
lib_deps = /home/max/repos/uclisp/ lib_deps = /home/max/repos/uclisp/
extra_scripts = pre:extra_script.py extra_scripts = pre:extra_script.py

View File

@@ -19,11 +19,10 @@ const char *platform_get_text() {
printf("> "); printf("> ");
line = NULL; line = NULL;
getline(&line, &line_len, stdin); getline(&line, &line_len, stdin);
return line; return line;
} }
void platform_repl_complete() { void platform_repl_complete() {
free(line); free(line);
line = NULL;
} }

View File

@@ -24,6 +24,10 @@ void pico_getline() {
int chr; int chr;
char *end = &buffer[0]; char *end = &buffer[0];
bool done = false; bool done = false;
printf("> ");
fflush(stdout);
while (!done) { while (!done) {
while((chr = getchar_timeout_us(0)) != PICO_ERROR_TIMEOUT) while((chr = getchar_timeout_us(0)) != PICO_ERROR_TIMEOUT)
{ {
@@ -33,10 +37,21 @@ void pico_getline() {
} }
chr = chr & 0xFF; chr = chr & 0xFF;
// Treat both backspace and DEL as backspace. It's unclear why to
// me, but they are appearing swapped for me in `screen` with the
// pico.
if (chr == '\b' || chr == '\x7f') {
if (end > buffer) {
end--;
printf("\b \b");
}
} else {
*end = chr; *end = chr;
end++; end++;
printf("%c", chr); printf("%c", chr);
}
fflush(stdout); fflush(stdout);
} }
} }

View File

@@ -1,4 +1,19 @@
(gpio-write 0 1) (setq led-pin 1)
(sleep-millis 100) (setq on 1)
(gpio-write 0 0) (setq off 0)
(sleep-millis 100) (setq blink-delay 100)
(defun blink ()
(gpio-write led-pin on)
(sleep-millis blink-delay)
(gpio-write led-pin off)
(sleep-millis blink-delay))
(while (quote t)
(blink))
(setq n 0)
(while 1
(printl n)
(setq n (+ n 1)))