From 24a4525387e2ed65bc7cbdbf3d75011554536b63 Mon Sep 17 00:00:00 2001
From: Brad Nelson
Date: Sun, 6 Jun 2021 22:04:43 -0700
Subject: [PATCH] Adding better docs + camera example.
---
ueforth/Makefile | 3 ++-
ueforth/esp32/camera.fs | 1 -
ueforth/esp32/camera_server.fs | 29 +++++++++++++++++++++++++++++
ueforth/site/ESP32forth.html | 12 +++++++++++-
ueforth/site/linux.html | 1 +
5 files changed, 43 insertions(+), 3 deletions(-)
create mode 100644 ueforth/esp32/camera_server.fs
diff --git a/ueforth/Makefile b/ueforth/Makefile
index 1c6b966..2a7c8fa 100644
--- a/ueforth/Makefile
+++ b/ueforth/Makefile
@@ -151,7 +151,7 @@ ESP32_BOOT = common/boot.fs common/conditionals.fs common/vocabulary.fs \
common/streams.fs posix/httpd.fs posix/web_interface.fs esp32/web_interface.fs \
esp32/registers.fs esp32/timers.fs \
esp32/bterm.fs posix/telnetd.fs \
- esp32/camera.fs common/blocks.fs \
+ esp32/camera.fs esp32/camera_server.fs common/blocks.fs \
esp32/autoboot.fs common/fini.fs
$(GEN)/esp32_boot.h: common/source_to_string.js $(ESP32_BOOT) | $(GEN)
echo "ok" | cat $(ESP32_BOOT) - | $< boot $(VERSION) $(REVISION) >$@
@@ -285,6 +285,7 @@ $(DEPLOY):
REPLACE = common/replace.js \
COMMON=@site/common.html \
+ POSIX_COMMON=@site/posix_common.html \
DESKTOP_COMMON=@site/desktop_common.html \
MENU=@site/menu.html \
VERSION=${VERSION} \
diff --git a/ueforth/esp32/camera.fs b/ueforth/esp32/camera.fs
index f1cd350..70d2b07 100644
--- a/ueforth/esp32/camera.fs
+++ b/ueforth/esp32/camera.fs
@@ -1,5 +1,4 @@
( Handling for ESP32-CAM )
-
DEFINED? esp_camera_init [IF]
vocabulary camera camera definitions
diff --git a/ueforth/esp32/camera_server.fs b/ueforth/esp32/camera_server.fs
new file mode 100644
index 0000000..4d508ff
--- /dev/null
+++ b/ueforth/esp32/camera_server.fs
@@ -0,0 +1,29 @@
+( Camera Server )
+DEFINED? camera [IF]
+
+vocabulary camera-server camera-server definitions
+also camera also httpd
+
+: handle-image
+ s" image/jpeg" ok-response
+ esp_camera_fb_get dup dup @ swap cell+ @ send
+ esp_camera_fb_return
+;
+
+: handle1
+ handleClient
+ s" /image" path str= if handle-image exit then
+ notfound-response
+;
+
+: do-serve begin ['] handle1 catch drop pause again ;
+
+: server ( port -- )
+ server
+ camera-config esp_camera_init throw
+ do-serve
+;
+
+only forth definitions
+
+[THEN]
diff --git a/ueforth/site/ESP32forth.html b/ueforth/site/ESP32forth.html
index 95cc74b..514039f 100644
--- a/ueforth/site/ESP32forth.html
+++ b/ueforth/site/ESP32forth.html
@@ -78,6 +78,7 @@ On boot, ESP32forth configures PIN 2 (typically an LED) to be an output and brin
ESP32forth Specific Words
{{COMMON}}
+{{POSIX_COMMON}}
ESP32forth Bindings
@@ -276,6 +277,14 @@ esp_camera_fb_return ( fb -- )
esp_camera_sensor_get ( -- sensor )
+Camera Server
+WIP Prototype - Not yet stable
+These words are inside the camera-server vocabulary.
+
+server ( port -- ) Start an image server at port,
+ e.g. http://IP/image will produce an image
+
+
SD_MMC
These words are inside the SD_MMC vocabulary.
@@ -448,7 +457,8 @@ Contact at port printed or via mDNS http://forth/.
-webui ( network-z password-z -- )
+webui ( network-z password-z -- ) login and start webui
+login ( network-z password-z -- ) login to wifi only
Usage:
diff --git a/ueforth/site/linux.html b/ueforth/site/linux.html
index d1d2ca8..d0384ef 100644
--- a/ueforth/site/linux.html
+++ b/ueforth/site/linux.html
@@ -27,6 +27,7 @@
µEforth Specific Words
{{COMMON}}
+{{POSIX_COMMON}}
Linux