diff --git a/app_httpd.cpp b/app_httpd.cpp index 9557467..768c76a 100644 --- a/app_httpd.cpp +++ b/app_httpd.cpp @@ -29,6 +29,7 @@ extern float lampR; // The R value in the graph equation // Info we pass to the webapp extern char myName[]; extern char myVer[]; +extern char myRotation[]; #include "fb_gfx.h" #include "fd_forward.h" @@ -603,7 +604,9 @@ static esp_err_t status_handler(httpd_req_t *req){ p+=sprintf(p, "\"face_enroll\":%u,", is_enrolling); p+=sprintf(p, "\"face_recognize\":%u,", recognition_enabled); p+=sprintf(p, "\"cam_name\":\"%s\",", myName); - p+=sprintf(p, "\"code_ver\":\"%s\"", myVer); + p+=sprintf(p, "\"code_ver\":\"%s\",", myVer); + // Serial.printf("Status Rotate \"%s\"\n",myRotation); + p+=sprintf(p, "\"rotate\":\"%s\"", myRotation); *p++ = '}'; *p++ = 0; httpd_resp_set_type(req, "application/json"); diff --git a/camera_index_ov2640.h b/camera_index_ov2640.h index 749b16d..c25c788 100644 --- a/camera_index_ov2640.h +++ b/camera_index_ov2640.h @@ -536,7 +536,7 @@ const uint8_t index_ov2640_html[] PROGMEM = R"=====(
- @@ -631,6 +631,8 @@ document.addEventListener('DOMContentLoaded', function (event) { const lampGroup = document.getElementById('lamp-group') const camName = document.getElementById('cam_name') const codeVer = document.getElementById('code_ver') + const rotate = document.getElementById('rotate') + if (updateRemote && initialValue !== value) { updateConfig(el); @@ -660,6 +662,11 @@ document.addEventListener('DOMContentLoaded', function (event) { window.document.title = value; } else if(el.id === "code_ver"){ codeVer.innerHTML = value; + } else if(el.id === "rotate"){ + rotate.value = value; + // setting value does not induce a onchange event + // this sets the figure transform css values + rotate.onchange(); } } } diff --git a/esp32-cam-webserver.ino b/esp32-cam-webserver.ino index ed7fa1c..8bcd024 100644 --- a/esp32-cam-webserver.ino +++ b/esp32-cam-webserver.ino @@ -38,6 +38,8 @@ #else const char* ssid = "my-access-point-ssid"; const char* password = "my-access-point-password"; + // used for wifi AP + const int wifichan = 5; #endif // A Name for the Camera. (can be set in myconfig.h) @@ -49,6 +51,7 @@ // This will be displayed to identify the firmware char myVer[] PROGMEM = __DATE__ " @ " __TIME__; +char myRotation[5]; #include "camera_pins.h" @@ -78,6 +81,17 @@ void setup() { Serial.print("Code Built: "); Serial.println(myVer); + // initial rotation + // can be set in myconfig.h + #ifndef CAM_ROTATION + #define CAM_ROTATION 0 + #endif + + // set the initialisation for image rotation + int n = snprintf(myRotation,sizeof(myRotation),"%d",CAM_ROTATION); + // Serial.printf("Config Rotation: \"%s\" size %d\n",myRotation,sizeof(myRotation)); + + #ifdef LED_PIN // If we have a notification LED set it to output pinMode(LED_PIN, OUTPUT); digitalWrite(LED_PIN, LED_OFF); @@ -158,6 +172,10 @@ void setup() { flashLED(400); delay(100); +#ifdef WIFI_AP + Serial.println("Setting up AP"); + WiFi.softAP(ssid, password, wifichan); +#else WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { @@ -165,6 +183,7 @@ void setup() { // - It would be good to do something else here as a future enhancement. // (eg: go to a captive AP config portal to configure the wifi) } +#endif // feedback that we are connected Serial.println("WiFi connected"); @@ -179,7 +198,11 @@ void setup() { startCameraServer(); Serial.print("Camera Ready! Use 'http://"); +#ifdef WIFI_AP + Serial.print(WiFi.softAPIP()); +#else Serial.print(WiFi.localIP()); +#endif Serial.println("' to connect"); } diff --git a/myconfig.sample.h b/myconfig.sample.h index 0fab624..6f72547 100644 --- a/myconfig.sample.h +++ b/myconfig.sample.h @@ -3,9 +3,15 @@ const char* ssid = "my-access-point-ssid"; const char* password = "my-access-point-password"; - +const int wifichan = 5; // Optionally give the camera a name for the web interface // (nb: this is not the network hostname) +#define CAM_NAME "UltiCam" + +// Optional initial rotation +#define CAM_ROTATION 90 + +// Optional AP setup +#define WIFI_AP -#define CAM_NAME "my-awesome-webcam"