Added rotation initialisation - allows to start with say 90deg. + Wifi AP option (#9)

Changes from JMfloyd:
*Allow to define an initial rotation value (compiled in) on startup; sets the select object, and initialises the figure transformations.
*Allows option to setup a wifi AP for standalone operation; My setup is for a rear camera on a trailer which requires a 90 rotation
* Additional myconfig options for rotation and wifi AP
This commit is contained in:
jmfloyd
2020-08-22 02:36:36 +10:00
committed by GitHub
parent c73adfd4ec
commit 15b3db536c
4 changed files with 43 additions and 4 deletions

View File

@ -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");

View File

@ -536,7 +536,7 @@ const uint8_t index_ov2640_html[] PROGMEM = R"=====(
</div>
<div class="input-group" id="rotate-group">
<label for="rotate">Rotate</label>
<select id="rotate" class="rotate-action">
<select id="rotate" class="default-action">
<option value="0" selected="selected">None</option>
<option value="90">Rotate Right</option>
<option value="-90">Rotate Left</option>
@ -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();
}
}
}

View File

@ -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");
}

View File

@ -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"