diff --git a/README.md b/README.md index 5e87a6c..d898638 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ This project was developed and thoroughly tested on PlatformIO. While I did comp - [x] ESP32S3 Freenove Camera - [x] M5CoreS3 (builtin Camera) - [x] XIAO ESP32S3 Sense Camera +- [x] Unit-CamS3 ([Howto guide](https://zenn.dev/aoya_uta/articles/f8e93d3fbff3d5)) **Receivers:** @@ -189,7 +190,6 @@ This project was developed and thoroughly tested on PlatformIO. While I did comp - [x] NanoPb possible issue #1 (payload size) - [x] Unified ESPNow in an one class for all transmitters and receivers - [x] Isolate the ESPNow Receiver and Transmitter in a seperated library -- [x] Unified and migrated to only one header `ESPNowCam.h` - [x] Add sender callback to improve speed - [ ] Add callback to Radio send action. issue #20 - [ ] Migration to esp_wifi_80211_tx() to improve Payload and Quality diff --git a/examples/custom-camera-sender/custom-camera-sender.cpp b/examples/custom-camera-sender/custom-camera-sender.cpp index f1b12fc..5ed8c42 100644 --- a/examples/custom-camera-sender/custom-camera-sender.cpp +++ b/examples/custom-camera-sender/custom-camera-sender.cpp @@ -15,6 +15,7 @@ camera_fb_t* fb; bool has_psram = false; +// Please change this to your Camera pins: camera_config_t camera_config = { .pin_pwdn = -1, .pin_reset = 15, @@ -90,7 +91,7 @@ void processFrame() { void setup() { Serial.begin(115200); - delay(5000); // only for debugging + delay(1000); // only for debugging if(psramFound()){ has_psram = true; diff --git a/examples/generic-camera-nopsram/generic-camera-nopsram.ino b/examples/generic-camera-nopsram/generic-camera-nopsram.ino new file mode 100644 index 0000000..e0363ab --- /dev/null +++ b/examples/generic-camera-nopsram/generic-camera-nopsram.ino @@ -0,0 +1,99 @@ +/************************************************** + * ESPNowCam video Transmitter + * by @hpsaturn Copyright (C) 2024 + * This file is part ESP32S3 camera tests project: + * https://github.com/hpsaturn/esp32s3-cam +**************************************************/ + +#include +#include +#include +#include + +ESPNowCam radio; +camera_fb_t* fb; + +bool has_psram = false; + +// Please change this to your Camera pins: +camera_config_t camera_config = { + .pin_pwdn = -1, + .pin_reset = 15, + .pin_xclk = 27, + .pin_sscb_sda = 25, + .pin_sscb_scl = 23, + .pin_d7 = 19, + .pin_d6 = 36, + .pin_d5 = 18, + .pin_d4 = 39, + .pin_d3 = 5, + .pin_d2 = 34, + .pin_d1 = 35, + .pin_d0 = 17, + .pin_vsync = 22, + .pin_href = 26, + .pin_pclk = 21, + + .xclk_freq_hz = 20000000, + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + + .pixel_format = PIXFORMAT_JPEG, + .frame_size = FRAMESIZE_QVGA, + .jpeg_quality = 12, + .fb_count = 1, + .fb_location = CAMERA_FB_IN_DRAM, + .grab_mode = CAMERA_GRAB_WHEN_EMPTY, +}; + +bool CameraBegin() { + esp_err_t err = esp_camera_init(&camera_config); + if (err != ESP_OK) { + return false; + } + return true; +} + +bool CameraGet() { + fb = esp_camera_fb_get(); + if (!fb) { + return false; + } + return true; +} + +bool CameraFree() { + if (fb) { + esp_camera_fb_return(fb); + return true; + } + return false; +} + +void processFrame() { + if (CameraGet()) { + radio.sendData(fb->buf, fb->len); + delay(30); // ==> weird delay for cameras without PSRAM + printFPS("CAM:"); + CameraFree(); + } +} + +void setup() { + Serial.begin(115200); + + delay(1000); // only for debugging + + radio.init(); + + if (!CameraBegin()) { + Serial.println("Camera Init Fail"); + delay(1000); + ESP.restart(); + } + delay(500); +} + +void loop() { + processFrame(); +} diff --git a/examples/generic-camera-nopsram/platformio.ini b/examples/generic-camera-nopsram/platformio.ini new file mode 100644 index 0000000..0e71003 --- /dev/null +++ b/examples/generic-camera-nopsram/platformio.ini @@ -0,0 +1,25 @@ +; ESPNowCam Freenove ESP32S3CAM +; https://github.com/hpsaturn/esp32s3-cam +; @Hpsaturn 2024 + +[platformio] +src_dir = ./ + +[env] +platform = espressif32 @ 4.4.0 +framework = arduino +monitor_speed = 115200 +monitor_filters = + esp32_exception_decoder + time +build_flags = + -D CORE_DEBUG_LEVEL=0 + +[esp32common] +extends = env +board = esp32dev + +[env:generic-camera-nopsram] +extends = esp32common +lib_deps = + hpsaturn/EspNowCam@^0.1.8 diff --git a/examples/generic-camera-psram/generic-camera-psram.ino b/examples/generic-camera-psram/generic-camera-psram.ino new file mode 100644 index 0000000..16c293c --- /dev/null +++ b/examples/generic-camera-psram/generic-camera-psram.ino @@ -0,0 +1,121 @@ +/************************************************** + * ESPNowCam video Transmitter + * by @hpsaturn Copyright (C) 2024 + * This file is part ESP32S3 camera tests project: + * https://github.com/hpsaturn/esp32s3-cam +**************************************************/ + +#include +#include +#include +#include + +ESPNowCam radio; +camera_fb_t* fb; + +bool has_psram = false; + +// Please change this to your Camera pins: +camera_config_t camera_config = { + .pin_pwdn = -1, + .pin_reset = 15, + .pin_xclk = 27, + .pin_sscb_sda = 25, + .pin_sscb_scl = 23, + .pin_d7 = 19, + .pin_d6 = 36, + .pin_d5 = 18, + .pin_d4 = 39, + .pin_d3 = 5, + .pin_d2 = 34, + .pin_d1 = 35, + .pin_d0 = 17, + .pin_vsync = 22, + .pin_href = 26, + .pin_pclk = 21, + + .xclk_freq_hz = 20000000, + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + + .pixel_format = PIXFORMAT_JPEG, + .frame_size = FRAMESIZE_QVGA, + .jpeg_quality = 12, + .fb_count = 1, + .fb_location = CAMERA_FB_IN_DRAM, + .grab_mode = CAMERA_GRAB_WHEN_EMPTY, +}; + +bool CameraBegin() { + esp_err_t err = esp_camera_init(&camera_config); + if (err != ESP_OK) { + return false; + } + return true; +} + +bool CameraGet() { + fb = esp_camera_fb_get(); + if (!fb) { + return false; + } + return true; +} + +bool CameraFree() { + if (fb) { + esp_camera_fb_return(fb); + return true; + } + return false; +} + +void processFrame() { + if (CameraGet()) { + if (has_psram) { + uint8_t *out_jpg = NULL; + size_t out_jpg_len = 0; + frame2jpg(fb, 12, &out_jpg, &out_jpg_len); + radio.sendData(out_jpg, out_jpg_len); + free(out_jpg); + } + else{ + radio.sendData(fb->buf, fb->len); + delay(30); // ==> weird delay for cameras without PSRAM + } + printFPS("CAM:"); + CameraFree(); + } +} + +void setup() { + Serial.begin(115200); + + delay(5000); // only for debugging + + if(psramFound()){ + has_psram = true; + size_t psram_size = esp_spiram_get_size() / 1048576; + Serial.printf("PSRAM size: %dMb\r\n", psram_size); + // suggested config with PSRAM + camera_config.pixel_format = PIXFORMAT_RGB565; + camera_config.fb_location = CAMERA_FB_IN_PSRAM; + camera_config.fb_count = 2; + } + else{ + Serial.println("PSRAM not found! Basic framebuffer setup."); + } + + radio.init(); + + if (!CameraBegin()) { + Serial.println("Camera Init Fail"); + delay(1000); + ESP.restart(); + } + delay(500); +} + +void loop() { + processFrame(); +} diff --git a/examples/generic-camera-psram/platformio.ini b/examples/generic-camera-psram/platformio.ini new file mode 100644 index 0000000..6dd039b --- /dev/null +++ b/examples/generic-camera-psram/platformio.ini @@ -0,0 +1,29 @@ +; ESPNowCam Freenove ESP32S3CAM +; https://github.com/hpsaturn/esp32s3-cam +; @Hpsaturn 2024 + +[platformio] +src_dir = ./ + +[env] +platform = espressif32 +framework = arduino +monitor_speed = 115200 +monitor_filters = + esp32_exception_decoder + time +build_flags = + -D CORE_DEBUG_LEVEL=0 + -D BOARD_HAS_PSRAM=1 + +[esp32common] +extends = env +board = esp32-s3-devkitc-1 +board_build.flash_size = 16MB +board_build.partitions = ../../config/partitions.csv + +[env:generic-camera-psram] +extends = esp32common +board_build.arduino.memory_type = dio_opi ; +lib_deps = + hpsaturn/EspNowCam@^0.1.8 diff --git a/examples/m5stickCplus-joystick-tank/icon.c b/examples/m5stickCplus-joystick-tank/icon.c old mode 100755 new mode 100644 diff --git a/examples/tft-3.5-basic-receiver/S3_Parallel8_ili9486.h b/examples/tft-3.5-basic-receiver/S3_Parallel8_ili9486.h old mode 100755 new mode 100644 diff --git a/examples/tft-3.5-basic-receiver/platformio.ini b/examples/tft-3.5-basic-receiver/platformio.ini old mode 100755 new mode 100644 diff --git a/examples/tft-3.5-basic-receiver/tft-3.5-basic-receiver.ino b/examples/tft-3.5-basic-receiver/tft-3.5-basic-receiver.ino old mode 100755 new mode 100644