Skip to content

Commit

Permalink
Mini viewer (#34)
Browse files Browse the repository at this point in the history
fixes #25
  • Loading branch information
easytarget authored Sep 10, 2020
1 parent bab559b commit 71dd634
Show file tree
Hide file tree
Showing 4 changed files with 656 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app_httpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "camera_index_ov2640.h"
#include "camera_index_ov3660.h"
#include "miniviewer.h"
#include "favicon/favicons.h"

//#define DEBUG_STREAM_DATA // Debug: dump info for each stream frame on serial port
Expand Down Expand Up @@ -570,6 +571,9 @@ static esp_err_t cmd_handler(httpd_req_t *req){
lampVal = constrain(val,0,100);
setLamp(lampVal);
}
else if(!strcmp(variable, "rotate")) {
sprintf(myRotation, "%i", val);
}
else {
res = -1;
}
Expand Down Expand Up @@ -660,6 +664,15 @@ static esp_err_t favicon_ico_handler(httpd_req_t *req){
return httpd_resp_send(req, (const char *)favicon_ico, favicon_ico_len);
}

static esp_err_t miniviewer_handler(httpd_req_t *req){
flashLED(75); // a little feedback to user
delay(75);
flashLED(75);
httpd_resp_set_type(req, "text/html");
httpd_resp_set_hdr(req, "Content-Encoding", "identity");
return httpd_resp_send(req, (const char *)miniviewer_html, miniviewer_html_len);
}

static esp_err_t index_handler(httpd_req_t *req){
flashLED(75); // a little feedback to user
delay(75);
Expand Down Expand Up @@ -704,6 +717,13 @@ void startCameraServer(int hPort, int sPort){
.user_ctx = NULL
};

httpd_uri_t miniviewer_uri = {
.uri = "/view",
.method = HTTP_GET,
.handler = miniviewer_handler,
.user_ctx = NULL
};

httpd_uri_t favicon_16x16_uri = {
.uri = "/favicon-16x16.png",
.method = HTTP_GET,
Expand Down Expand Up @@ -759,6 +779,7 @@ void startCameraServer(int hPort, int sPort){
httpd_register_uri_handler(camera_httpd, &cmd_uri);
httpd_register_uri_handler(camera_httpd, &status_uri);
httpd_register_uri_handler(camera_httpd, &capture_uri);
httpd_register_uri_handler(camera_httpd, &miniviewer_uri);
httpd_register_uri_handler(camera_httpd, &favicon_16x16_uri);
httpd_register_uri_handler(camera_httpd, &favicon_32x32_uri);
httpd_register_uri_handler(camera_httpd, &favicon_ico_uri);
Expand Down
3 changes: 3 additions & 0 deletions camera_index_ov2640.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
} else if(el.id === "cam_name"){
camName.innerHTML = value;
window.document.title = value;
console.log('Name set to: ' + value);
} else if(el.id === "code_ver"){
codeVer.innerHTML = value;
} else if(el.id === "rotate"){
Expand All @@ -698,6 +699,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
streamURL = value;
streamButton.setAttribute("title", `You can also browse to '${streamURL}' for a raw stream`);
show(streamGroup)
console.log('Stream set to:' + value);
}
}
}
Expand Down Expand Up @@ -836,6 +838,7 @@ document.addEventListener('DOMContentLoaded', function (event) {

// Detection and framesize
rotate.onchange = () => {
updateConfig(rotate);
rot = rotate.value;
if (rot == -90) {
viewContainer.style.transform = `rotate(-90deg) translate(-100%)`;
Expand Down
3 changes: 3 additions & 0 deletions camera_index_ov3660.h
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
} else if(el.id === "cam_name"){
camName.innerHTML = value;
window.document.title = value;
console.log('Name set to: ' + value);
} else if(el.id === "code_ver"){
codeVer.innerHTML = value;
} else if(el.id === "rotate"){
Expand All @@ -709,6 +710,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
streamURL = value;
streamButton.setAttribute("title", `You can also browse to '${streamURL}' for a raw stream`);
show(streamGroup)
console.log('Stream set to:' + value);
}
}
}
Expand Down Expand Up @@ -844,6 +846,7 @@ document.addEventListener('DOMContentLoaded', function (event) {

// Detection and framesize
rotate.onchange = () => {
updateConfig(rotate);
rot = rotate.value;
if (rot == -90) {
viewContainer.style.transform = `rotate(-90deg) translate(-100%)`;
Expand Down
Loading

0 comments on commit 71dd634

Please sign in to comment.