From 412da1d8b2e4d3b2f32b697717ec89d3014ee8fc Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 6 Feb 2021 18:23:06 -0800 Subject: [PATCH] Fixed arduino hiding. --- ueforth/Makefile | 6 +++--- ueforth/arduino/arduino_highlevel.fs | 5 +++++ ueforth/arduino/arduino_server.fs | 22 ++++++++++++++++++++++ ueforth/common/core.h | 2 +- ueforth/common/hide_calls.fs | 5 +++++ ueforth/common/vocabulary.fs | 3 --- 6 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 ueforth/arduino/arduino_highlevel.fs create mode 100644 ueforth/common/hide_calls.fs diff --git a/ueforth/Makefile b/ueforth/Makefile index e4faa21..5b195ce 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -113,7 +113,7 @@ unit_tests: $(POSIX)/ueforth common/all_tests.fs $(GEN): mkdir -p $@ -POSIX_BOOT = common/boot.fs common/vocabulary.fs common/ansi.fs \ +POSIX_BOOT = common/boot.fs common/vocabulary.fs common/hide_calls.fs common/ansi.fs \ posix/posix.fs posix/posix_highlevel.fs \ common/highlevel.fs common/filetools.fs posix/posix_desktop.fs \ common/tasks.fs common/streams.fs common/blocks.fs posix/args.fs \ @@ -121,7 +121,7 @@ POSIX_BOOT = common/boot.fs common/vocabulary.fs common/ansi.fs \ $(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN) echo "ok" | cat $(POSIX_BOOT) - | $< boot >$@ -WINDOWS_BOOT = common/boot.fs common/vocabulary.fs common/ansi.fs \ +WINDOWS_BOOT = common/boot.fs common/vocabulary.fs common/hide_calls.fs common/ansi.fs \ windows/windows.fs windows/windows_highlevel.fs common/highlevel.fs \ common/tasks.fs common/streams.fs common/blocks.fs \ common/utils.fs @@ -129,7 +129,7 @@ $(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN) echo "ok" | cat $(WINDOWS_BOOT) - | $< boot >$@ ARDUINO_BOOT = common/boot.fs common/vocabulary.fs arduino/arduino.fs \ - posix/posix_highlevel.fs common/highlevel.fs common/filetools.fs \ + arduino/arduino_highlevel.fs common/highlevel.fs common/filetools.fs \ common/tasks.fs common/streams.fs arduino/arduino_server.fs \ arduino/esp_camera.fs common/blocks.fs common/utils.fs \ arduino/autoboot.fs diff --git a/ueforth/arduino/arduino_highlevel.fs b/ueforth/arduino/arduino_highlevel.fs new file mode 100644 index 0000000..a47de85 --- /dev/null +++ b/ueforth/arduino/arduino_highlevel.fs @@ -0,0 +1,5 @@ +( Words with OS assist ) +: allocate ( n -- a ior ) malloc dup 0= ; +: free ( a -- ior ) sysfree drop 0 ; +: resize ( a n -- a ior ) realloc dup 0= ; + diff --git a/ueforth/arduino/arduino_server.fs b/ueforth/arduino/arduino_server.fs index eef645d..1eb42c6 100644 --- a/ueforth/arduino/arduino_server.fs +++ b/ueforth/arduino/arduino_server.fs @@ -1,4 +1,7 @@ ( Server Terminal ) + +vocabulary web-interface web-interface definitions + : n. ( n -- ) <# #s #> type ; : ip# dup 255 and n. [char] . emit 256 / ; : ip. ( n -- ) ip# ip# ip# 255 and . ; @@ -97,8 +100,17 @@ window.onload = function() { variable webserver 20000 constant out-size + +streams +: >stream >stream ; +: stream> stream> ; +: stream>ch stream>ch ; +: stream stream ; +web-interface + 200 stream input-stream out-size dup stream output-stream + create out-string out-size 1+ allot align : handle-index @@ -132,6 +144,11 @@ create out-string out-size 1+ allot align again ; +tasks +: task task ; +: start-task start-task ; +web-interface + ' do-serve 1000 1000 task webserver-task : serve @@ -144,4 +161,9 @@ create out-string out-size 1+ allot align WIFI_MODE_STA Wifi.mode WiFi.begin begin WiFi.localIP 0= while 100 ms repeat WiFi.localIP ip. cr z" ueforth" MDNS.begin if ." MDNS started" else ." MDNS failed" then cr ; + +forth definitions web-interface + : webui ( z z -- ) wifi serve ; + +forth diff --git a/ueforth/common/core.h b/ueforth/common/core.h index 328d3b7..8db86a4 100644 --- a/ueforth/common/core.h +++ b/ueforth/common/core.h @@ -133,7 +133,7 @@ static void ueforth_init(int argc, char *argv[], void *heap, // FORTH vocabulary *g_sys.heap++ = 0; g_sys.current = (cell_t **) g_sys.heap; - g_sys.context = (cell_t **) g_sys.heap; ++g_sys.heap; + g_sys.context = (cell_t **) g_sys.heap; *g_sys.heap++ = 0; *g_sys.heap++ = 0; *g_sys.heap++ = 0; *g_sys.heap++ = 0; ueforth_run(0); diff --git a/ueforth/common/hide_calls.fs b/ueforth/common/hide_calls.fs new file mode 100644 index 0000000..37b34c4 --- /dev/null +++ b/ueforth/common/hide_calls.fs @@ -0,0 +1,5 @@ +internals definitions +transfer call0 transfer call1 transfer call2 transfer call3 transfer call4 +transfer call5 transfer call6 transfer call7 transfer call8 transfer call9 +transfer call10 +forth definitions diff --git a/ueforth/common/vocabulary.fs b/ueforth/common/vocabulary.fs index 7bdbb8d..e7e9708 100644 --- a/ueforth/common/vocabulary.fs +++ b/ueforth/common/vocabulary.fs @@ -25,7 +25,4 @@ transfer $@ transfer see. transfer see-loop transfer >name-length transfer exit= transfer see-one transfer tib-setup transfer input-limit -transfer call0 transfer call1 transfer call2 transfer call3 transfer call4 -transfer call5 transfer call6 transfer call7 transfer call8 transfer call9 -transfer call10 forth definitions