Add reloading page to camera + change round xlib example.
This commit is contained in:
@ -4,6 +4,47 @@ DEFINED? camera [IF]
|
|||||||
vocabulary camera-server camera-server definitions
|
vocabulary camera-server camera-server definitions
|
||||||
also camera also httpd
|
also camera also httpd
|
||||||
|
|
||||||
|
r|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<body>
|
||||||
|
<img id="pic">
|
||||||
|
<script>
|
||||||
|
var pic = document.getElementById('pic');
|
||||||
|
function httpPost(url, callback) {
|
||||||
|
var r = new XMLHttpRequest();
|
||||||
|
r.responseType = 'blob';
|
||||||
|
r.onreadystatechange = function() {
|
||||||
|
if (this.readyState == XMLHttpRequest.DONE) {
|
||||||
|
if (this.status === 200) {
|
||||||
|
callback(this.response);
|
||||||
|
} else {
|
||||||
|
callback(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
r.open('POST', url);
|
||||||
|
r.send();
|
||||||
|
}
|
||||||
|
function Frame() {
|
||||||
|
httpPost('./image', function(r) {
|
||||||
|
if (r !== null) {
|
||||||
|
try {
|
||||||
|
pic.src = URL.createObjectURL(r);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTimeout(Frame, 30);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Frame();
|
||||||
|
</script>
|
||||||
|
| constant index-html# constant index-html
|
||||||
|
|
||||||
|
: handle-index
|
||||||
|
s" text/html" ok-response
|
||||||
|
index-html index-html# send
|
||||||
|
;
|
||||||
|
|
||||||
: handle-image
|
: handle-image
|
||||||
s" image/jpeg" ok-response
|
s" image/jpeg" ok-response
|
||||||
esp_camera_fb_get dup dup @ swap cell+ @ send
|
esp_camera_fb_get dup dup @ swap cell+ @ send
|
||||||
@ -12,6 +53,7 @@ also camera also httpd
|
|||||||
|
|
||||||
: handle1
|
: handle1
|
||||||
handleClient
|
handleClient
|
||||||
|
s" /" path str= if handle-index exit then
|
||||||
s" /image" path str= if handle-image exit then
|
s" /image" path str= if handle-image exit then
|
||||||
notfound-response
|
notfound-response
|
||||||
;
|
;
|
||||||
|
|||||||
@ -2,7 +2,7 @@ include posix/xlib.fs
|
|||||||
|
|
||||||
also x11
|
also x11
|
||||||
|
|
||||||
z" :0" XOpenDisplay constant display
|
0 XOpenDisplay constant display
|
||||||
display XDefaultScreen constant screen
|
display XDefaultScreen constant screen
|
||||||
display screen XBlackPixel constant black
|
display screen XBlackPixel constant black
|
||||||
display screen XWhitePixel constant white
|
display screen XWhitePixel constant white
|
||||||
|
|||||||
Reference in New Issue
Block a user