From 49b231260f3c2001de92ca688b3f3038cd83cae8 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Tue, 1 Feb 2022 22:29:06 -0800 Subject: [PATCH] Make camera lazy load. --- ueforth/common/boot.fs | 1 + ueforth/common/forth_namespace_tests.fs | 3 +-- ueforth/esp32/camera.fs | 15 ++++++++++++++- ueforth/esp32/camera_server.fs | 9 +++++++-- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ueforth/common/boot.fs b/ueforth/common/boot.fs index 6c72c5b..c1f35c1 100644 --- a/ueforth/common/boot.fs +++ b/ueforth/common/boot.fs @@ -211,6 +211,7 @@ variable hld : z" postpone s" state @ if postpone drop else drop then ; immediate : r" parse-quote state @ if swap aliteral aliteral then ; immediate : r| [char] | parse state @ if swap aliteral aliteral then ; immediate +: r~ [char] ~ parse state @ if swap aliteral aliteral then ; immediate : s>z ( a n -- z ) here >r zplace r> ; : z>s ( z -- a n ) 0 over begin dup c@ while 1+ swap 1+ swap repeat drop ; diff --git a/ueforth/common/forth_namespace_tests.fs b/ueforth/common/forth_namespace_tests.fs index 62e22c0..3a4d9fd 100644 --- a/ueforth/common/forth_namespace_tests.fs +++ b/ueforth/common/forth_namespace_tests.fs @@ -62,6 +62,7 @@ e: check-boot out: cmove out: z>s out: s>z + out: r~ out: r| out: r" out: z" @@ -490,8 +491,6 @@ e: test-posix-forth-namespace e: test-esp32-forth-namespace internals voclist out: ansi - out: camera-server - out: camera out: registers out: web-interface out: httpd diff --git a/ueforth/esp32/camera.fs b/ueforth/esp32/camera.fs index 4852f2d..d7967fd 100644 --- a/ueforth/esp32/camera.fs +++ b/ueforth/esp32/camera.fs @@ -12,10 +12,21 @@ \ See the License for the specific language governing permissions and \ limitations under the License. -( Handling for ESP32-CAM ) +( Lazy loaded camera gandling for ESP32-CAM ) DEFINED? esp_camera_init [IF] +internals definitions +transfer{ + esp_camera_init esp_camera_deinit + esp_camera_fb_get esp_camera_fb_return + esp_camera_sensor_get +}transfer +forth definitions + +: camera r| + vocabulary camera camera definitions + also internals transfer{ esp_camera_init esp_camera_deinit @@ -53,5 +64,7 @@ constant camera-fb-count constant camera-format forth definitions +camera +| evaluate ; [THEN] diff --git a/ueforth/esp32/camera_server.fs b/ueforth/esp32/camera_server.fs index 82d6299..7f3b2a6 100644 --- a/ueforth/esp32/camera_server.fs +++ b/ueforth/esp32/camera_server.fs @@ -12,11 +12,14 @@ \ See the License for the specific language governing permissions and \ limitations under the License. -( Camera Server ) +( Lazy loaded Camera Server ) DEFINED? camera [IF] +: camera-server r~ + +camera vocabulary camera-server camera-server definitions -also camera also httpd + also camera also httpd r| @@ -82,5 +85,7 @@ Frame(); ; only forth definitions +camera-server +~ evaluate ; [THEN]