Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devel #33

Merged
merged 9 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/platformio.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
name: PlatformIO

on:
push:
branches:
- master
paths-ignore:
- '**/README.md'

pull_request:
branches:
- master
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@ The library includes some pre-defined camera configs to have an easy implementat
CamFreenove Camera;
```

for now, it includes drivers for FreenoveS3, XIAOS3, and the TTGO T-Journal cameras, but you are able to define your custom camera like is shown in the [custom-camera-sender](examples/custom-camera-sender/) example. If you can run it in a different camera, please notify me :D
and you able to change the Camera parameters, e.g:

```cpp
Camera.config.fb_count = 2;
Camera.config.frame_size = FRAMESIZE_QQVGA;
```

For now, it includes drivers for FreenoveS3, XIAOS3, M5UnitCamS3, and the TTGO T-Journal cameras, but you are able to define your custom camera like is shown in the [custom-camera-sender](examples/custom-camera-sender/) example. If you can run it in a different camera, please notify me :D

## Examples

Expand Down Expand Up @@ -192,7 +199,7 @@ This project was developed and thoroughly tested on PlatformIO. While I did comp
- [x] Unified ESPNow in an one class for all transmitters and receivers
- [x] Isolate the ESPNow Receiver and Transmitter in a seperated library
- [x] Add sender callback to improve speed
- [ ] Add callback to Radio send action. issue #20
- [x] Added internal drivers for some popular Cameras
- [ ] Migration to esp_wifi_80211_tx() to improve Payload and Quality

## Credits
Expand Down
4 changes: 4 additions & 0 deletions examples/freenove-basic-sender/freenove-basic-sender.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ void setup() {
// uint8_t macRecv[6] = {0xB8,0xFF,0x09,0xC6,0x0E,0xCC};
// radio.setTarget(macRecv);
radio.init();

// You are able to change the Camera config E.g:
// Camera.config.fb_count = 2;
// Camera.config.frame_size = FRAMESIZE_QQVGA;

if (!Camera.begin()) {
Serial.println("Camera Init Fail");
Expand Down
8 changes: 3 additions & 5 deletions examples/m5cores3-espnow-sender/m5cores3-espnow-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ void processFrame() {
uint8_t *out_jpg = NULL;
size_t out_jpg_len = 0;
frame2jpg(CoreS3.Camera.fb, 18, &out_jpg, &out_jpg_len);
// Serial.printf("JPG len %i\r\n",out_jpg_len);
CoreS3.Display.drawJpg(out_jpg, out_jpg_len, 0, 0, dw, dh);
// CoreS3.Display.drawJpg(out_jpg, out_jpg_len, 0, 0, dw, dh);
radio.sendData(out_jpg, out_jpg_len);
// printFPS("CAM:");
// drawFPS();
printFPS("CAM:");
free(out_jpg);
CoreS3.Camera.free();
}
Expand Down Expand Up @@ -65,7 +63,7 @@ void setup() {
if (!CoreS3.Camera.begin()) {
CoreS3.Display.drawString("Camera Init Fail", dw / 2, dh / 2);
}
// CoreS3.Display.drawString("Camera Init Success", dw / 2, dh / 2);
CoreS3.Display.drawString("Camera Init Success", dw / 2, dh / 2);
CoreS3.Camera.sensor->set_framesize(CoreS3.Camera.sensor, FRAMESIZE_QVGA);

delay(500);
Expand Down
9 changes: 7 additions & 2 deletions examples/tjournal-espnow-sender/tjournal-espnow-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ESPNowCam radio;
void processFrame() {
if (Camera.get()) {
radio.sendData(Camera.fb->buf, Camera.fb->len);
delay(25); // ==> weird delay for this camera.
delay(35); // ==> weird delay for NOPSRAM camera.
printFPS("CAM:");
Camera.free();
}
Expand All @@ -25,14 +25,19 @@ void processFrame() {
void setup() {
Serial.begin(115200);

delay(5000); // only for debugging
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();

// You are able to change the Camera config E.g:
// Camera.config.fb_count = 2;
// Camera.config.frame_size = FRAMESIZE_QQVGA;

if (!Camera.begin()) {
Serial.println("Camera Init Fail");
delay(1000);
Expand Down
2 changes: 1 addition & 1 deletion examples/unitcams3-basic-sender/unitcams3-basic-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void processFrame() {
void setup() {
Serial.begin(115200);

delay(5000); // only for debugging
delay(1000); // only for debugging

if(psramFound()){
size_t psram_size = esp_spiram_get_size() / 1048576;
Expand Down
12 changes: 10 additions & 2 deletions examples/xiao-espnow-sender/xiao-espnow-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ void processFrame() {
void setup() {
Serial.begin(115200);

delay(5000); // only for debugging
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 (!radio.init()) {
Serial.println("Radio Init Fail");
delay(1000);
}

// You are able to change the Camera config E.g:
// Camera.config.fb_count = 2;
// Camera.config.frame_size = FRAMESIZE_QQVGA;

if (!Camera.begin()) {
Serial.println("Camera Init Fail");
delay(1000);
Expand Down
4 changes: 4 additions & 0 deletions examples/xiao-fpv-sender/xiao-fpv-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ void setup() {
}

radio.init();

// You are able to change the Camera config E.g:
// Camera.config.frame_size = FRAMESIZE_QQVGA;

if (!Camera.begin()) {
Serial.println("Camera Init Fail");
delay(1000);
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "EspNowCam",
"version": "0.1.9",
"version": "0.1.10",
"homepage":"https://github.com/hpsaturn/esp32s3-cam",
"keywords":
[
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=EspNowCam
version=0.1.9
version=0.1.10
author=@hpsaturn
maintainer=Antonio Vanegas <[email protected]>
sentence=ESPNowCam, a straightforward video streamer for popular ESP32Cam models, leveraging the ESPNow protocol. No need for IPs, routers, or credentials—keeping it simple! :D
Expand Down
2 changes: 0 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ platform = espressif32 @ 4.4.0
extends = env
board = esp32dev
build_src_filter = -<*> -<*common*> +<tjournal-espnow-sender/>
build_flags =
-D CORE_DEBUG_LEVEL=0

[env:custom-camera-sender]
platform = espressif32 @ 4.4.0
Expand Down
24 changes: 12 additions & 12 deletions src/ESPNowCam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ bool sendMessage(uint32_t msglen, const uint8_t *mac) {
esp_err_t result = esp_now_send(mac, send_buffer, msglen);

if (result == ESP_OK) {
// Serial.println("send msg success");
log_v("send msg success");
return true;
} else if (result == ESP_ERR_ESPNOW_NOT_INIT) {
Serial.println("ESPNOW not Init.");
log_e("ESPNOW not Init.");
} else if (result == ESP_ERR_ESPNOW_ARG) {
Serial.println("Invalid Argument");
log_e("Invalid Argument");
} else if (result == ESP_ERR_ESPNOW_INTERNAL) {
Serial.println("Internal Error");
log_e("Internal Error");
} else if (result == ESP_ERR_ESPNOW_NO_MEM) {
Serial.println("ESP_ERR_ESPNOW_NO_MEM");
log_e("ESP_ERR_ESPNOW_NO_MEM");
} else if (result == ESP_ERR_ESPNOW_NOT_FOUND) {
Serial.println("Peer not found.");
log_e("Peer not found.");
} else {
Serial.println("Unknown error");
log_e("Unknown error");
}
return false;
}
Expand Down Expand Up @@ -128,7 +128,7 @@ bool decodeMessage(uint16_t message_length) {
msg_recv.data.funcs.decode = &decode_data;
bool status = pb_decode(&stream, Frame_fields, &msg_recv);
if (!status) {
Serial.printf("Decoding msg failed: %s\r\n", PB_GET_ERROR(&stream));
log_w("Decoding msg failed: %s\r\n", PB_GET_ERROR(&stream));
return false;
}
return true;
Expand Down Expand Up @@ -159,19 +159,19 @@ bool ESPNowCam::init(uint8_t chunk_size) {
chunksize = chunk_size;
chunk_size_left = chunk_size;
WiFi.mode(WIFI_STA);
Serial.println("ESPNow Init");
Serial.println(WiFi.macAddress());
log_i("ESPNow Init");
log_i("%s",WiFi.macAddress().c_str());
// shutdown wifi
WiFi.disconnect();
delay(100);

if (esp_now_init() == ESP_OK) {
Serial.println("ESPNow Init Success");
log_i("ESPNow Init Success");
esp_now_register_recv_cb(msgReceiveCb);
esp_now_register_send_cb(msgSentCb);
return true;
} else {
Serial.println("ESPNow Init Failed");
log_e("ESPNow Init Failed");
delay(100);
ESP.restart();
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/ESPNowCam.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ extern "C" {
typedef void (*RecvCb)(uint32_t lenght);
}

#define CSL_VERSION "0.1.9"
#define CSL_REVISION 074
#define CSL_VERSION "0.1.10"
#define CSL_REVISION 075

class ESPNowCam {
private:
Expand Down
58 changes: 0 additions & 58 deletions src/drivers/CamFreenove.cpp

This file was deleted.

43 changes: 34 additions & 9 deletions src/drivers/CamFreenove.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
#ifndef CAMFREENOVE_H
#define CAMFREENOVE_H

#include "CameraBase.hpp"
#include "esp_camera.h"

class CamFreenove {
private:
public:
camera_fb_t* fb;
sensor_t* sensor;
camera_config_t* config;
bool begin();
bool get();
bool free();
class CamFreenove : public CameraBase {
public:
using CameraBase::begin;
using CameraBase::free;
using CameraBase::get;

CamFreenove() {
config.pin_pwdn = -1;
config.pin_reset = -1;
config.pin_xclk = 15;
config.pin_sccb_sda = 4;
config.pin_sccb_scl = 5;
config.pin_d7 = 16;
config.pin_d6 = 17;
config.pin_d5 = 18;
config.pin_d4 = 12;
config.pin_d3 = 10;
config.pin_d2 = 8;
config.pin_d1 = 9;
config.pin_d0 = 11;
config.pin_vsync = 6;
config.pin_href = 7;
config.pin_pclk = 13;
config.xclk_freq_hz = 20000000;
config.ledc_timer = LEDC_TIMER_0;
config.ledc_channel = LEDC_CHANNEL_0;
config.pixel_format = PIXFORMAT_RGB565;
config.frame_size = FRAMESIZE_QVGA;
config.jpeg_quality = 0;
config.fb_count = 2;
config.fb_location = CAMERA_FB_IN_PSRAM;
config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
}
};

#endif
Loading
Loading