2020#include " camera_index_ov2640.h"
2121#include " camera_index_ov3660.h"
2222
23- // Globals needed to set led levels
24- extern long int ledVal;
25- extern int ledChannel;
23+ // Globals (from main .ino) needed to set Led and Lamp levels
24+ extern long int lampVal;
25+ extern int lampChannel;
26+ void flashLED (int flashtime);
2627
2728#include " fb_gfx.h"
2829#include " fd_forward.h"
@@ -530,23 +531,26 @@ static esp_err_t cmd_handler(httpd_req_t *req){
530531 detection_enabled = val;
531532 }
532533 }
533- else if (!strcmp (variable, " led " )) {
534- Serial.print (" LED " );
535- ledVal = ( val * 2.55 ); // Gets the value of the query parameter (0-100) and converts to pwm value
536- if (ledVal > 255 ) ledVal = 255 ; // normalise 0-255 (pwm range) just in case..
537- if (ledVal < 0 ) ledVal = 0 ;
538- ledcWrite (ledChannel, ledVal);
539- Serial.println (ledVal );
540- res = true ;
534+ else if (!strcmp (variable, " lamp " )) {
535+ Serial.print (" Lamp: " );
536+ lampVal = val;
537+ if (lampVal > 100 ) lampVal = 100 ; // normalise 0-255 (pwm range) just in case..
538+ if (lampVal < 0 ) lampVal = 0 ;
539+ ledcWrite (lampChannel, lampVal * 2.55 ); // Add s exponential map for 0-100 vs pwm value here.
540+ Serial.print (lampVal );
541+ Serial. println ( " % " ) ;
541542 }
542543 else {
543544 res = -1 ;
544545 }
545546
547+
546548 if (res){
547549 return httpd_resp_send_500 (req);
548550 }
549551
552+ flashLED (75 ); // little flash of status LED
553+
550554 httpd_resp_set_hdr (req, " Access-Control-Allow-Origin" , " *" );
551555 return httpd_resp_send (req, NULL , 0 );
552556}
@@ -558,6 +562,7 @@ static esp_err_t status_handler(httpd_req_t *req){
558562 char * p = json_response;
559563 *p++ = ' {' ;
560564
565+ p+=sprintf (p, " \" Lamp\" :%u" , lampVal);
561566 p+=sprintf (p, " \" framesize\" :%u," , s->status .framesize );
562567 p+=sprintf (p, " \" quality\" :%u," , s->status .quality );
563568 p+=sprintf (p, " \" brightness\" :%d," , s->status .brightness );
@@ -594,14 +599,14 @@ static esp_err_t status_handler(httpd_req_t *req){
594599}
595600
596601static esp_err_t index_handler (httpd_req_t *req){
602+ flashLED (75 ); // a little feedback to user
597603 httpd_resp_set_type (req, " text/html" );
598- // httpd_resp_set_hdr(req, "Content-Encoding", "gzip");
599604 httpd_resp_set_hdr (req, " Content-Encoding" , " identity" );
600605 sensor_t * s = esp_camera_sensor_get ();
601606 if (s->id .PID == OV3660_PID) {
602- return httpd_resp_send (req, (const char *)index_ov3660_html_gz, index_ov3660_html_gz_len );
607+ return httpd_resp_send (req, (const char *)index_ov3660_html, index_ov3660_html_len );
603608 }
604- return httpd_resp_send (req, (const char *)index_ov2640_html_gz, index_ov2640_html_gz_len );
609+ return httpd_resp_send (req, (const char *)index_ov2640_html, index_ov2640_html_len );
605610}
606611
607612void startCameraServer (){
0 commit comments