Skip to content

Commit 43186d3

Browse files
committed
Lamp controls auto-hide, stream toggles no longer in settings menu, some visual fluff
1 parent c369670 commit 43186d3

File tree

4 files changed

+52
-17
lines changed

4 files changed

+52
-17
lines changed

app_httpd.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ static esp_err_t status_handler(httpd_req_t *req){
565565
sensor_t * s = esp_camera_sensor_get();
566566
char * p = json_response;
567567
*p++ = '{';
568-
568+
p+=sprintf(p, "\"lamp\":%i,", lampVal);
569569
p+=sprintf(p, "\"framesize\":%u,", s->status.framesize);
570570
p+=sprintf(p, "\"quality\":%u,", s->status.quality);
571571
p+=sprintf(p, "\"brightness\":%d,", s->status.brightness);
@@ -594,7 +594,6 @@ static esp_err_t status_handler(httpd_req_t *req){
594594
p+=sprintf(p, "\"face_detect\":%u,", detection_enabled);
595595
p+=sprintf(p, "\"face_enroll\":%u,", is_enrolling);
596596
p+=sprintf(p, "\"face_recognize\":%u", recognition_enabled);
597-
if (lampVal != -1) p+=sprintf(p, "\"Lamp\":%u", lampVal);
598597
*p++ = '}';
599598
*p++ = 0;
600599
httpd_resp_set_type(req, "application/json");

camera_index_ov2640.h

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,34 +336,50 @@ const uint8_t index_ov2640_html[] PROGMEM = R"=====(
336336
.hidden {
337337
display: none
338338
}
339+
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+
349+
.inline-button {
350+
line-height: 20px;
351+
margin: 2px;
352+
padding: 1px 4px 2px 4px;
353+
}
354+
339355
</style>
340356
</head>
341357
<body>
342358
<section class="main">
343359
<div id="logo">
344-
<label for="nav-toggle-cb" id="nav-toggle">&#9776;&nbsp;&nbsp;Toggle OV2640 settings</label>
360+
<label for="nav-toggle-cb" id="nav-toggle" style="float:left;">&#9776;&nbsp;&nbsp;Settings&nbsp;&nbsp;&nbsp;&nbsp;</label>
361+
<button id="get-still" style="float:left;">Get Still</button>
362+
<button id="toggle-stream" style="float:left;">Start Stream</button>
345363
</div>
346364
<div id="content">
347365
<div id="sidebar">
348366
<input type="checkbox" id="nav-toggle-cb" checked="checked">
349367
<nav id="menu">
350-
351368
<div class="input-group" id="lamp-group">
352369
<label for="lamp">Light</label>
353370
<div class="range-min">0%</div>
354371
<input type="range" id="lamp" min="0" max="100" value="0" class="default-action">
355372
<div class="range-max">100%</div>
356373
</div>
357-
358374
<div class="input-group" id="framesize-group">
359375
<label for="framesize">Resolution</label>
360376
<select id="framesize" class="default-action">
361377
<option value="10">UXGA(1600x1200)</option>
362378
<option value="9">SXGA(1280x1024)</option>
363379
<option value="8">XGA(1024x768)</option>
364-
<option value="7">SVGA(800x600)</option>
380+
<option value="7" selected="selected">SVGA(800x600)</option>
365381
<option value="6">VGA(640x480)</option>
366-
<option value="5" selected="selected">CIF(400x296)</option>
382+
<option value="5">CIF(400x296)</option>
367383
<option value="4">QVGA(320x240)</option>
368384
<option value="3">HQVGA(240x176)</option>
369385
<option value="0">QQVGA(160x120)</option>
@@ -545,8 +561,6 @@ const uint8_t index_ov2640_html[] PROGMEM = R"=====(
545561
</div>
546562
</div>
547563
<section id="buttons">
548-
<button id="get-still">Get Still</button>
549-
<button id="toggle-stream">Start Stream</button>
550564
<button id="face_enroll" class="disabled" disabled="disabled">Enroll Face</button>
551565
</section>
552566
</nav>
@@ -593,6 +607,8 @@ document.addEventListener('DOMContentLoaded', function (event) {
593607
el.value = value
594608
}
595609

610+
const lampGroup = document.getElementById('lamp-group')
611+
596612
if (updateRemote && initialValue !== value) {
597613
updateConfig(el);
598614
} else if(!updateRemote){
@@ -610,6 +626,12 @@ document.addEventListener('DOMContentLoaded', function (event) {
610626
value ? show(wb) : hide(wb)
611627
} else if(el.id === "face_recognize"){
612628
value ? enable(enrollButton) : disable(enrollButton)
629+
} else if(el.id === "lamp"){
630+
if (value == -1) {
631+
hide(lampGroup)
632+
} else {
633+
show(lampGroup)
634+
}
613635
}
614636
}
615637
}

camera_index_ov3660.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,20 @@ const uint8_t index_ov3660_html[] PROGMEM = R"=====(
357357
<body>
358358
<section class="main">
359359
<div id="logo">
360-
<label for="nav-toggle-cb" id="nav-toggle">&#9776;&nbsp;&nbsp;Toggle OV3660 settings</label>
360+
<label for="nav-toggle-cb" id="nav-toggle" style="float:left;">&#9776;&nbsp;&nbsp;Settings&nbsp;&nbsp;&nbsp;&nbsp;</label>
361+
<button id="get-still" style="float:left;">Get Still</button>
362+
<button id="toggle-stream" style="float:left;">Start Stream</button>
361363
</div>
362364
<div id="content">
363365
<div id="sidebar">
364366
<input type="checkbox" id="nav-toggle-cb" checked="checked">
365367
<nav id="menu">
368+
<div class="input-group" id="lamp-group">
369+
<label for="lamp">Light</label>
370+
<div class="range-min">0%</div>
371+
<input type="range" id="lamp" min="0" max="100" value="0" class="default-action">
372+
<div class="range-max">100%</div>
373+
</div>
366374
<div class="input-group" id="framesize-group">
367375
<label for="framesize">Resolution</label>
368376
<select id="framesize" class="default-action">
@@ -566,8 +574,6 @@ const uint8_t index_ov3660_html[] PROGMEM = R"=====(
566574
</div>
567575
</div>
568576
<section id="buttons">
569-
<button id="get-still">Get Still</button>
570-
<button id="toggle-stream">Start Stream</button>
571577
<button id="face_enroll" class="disabled" disabled="disabled">Enroll Face</button>
572578
</section>
573579
</nav>
@@ -614,6 +620,8 @@ document.addEventListener('DOMContentLoaded', function (event) {
614620
el.value = value
615621
}
616622

623+
const lampGroup = document.getElementById('lamp-group')
624+
617625
if (updateRemote && initialValue !== value) {
618626
updateConfig(el);
619627
} else if(!updateRemote){
@@ -629,6 +637,12 @@ document.addEventListener('DOMContentLoaded', function (event) {
629637
value ? show(wb) : hide(wb)
630638
} else if(el.id === "face_recognize"){
631639
value ? enable(enrollButton) : disable(enrollButton)
640+
} else if(el.id === "lamp"){
641+
if (value == -1) {
642+
hide(lampGroup)
643+
} else {
644+
show(lampGroup)
645+
}
632646
}
633647
}
634648
}
@@ -676,7 +690,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
676690
document
677691
.querySelectorAll('.default-action')
678692
.forEach(el => {
679-
updateValue(el, state[el.id], false)
693+
updateValue(el, state[el.id], false)
680694
})
681695
})
682696

esp32-cam-webserver.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#endif
3636
int lampChannel = 7; // a free PWM channel (some channels used by camera)
3737
const int pwmfreq = 50000; // 50K pwm frequency
38-
const int pwmresolution = 8; // duty cycle has 8 bit range
38+
const int pwmresolution = 9; // duty cycle bit range
3939
// https://diarmuid.ie/blog/pwm-exponential-led-fading-on-arduino-or-other-platforms
4040
const int pwmIntervals = 100; // The number of Steps between the output being on and off
4141
float lampR; // The R value in the PWM graph equation (calculated in setup)
@@ -56,9 +56,9 @@ void setup() {
5656
ledcSetup(lampChannel, pwmfreq, pwmresolution); // configure LED PWM channel
5757
ledcWrite(lampChannel, lampVal); // set initial value
5858
ledcAttachPin(LAMP_PIN, lampChannel); // attach the GPIO pin to the channel
59-
// Calculate the PWM scaling R factor:
59+
// Calculate the PWM scaling R factor:
6060
// https://diarmuid.ie/blog/pwm-exponential-led-fading-on-arduino-or-other-platforms
61-
lampR = (pwmIntervals * log10(2))/(log10(255));
61+
lampR = (pwmIntervals * log10(2))/(log10(pow(2,pwmresolution)));
6262
#endif
6363

6464
camera_config_t config;
@@ -113,7 +113,7 @@ void setup() {
113113
s->set_saturation(s, -2);//lower the saturation
114114
}
115115
//drop down frame size for higher initial frame rate
116-
s->set_framesize(s, FRAMESIZE_QVGA);
116+
s->set_framesize(s, FRAMESIZE_SVGA);
117117

118118
#if defined(CAMERA_MODEL_M5STACK_WIDE)
119119
s->set_vflip(s, 1);

0 commit comments

Comments
 (0)