From 865c54b93a33e777bc2b2486d7a78c59ab428227 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 6 Feb 2021 20:52:39 -0800 Subject: [PATCH] Isolate more stuff. --- ueforth/arduino/arduino.fs | 4 +++- ueforth/arduino/arduino_server.fs | 5 ----- ueforth/arduino/autoboot.fs | 5 ++++- ueforth/arduino/esp_camera.fs | 6 ++++++ ueforth/arduino/hide_io.fs | 21 +++++++++++++++++++++ ueforth/common/blocks.fs | 2 +- ueforth/common/vocabulary.fs | 1 + ueforth/site/index.html | 15 ++++++++++++++- 8 files changed, 50 insertions(+), 9 deletions(-) diff --git a/ueforth/arduino/arduino.fs b/ueforth/arduino/arduino.fs index 32e9dd8..ba89dc7 100644 --- a/ueforth/arduino/arduino.fs +++ b/ueforth/arduino/arduino.fs @@ -1,12 +1,14 @@ ( Set up Basic I/O ) +internals definitions : arduino-bye 0 terminate ; ' arduino-bye is bye : arduino-type ( a n -- ) Serial.write drop ; ' arduino-type is type -: key? ( -- n ) Serial.available ; : arduino-key ( -- n ) begin Serial.available until 0 >r rp@ 1 Serial.readBytes drop r> ; ' arduino-key is key +forth definitions +: key? ( -- n ) Serial.available ; ( Map Arduino / ESP32 things to shorter names. ) : pin ( n pin# -- ) swap digitalWrite ; diff --git a/ueforth/arduino/arduino_server.fs b/ueforth/arduino/arduino_server.fs index 216c38c..226dfe8 100644 --- a/ueforth/arduino/arduino_server.fs +++ b/ueforth/arduino/arduino_server.fs @@ -158,11 +158,6 @@ 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 diff --git a/ueforth/arduino/autoboot.fs b/ueforth/arduino/autoboot.fs index fa4c4a4..9377f60 100644 --- a/ueforth/arduino/autoboot.fs +++ b/ueforth/arduino/autoboot.fs @@ -1,7 +1,10 @@ +internals definitions ( Change default block source on arduino ) : arduino-default-use s" /spiffs/blocks.fb" open-blocks ; ' arduino-default-use is default-use ( Check for autoexec.fs and run if present ) : autoexec ( a n -- ) s" /spiffs/autoexec.fs" ['] included catch 2drop drop ; -autoexec +' autoexec +forth definitions +execute diff --git a/ueforth/arduino/esp_camera.fs b/ueforth/arduino/esp_camera.fs index d94dc4d..8a26c66 100644 --- a/ueforth/arduino/esp_camera.fs +++ b/ueforth/arduino/esp_camera.fs @@ -2,6 +2,12 @@ vocabulary camera camera definitions +?transfer esp_camera_init +?transfer esp_camera_deinit +?transfer esp_camera_fb_get +?transfer esp_camera_fb_return +?transfer esp_camera_sensor_get + 0 constant PIXFORMAT_RGB565 1 constant PIXFORMAT_YUV422 2 constant PIXFORMAT_GRAYSCALE diff --git a/ueforth/arduino/hide_io.fs b/ueforth/arduino/hide_io.fs index 9a79efa..a964df8 100644 --- a/ueforth/arduino/hide_io.fs +++ b/ueforth/arduino/hide_io.fs @@ -68,6 +68,27 @@ transfer{ }transfer forth definitions +vocabulary bluetooth bluetooth definitions +?transfer SerialBT.new +?transfer SerialBT.delete +?transfer SerialBT.begin +?transfer SerialBT.end +?transfer SerialBT.available +?transfer SerialBT.readBytes +?transfer SerialBT.write +?transfer SerialBT.flush +?transfer SerialBT.hasClient +?transfer SerialBT.enableSSP +?transfer SerialBT.setPin +?transfer SerialBT.unpairDevice +?transfer SerialBT.connect +?transfer SerialBT.connectAddr +?transfer SerialBT.disconnect +?transfer SerialBT.connected +?transfer SerialBT.isReady +?transfer esp_bt_dev_get_address +forth definitions + internals definitions transfer{ malloc sysfree realloc diff --git a/ueforth/common/blocks.fs b/ueforth/common/blocks.fs index dada9fb..7b6f9e2 100644 --- a/ueforth/common/blocks.fs +++ b/ueforth/common/blocks.fs @@ -48,8 +48,8 @@ forth definitions internals internals definitions : @line ( n -- ) 64 * scr @ block + ; : e' ( n -- ) @line clobber-line drop update ; -: wipe 15 for r@ e' next l ; : e e' l ; forth definitions internals +: wipe 15 for r@ e' next l ; : e e' l ; : d ( n -- ) dup 1+ @line swap @line 15 @line over - cmove 15 e ; : r ( n "line" -- ) 0 parse 64 min rot dup e @line swap cmove l ; : a ( n "line" -- ) dup @line over 1+ @line 16 @line over - cmove> r ; diff --git a/ueforth/common/vocabulary.fs b/ueforth/common/vocabulary.fs index 5dddf05..7833a6d 100644 --- a/ueforth/common/vocabulary.fs +++ b/ueforth/common/vocabulary.fs @@ -9,6 +9,7 @@ : transfer-xt ( xt -- ) context @ begin 2dup @ <> while @ >link& repeat nip dup @ swap dup @ >link swap ! current @ @ over >link& ! current @ ! ; : transfer ( "name" ) ' transfer-xt ; +: ?transfer ( "name" ) bl parse find dup if transfer-xt else drop then ; : }transfer ; : transfer{ begin ' dup ['] }transfer = if drop exit then transfer-xt again ; diff --git a/ueforth/site/index.html b/ueforth/site/index.html index d3f1b99..74da687 100644 --- a/ueforth/site/index.html +++ b/ueforth/site/index.html @@ -156,6 +156,7 @@ See