Porównaj commity

...

2 Commity

Autor SHA1 Wiadomość Data
Alan 4ef6ff08b9
Update README.md 2023-07-27 09:48:11 +01:00
Alan b65fadb0a7
Update ESP32cam-demo.ino 2023-07-27 09:46:20 +01:00
2 zmienionych plików z 56 dodań i 7 usunięć

Wyświetl plik

@ -47,8 +47,8 @@
// Enter your Wifi Settings here // Enter your Wifi Settings here
#define SSID_NAME "your wifi here" #define SSID_NAME "<your wifi ssid here>"
#define SSID_PASWORD "your wifi password here" #define SSID_PASWORD "<your wifi password here>"
// --------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------
@ -70,7 +70,8 @@
void handleNotFound(); void handleNotFound();
void readRGBImage(); void readRGBImage();
bool getNTPtime(int sec); bool getNTPtime(int sec);
bool handleJPG(); bool handleJPG();
bool handleJpeg();
void handleStream(); void handleStream();
int requestWebPage(String*, String*, int); int requestWebPage(String*, String*, int);
void handleTest(); void handleTest();
@ -84,8 +85,8 @@
// -SETTINGS // -SETTINGS
// --------------------------------------------------------------- // ---------------------------------------------------------------
const char* stitle = "ESP32Cam-demo"; // title of this sketch char* stitle = "ESP32Cam-demo"; // title of this sketch
const char* sversion = "14Jul23"; // Sketch version 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 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("/", handleRoot); // root page
server.on("/data", handleData); // suplies data to periodically update root (AJAX) server.on("/data", handleData); // suplies data to periodically update root (AJAX)
server.on("/jpg", handleJPG); // capture image and send as jpg 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("/stream", handleStream); // stream live video
server.on("/photo", handlePhoto); // save image to sd card server.on("/photo", handlePhoto); // save image to sd card
server.on("/img", handleImg); // show image from 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 rootUserInput(client); // Action any user input from this web page
// html header // 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 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 // -test procedure i.e. http://x.x.x.x/test
// ---------------------------------------------------------------- // ----------------------------------------------------------------

Wyświetl plik

@ -89,12 +89,14 @@ as data (http://x.x.x.x/rgb).
URLs: URLs:
<br>http://x.x.x.x/ Hello message <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/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/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 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/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 <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: GPIO PINS:
<br> 13 free (used by sd card but free if using 1 bit mode) <br> 13 free (used by sd card but free if using 1 bit mode)