-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from hpsaturn/devel
Devel
- Loading branch information
Showing
12 changed files
with
416 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/************************************************** | ||
* ESPNowCam video Transmitter | ||
* by @hpsaturn Copyright (C) 2024 | ||
* This file is part ESP32S3 camera tests project: | ||
* https://github.com/hpsaturn/esp32s3-cam | ||
**************************************************/ | ||
|
||
#include <Arduino.h> | ||
#include <esp_camera.h> | ||
#include <ESPNowCam.h> | ||
#include <Utils.h> | ||
|
||
ESPNowCam radio; | ||
camera_fb_t* fb; | ||
|
||
bool has_psram = false; | ||
|
||
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(); | ||
} |
46 changes: 46 additions & 0 deletions
46
examples/tjournal-espnow-sender/tjournal-espnow-sender.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/************************************************** | ||
* ESPNowCam video Transmitter | ||
* by @hpsaturn Copyright (C) 2024 | ||
* This file is part ESP32S3 camera tests project: | ||
* https://github.com/hpsaturn/esp32s3-cam | ||
**************************************************/ | ||
|
||
#include <Arduino.h> | ||
#include <ESPNowCam.h> | ||
#include <drivers/CamTJournal.h> | ||
#include <Utils.h> | ||
|
||
CamTJournal Camera; | ||
ESPNowCam radio; | ||
|
||
void processFrame() { | ||
if (Camera.get()) { | ||
radio.sendData(Camera.fb->buf, Camera.fb->len); | ||
delay(25); // ==> weird delay for this camera. | ||
printFPS("CAM:"); | ||
Camera.free(); | ||
} | ||
} | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
delay(5000); // only for debugging | ||
|
||
if(psramFound()){ | ||
size_t psram_size = esp_spiram_get_size() / 1048576; | ||
Serial.printf("PSRAM size: %dMb\r\n", psram_size); | ||
} | ||
|
||
radio.init(); | ||
if (!Camera.begin()) { | ||
Serial.println("Camera Init Fail"); | ||
delay(1000); | ||
ESP.restart(); | ||
} | ||
delay(500); | ||
} | ||
|
||
void loop() { | ||
processFrame(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/************************************************** | ||
* ESPNowCam video Transmitter. | ||
* ---------------------------- | ||
* | ||
* XIAO FPV ESPNow transmitter uses some extra features of | ||
* this board to have some power consumption improvements | ||
* | ||
* by @hpsaturn Copyright (C) 2024 | ||
* This file is part ESP32S3 camera tests project: | ||
* https://github.com/hpsaturn/esp32s3-cam | ||
**************************************************/ | ||
|
||
#include <Arduino.h> | ||
#include <OneButton.h> | ||
#include <ESPNowCam.h> | ||
#include <drivers/CamXiao.h> | ||
#include <Utils.h> | ||
|
||
CamXiao Camera; | ||
ESPNowCam radio; | ||
OneButton btnB(GPIO_NUM_0, true); | ||
|
||
void processFrame() { | ||
if (Camera.get()) { | ||
uint8_t *out_jpg = NULL; | ||
size_t out_jpg_len = 0; | ||
frame2jpg(Camera.fb, 12, &out_jpg, &out_jpg_len); | ||
radio.sendData(out_jpg, out_jpg_len); | ||
printFPS("CAM:"); | ||
free(out_jpg); | ||
Camera.free(); | ||
} | ||
} | ||
|
||
void shutdown() { | ||
Serial.println("shutdown.."); | ||
esp_sleep_enable_ext0_wakeup(GPIO_NUM_0,0); | ||
delay(1000); | ||
esp_deep_sleep_start(); | ||
} | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
delay(1000); // only for debugging | ||
|
||
if(psramFound()){ | ||
size_t psram_size = esp_spiram_get_size() / 1048576; | ||
Serial.printf("PSRAM size: %dMb\r\n", psram_size); | ||
} | ||
|
||
radio.init(); | ||
if (!Camera.begin()) { | ||
Serial.println("Camera Init Fail"); | ||
delay(1000); | ||
} | ||
|
||
btnB.attachClick([]() { shutdown(); }); | ||
delay(100); | ||
} | ||
|
||
void loop() { | ||
processFrame(); | ||
btnB.tick(); | ||
} |
Oops, something went wrong.