kopia lustrzana https://github.com/alanesq/esp32cam-demo
Porównaj commity
2 Commity
afe1961db1
...
4ef6ff08b9
Autor | SHA1 | Data |
---|---|---|
Alan | 4ef6ff08b9 | |
Alan | b65fadb0a7 |
|
@ -47,8 +47,8 @@
|
|||
|
||||
// Enter your Wifi Settings here
|
||||
|
||||
#define SSID_NAME "your wifi here"
|
||||
#define SSID_PASWORD "your wifi password here"
|
||||
#define SSID_NAME "<your wifi ssid here>"
|
||||
#define SSID_PASWORD "<your wifi password here>"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------
|
||||
|
@ -70,7 +70,8 @@
|
|||
void handleNotFound();
|
||||
void readRGBImage();
|
||||
bool getNTPtime(int sec);
|
||||
bool handleJPG();
|
||||
bool handleJPG();
|
||||
bool handleJpeg();
|
||||
void handleStream();
|
||||
int requestWebPage(String*, String*, int);
|
||||
void handleTest();
|
||||
|
@ -84,8 +85,8 @@
|
|||
// -SETTINGS
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
const char* stitle = "ESP32Cam-demo"; // title of this sketch
|
||||
const char* sversion = "14Jul23"; // Sketch version
|
||||
char* stitle = "ESP32Cam-demo"; // title of this sketch
|
||||
char* sversion = "27Jul23"; // Sketch version
|
||||
|
||||
bool sendRGBfile = 0; // if set '/rgb' will just return raw rgb data which can be saved as a file rather than display a HTML pag
|
||||
|
||||
|
@ -248,6 +249,7 @@ void setup() {
|
|||
server.on("/", handleRoot); // root page
|
||||
server.on("/data", handleData); // suplies data to periodically update root (AJAX)
|
||||
server.on("/jpg", handleJPG); // capture image and send as jpg
|
||||
server.on("/jpeg", handleJpeg); // show updating image
|
||||
server.on("/stream", handleStream); // stream live video
|
||||
server.on("/photo", handlePhoto); // save image to sd card
|
||||
server.on("/img", handleImg); // show image from sd card
|
||||
|
@ -877,7 +879,7 @@ void handleRoot() {
|
|||
rootUserInput(client); // Action any user input from this web page
|
||||
|
||||
// html header
|
||||
sendHeader(client, "ESP32Cam demo sketch");
|
||||
sendHeader(client, stitle);
|
||||
client.write("<FORM action='/' method='post'>\n"); // used by the buttons in the html (action = the web page to send it to
|
||||
|
||||
|
||||
|
@ -1520,6 +1522,51 @@ int requestWebPage(String* page, String* received, int maxWaitTime=5000){
|
|||
// ******************************************************************************************************************
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// -show updating image i.e. http://x.x.x.x/jpeg
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
void handleJpeg() {
|
||||
|
||||
int refreshRate = 2000; // image refresh rate (ms)
|
||||
|
||||
WiFiClient client = server.client(); // open link with client
|
||||
|
||||
// Start page
|
||||
client.write("HTTP/1.1 200 OK\r\n");
|
||||
client.write("Content-Type: text/html\r\n");
|
||||
client.write("Connection: close\r\n");
|
||||
client.write("\r\n");
|
||||
client.write("<!DOCTYPE HTML><html lang='en'>\n");
|
||||
client.write("<head></head><body>");
|
||||
|
||||
client.write("<FORM action='/' method='post'>\n"); // used by the buttons in the html (action = the web page to send it to
|
||||
|
||||
// capture and show a jpg image
|
||||
client.write("<img id='image1' src='/jpg'/>"); // show image from http://x.x.x.x/jpg
|
||||
|
||||
// javascript to refresh the image periodically
|
||||
client.printf(R"=====(
|
||||
<script>
|
||||
function refreshImage(){
|
||||
var timestamp = new Date().getTime();
|
||||
var el = document.getElementById('image1');
|
||||
var queryString = '?t=' + timestamp;
|
||||
el.src = '/jpg' + queryString;
|
||||
}
|
||||
setInterval(function() { refreshImage(); }, %d);
|
||||
</script>
|
||||
)=====", refreshRate);
|
||||
|
||||
|
||||
sendFooter(client); // close web page
|
||||
|
||||
} // handleJpeg
|
||||
|
||||
|
||||
// ******************************************************************************************************************
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// -test procedure i.e. http://x.x.x.x/test
|
||||
// ----------------------------------------------------------------
|
||||
|
|
|
@ -89,12 +89,14 @@ as data (http://x.x.x.x/rgb).
|
|||
|
||||
URLs:
|
||||
<br>http://x.x.x.x/ Hello message
|
||||
<br>http://x.x.x.x/jpg capture image and display as a JPG
|
||||
<br>http://x.x.x.x/jpeg as above but refreshes every 2 seconds
|
||||
<br>http://x.x.x.x/photo Capture an image and save to sd card
|
||||
<br>http://x.x.x.x/stream Show live streaming video
|
||||
<br>http://x.x.x.x/img Show most recent image saved to sd card
|
||||
<br>http://x.x.x.x/img?img=1 Show image number 1 on sd card
|
||||
<br>http://x.x.x.x/rgb Captures an image and converts to RGB data (will not work with the highest
|
||||
resolution images as there is not enough memory)
|
||||
resolution images as there is not enough memory)
|
||||
|
||||
GPIO PINS:
|
||||
<br> 13 free (used by sd card but free if using 1 bit mode)
|
||||
|
|
Ładowanie…
Reference in New Issue