Code cleanup

This commit is contained in:
Anatoli Arkhipenko 2024-09-27 10:00:18 -04:00
parent 3b0ee3a704
commit ea7a76a216
5 changed files with 10 additions and 41 deletions

View file

@ -2,6 +2,9 @@
// ==== includes =================================
#include "references.h"
#define MILLIS_FUNCTION xTaskGetTickCount()
// #define MILLIS_FUNCTION millis()
// ==== prototypes ===============================
void setupLogging();

View file

@ -14,7 +14,7 @@ void setupLogging() {
// === millis() - based timestamp ==
void printTimestamp(Print* logOutput) {
char c[24];
sprintf(c, "%10lu ", (long unsigned int) xTaskGetTickCount()/*millis()*/);
sprintf(c, "%10lu ", (long unsigned int) MILLIS_FUNCTION);
logOutput->print(c);
}
@ -22,7 +22,7 @@ void printTimestamp(Print* logOutput) {
// start-time-based timestamp ========
void printTimestampMillis(Print* logOutput) {
char c[64];
unsigned long mm = xTaskGetTickCount();//millis();
unsigned long mm = MILLIS_FUNCTION;
int ms = mm % 1000;
int s = mm / 1000;
int m = s / 60;

View file

@ -1,23 +1,14 @@
/*
This is a simple MJPEG streaming webserver implemented for AI-Thinker ESP32-CAM
This is a MJPEG streaming webserver implemented for AI-Thinker ESP32-CAM
and ESP-EYE modules.
This is tested to work with VLC and Blynk video widget and can support up to 10
simultaneously connected streaming clients.
Simultaneous streaming is implemented with dedicated FreeRTOS tasks.
Simultaneous streaming is implemented with FreeRTOS tools: queue and tasks.
Inspired by and based on this Instructable: $9 RTSP Video Streamer Using the ESP32-CAM Board
(https://www.instructables.com/id/9-RTSP-Video-Streamer-Using-the-ESP32-CAM-Board/)
Board: AI-Thinker ESP32-CAM or ESP-EYE
Compile as:
ESP32 Dev Module
CPU Freq: 240
Flash Freq: 80
Flash mode: QIO
Flash Size: 4Mb
Partrition: Minimal SPIFFS
PSRAM: Enabled
*/
#include "definitions.h"
@ -44,11 +35,6 @@ const char *c_pwd = AP_PWD;
// Camera models overview:
// https://randomnerdtutorials.com/esp32-cam-camera-pin-gpios/
// #define CAMERA_MODEL_WROVER_KIT
// #define CAMERA_MODEL_ESP_EYE
// #define CAMERA_MODEL_M5STACK_PSRAM
// #define CAMERA_MODEL_M5STACK_WIDE
// #define CAMERA_MODEL_AI_THINKER
#include "camera_pins.h"
@ -56,11 +42,11 @@ WebServer server(80);
// ===== rtos task handles =========================
// Streaming is implemented with tasks:
TaskHandle_t tMjpeg; // handles client connections to the webserver
TaskHandle_t tCam; // handles getting picture frames from the camera and storing them locally
TaskHandle_t tMjpeg; // handles client connections to the webserver
TaskHandle_t tCam; // handles getting picture frames from the camera and storing them locally
TaskHandle_t tStream;
uint8_t noActiveClients; // number of active clients
uint8_t noActiveClients; // number of active clients
// frameSync semaphore is used to prevent streaming buffer as it is replaced with the next frame
SemaphoreHandle_t frameSync = NULL;
@ -119,22 +105,6 @@ void setup()
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
.pixel_format = PIXFORMAT_JPEG,
/*
FRAMESIZE_96X96, // 96x96
FRAMESIZE_QQVGA, // 160x120
FRAMESIZE_QCIF, // 176x144
FRAMESIZE_HQVGA, // 240x176
FRAMESIZE_240X240, // 240x240
FRAMESIZE_QVGA, // 320x240
FRAMESIZE_CIF, // 400x296
FRAMESIZE_HVGA, // 480x320
FRAMESIZE_VGA, // 640x480
FRAMESIZE_SVGA, // 800x600
FRAMESIZE_XGA, // 1024x768
FRAMESIZE_HD, // 1280x720
FRAMESIZE_SXGA, // 1280x1024
FRAMESIZE_UXGA, // 1600x1200
*/
.frame_size = FRAME_SIZE,
.jpeg_quality = JPEG_QUALITY,
.fb_count = 2,
@ -202,6 +172,5 @@ void setup()
}
void loop() {
// vTaskDelay(1000);
vTaskDelete(NULL);
}

View file

@ -19,7 +19,6 @@ void camCB(void* pvParameters) {
// Grab a frame from the camera and allocate frame chunk for it
fb = esp_camera_fb_get();
// frameChunck_t* f = (frameChunck_t*) ps_malloc( sizeof(frameChunck_t) );
frameChunck_t* f = (frameChunck_t*) allocateMemory(NULL, sizeof(frameChunck_t), true);
if ( f ) {
// char* d = (char*) ps_malloc( fb->len );

View file

@ -2,8 +2,6 @@
#if defined(CAMERA_MULTICLIENT_QUEUE)
// frameChunck_t frameChunck;
// streamInfo_t streamInfo;
QueueHandle_t streamingClients;
volatile size_t camSize; // size of the current frame, byte