Skip to content

Commit d0a9071

Browse files
committed
Working, release>
1 parent 43186d3 commit d0a9071

File tree

4 files changed

+78
-20
lines changed

4 files changed

+78
-20
lines changed

app_httpd.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ extern int lampVal; // The current Lamp value
2626
extern int lampChannel; // PWM channel Lamp is attached to
2727
extern float lampR; // The R value in the graph equation
2828

29+
// Info we pass to the webapp
30+
extern char myName[];
31+
extern char myVer[];
32+
2933
#include "fb_gfx.h"
3034
#include "fd_forward.h"
3135
#include "fr_forward.h"
@@ -561,7 +565,6 @@ static esp_err_t cmd_handler(httpd_req_t *req){
561565

562566
static esp_err_t status_handler(httpd_req_t *req){
563567
static char json_response[1024];
564-
565568
sensor_t * s = esp_camera_sensor_get();
566569
char * p = json_response;
567570
*p++ = '{';
@@ -593,7 +596,9 @@ static esp_err_t status_handler(httpd_req_t *req){
593596
p+=sprintf(p, "\"colorbar\":%u,", s->status.colorbar);
594597
p+=sprintf(p, "\"face_detect\":%u,", detection_enabled);
595598
p+=sprintf(p, "\"face_enroll\":%u,", is_enrolling);
596-
p+=sprintf(p, "\"face_recognize\":%u", recognition_enabled);
599+
p+=sprintf(p, "\"face_recognize\":%u,", recognition_enabled);
600+
p+=sprintf(p, "\"cam_name\":\"%s\",", myName);
601+
p+=sprintf(p, "\"code_ver\":\"%s\"", myVer);
597602
*p++ = '}';
598603
*p++ = 0;
599604
httpd_resp_set_type(req, "application/json");

camera_index_ov2640.h

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const uint8_t index_ov2640_html[] PROGMEM = R"=====(
55
<head>
66
<meta charset="utf-8">
77
<meta name="viewport" content="width=device-width,initial-scale=1">
8-
<title>ESP32 OV2640</title>
8+
<title id="title">ESP32 OV2640</title>
99
<style>
1010
body {
1111
font-family: Arial,Helvetica,sans-serif;
@@ -258,6 +258,15 @@ const uint8_t index_ov2640_html[] PROGMEM = R"=====(
258258
background: #363636
259259
}
260260

261+
input[type=text] {
262+
border: 1px solid #363636;
263+
font-size: 14px;
264+
height: 20px;
265+
margin: 1px;
266+
outline: 0;
267+
border-radius: 5px
268+
}
269+
261270
.switch {
262271
display: block;
263272
position: relative;
@@ -337,15 +346,6 @@ const uint8_t index_ov2640_html[] PROGMEM = R"=====(
337346
display: none
338347
}
339348

340-
input[type=text] {
341-
border: 1px solid #363636;
342-
font-size: 14px;
343-
height: 20px;
344-
margin: 1px;
345-
outline: 0;
346-
border-radius: 5px
347-
}
348-
349349
.inline-button {
350350
line-height: 20px;
351351
margin: 2px;
@@ -563,6 +563,15 @@ const uint8_t index_ov2640_html[] PROGMEM = R"=====(
563563
<section id="buttons">
564564
<button id="face_enroll" class="disabled" disabled="disabled">Enroll Face</button>
565565
</section>
566+
<div class="input-group" id="cam_name-group">
567+
<label for="cam_name">Name:</label>
568+
<div id="cam_name" class="default-action"></div>
569+
</div>
570+
<div class="input-group" id="code_ver-group">
571+
<label for="code_ver">Firmware:</label>
572+
<div id="code_ver" class="default-action"></div>
573+
</div>
574+
566575
</nav>
567576
</div>
568577
<figure>
@@ -573,7 +582,9 @@ const uint8_t index_ov2640_html[] PROGMEM = R"=====(
573582
</figure>
574583
</div>
575584
</section>
576-
<script>
585+
</body>
586+
587+
<script>
577588
document.addEventListener('DOMContentLoaded', function (event) {
578589
var baseHost = document.location.origin
579590
var streamUrl = baseHost + ':81'
@@ -608,6 +619,8 @@ document.addEventListener('DOMContentLoaded', function (event) {
608619
}
609620

610621
const lampGroup = document.getElementById('lamp-group')
622+
const camName = document.getElementById('cam_name')
623+
const codeVer = document.getElementById('code_ver')
611624

612625
if (updateRemote && initialValue !== value) {
613626
updateConfig(el);
@@ -632,6 +645,11 @@ document.addEventListener('DOMContentLoaded', function (event) {
632645
} else {
633646
show(lampGroup)
634647
}
648+
} else if(el.id === "cam_name"){
649+
camName.innerHTML = value;
650+
window.document.title = value;
651+
} else if(el.id === "code_ver"){
652+
codeVer.innerHTML = value;
635653
}
636654
}
637655
}
@@ -698,6 +716,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
698716
const startStream = () => {
699717
view.src = `${streamUrl}/stream`
700718
show(viewContainer)
719+
view.scrollIntoView();
701720
streamButton.innerHTML = 'Stop Stream'
702721
}
703722

@@ -807,8 +826,8 @@ document.addEventListener('DOMContentLoaded', function (event) {
807826
}
808827
})
809828

810-
</script>
811-
</body>
829+
</script>
830+
812831
</html>
813832
)=====";
814833

esp32-cam-webserver.ino

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
#include "esp_camera.h"
22
#include <WiFi.h>
33

4-
//
5-
// WARNING!!! Make sure that you have either selected ESP32 Wrover Module,
6-
// or another board which has PSRAM enabled
7-
//
4+
/* This sketch is a extension/expansion/reork of the 'official' ESP32 Camera example
5+
* sketch from Expressif:
6+
* https://github.com/espressif/arduino-esp32/tree/master/libraries/ESP32/examples/Camera/CameraWebServer
7+
*
8+
* It is modified to allow control of Illumination LED Lamps's (present on some modules),
9+
* greater feedback via a status LED, and the HTML contents are present in plain text
10+
* for easy modification.
11+
*
12+
* A camera name can now be configured, and wifi details can be stored in an optional
13+
* header file to allow easier updated of the repo.
14+
*
15+
* The web UI has had minor changes to add the Lamp control when present, I have made the
16+
* 'Start Stream' controls more accessible, and add feedback of the camera name/firmware.
17+
*
18+
*
19+
* note: Make sure that you have either selected ESP32 AI Thinker,
20+
* or another board which has PSRAM enabled to use High resolution Modes
21+
*/
822

923
// Select camera board model
1024
//#define CAMERA_MODEL_WROVER_KIT
@@ -25,6 +39,18 @@
2539
const char* password = "my-access-point-password";
2640
#endif
2741

42+
// A Name for the Camera. (can be set in wifi.h)
43+
#ifdef CAM_NAME
44+
char myName[] = CAM_NAME;
45+
#else
46+
char myName[] = "ESP32 camera server";
47+
#endif
48+
49+
// This will be displayed to identify the firmware
50+
char myVer[] PROGMEM = __DATE__ " @ " __TIME__;
51+
52+
53+
2854
#include "camera_pins.h"
2955

3056
// Status and illumination LED's
@@ -45,7 +71,10 @@ void startCameraServer();
4571
void setup() {
4672
Serial.begin(115200);
4773
Serial.setDebugOutput(true);
48-
Serial.println();
74+
Serial.print("esp32-cam-webserver: ");
75+
Serial.println(myName);
76+
Serial.print("Code Built: ");
77+
Serial.println(myVer);
4978

5079
#ifdef LED_PIN // If we have notification LED, set it to output
5180
pinMode(LED_PIN, OUTPUT);

mywifi.sample.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@
33

44
const char* ssid = "my-access-point-ssid";
55
const char* password = "my-access-point-password";
6+
7+
8+
// Optionally give the camera a name for the web interface
9+
// (this is not a network hostname)
10+
// #define CAM_NAME "Chocolate Store"

0 commit comments

Comments
 (0)