Skip to content

Commit

Permalink
Merge pull request #7 from hpsaturn/improv_sample_minors
Browse files Browse the repository at this point in the history
Improv sample minors
  • Loading branch information
hpsaturn authored Feb 3, 2024
2 parents 3a428e3 + acf9a7c commit b700bfa
Show file tree
Hide file tree
Showing 24 changed files with 983 additions and 57 deletions.
67 changes: 37 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

ESPNowCam library, is a straightforward video streamer for popular ESP32Cam models, leveraging the ESPNow protocol. No need for IPs, routers, or credentials—keeping it simple! :D


**This library is for general purpose**, as it receives pointers to data, such as buffers, strings, images, or any byte-formatted content. This versatility allows you to transmit larger packages. For example, a buffer of 4000 bytes takes approximately 1/9 of a second, achieving a frame rate of around 9FPS

<table>
Expand All @@ -15,34 +14,45 @@ ESPNowCam library, is a straightforward video streamer for popular ESP32Cam mode
</tr>
</table>

## Tested devices
## Library installation

**Cameras:**
**PlatformIO**:

- [x] ESP32S3 Cam Freenove
- [x] M5CoreS3 builtin Camera
Add the following line to the lib_deps option of your [env:] section:

**Receivers:**
```python
hpsaturn/EspNowCam@^0.1.0
```

- [x] M5Core2 (AWS tested)
- [x] M5CoreS3
- [x] Makerfabs Parallel using LGFX
- [ ] Maybe any TFT with LGFX support (better with PSRAM)
Or via command line:

[![video demo](https://raw.githubusercontent.com/hpsaturn/esp32s3-cam/master/pictures/youtube.jpg)](https://youtu.be/zXIzP1TGlpA)
```python
pio pkg install --library "hpsaturn/ESPNowCam@^0.1.3"
```

**Arduino IDE**:

For `Arduino IDE` is a little bit more complicated because the Arduino IDE dependencies resolver is very bad, but you only need first download and install the [Nanopb library](https://github.com/nanopb/nanopb/releases/tag/nanopb-0.4.8) using the `Include Library` section via zip file, and then with the **Library Manager** find **ESPNowCam**

## Examples and Tests

[![video demo](https://raw.githubusercontent.com/hpsaturn/esp32s3-cam/master/pictures/youtube.jpg)](https://youtu.be/zXIzP1TGlpA)

| ENV Name | Target | Status |
|:-----------------|:--------------:|:----------:|
| freenove-espnow-sender | ESPNow camera transmitter | STABLE |
| freenove-hvga-sender | ESPNow camera transmitter | <6 FPS |
| m5cores3-espnow-sender | ESPNow built-in camera transmitter | STABLE |
| m5cores3-espnow-receiver | Video receiver via ESPNow [1] | STABLE|
| freenove-basic-sender | ESPNow camera transmitter (QVGA) | STABLE |
| freenove-hvga-sender | ESPNow camera transmitter (HVGA) | <6 FPS |
| freenove-nojpg-sender | ESPNow camera transmitter (NOJPG) | DEMO ONLY (<2FPS) |
| freenove-tank | Advanced sample. Sender/Receiver | INPROGRESS |
| m5core2-basic-receiver | Video receiver via ESPNow [1] | STABLE |
| m5core2-espnow-receiver | Video receiver via ESPNow [1] | STABLE |
| m5cores3-espnow-receiver | Video receiver via ESPNow [1] | STABLE|
| m5cores3-espnow-sender | ESPNow built-in camera transmitter | STABLE |
| m5stickCplus-joystick-tank | Advanced sample. Custom payload | INPROGRESS |
| makerfabs-basic-receiver | Video receiver via ESPNow [2] | STABLE |
| makerfabs-nojpg-receiver | Video receiver via ESPNow [2] | DEMO ONLY (<2FPS) |

[1] Use with freenove or M5CoreS3 espnow sender sample
[1] Use with freenove or M5CoreS3 senders sample
[2] Use with freenove HVGA sender sample

### Install examples
Expand All @@ -57,25 +67,20 @@ pio run -e m5cores3-espnow-receiver --target upload

Some examples, only needs run `pio run --target upload` into each directory

### Library installation

**PlatformIO**:

Add the following line to the lib_deps option of your [env:] section:
## Tested devices

```python
hpsaturn/EspNowCam@^0.1.0
```
**Cameras:**

Or via command line:
- [x] ESP32S3 Cam Freenove
- [x] M5CoreS3 builtin Camera

```python
pio pkg install --library "hpsaturn/ESPNowCam@^0.1.1"
```
**Receivers:**

**Arduino IDE**:
- [x] M5Core2 (AWS tested)
- [x] M5CoreS3
- [x] Makerfabs Parallel using LGFX
- [ ] Maybe any TFT with LGFX support (better with PSRAM)

For `Arduino IDE` is a little bit more complicated because the Arduino IDE dependencies resolver is very bad, but you only need first download and install the [Nanopb library](https://github.com/nanopb/nanopb/releases/tag/nanopb-0.4.8) using the `Include Library` section via zip file, and then with the **Library Manager** find **ESPNowCam**

## TODO

Expand All @@ -98,4 +103,6 @@ The Freenove camera sometimes needs good power cable and also takes some seconds

For Arduino IDE users, if you have a compiling error, maybe you forget install NanoPb library. Please see above.

This library was tested on PlatformIO and works with its manifest, on the other hand, in Arduino IDE (I'm not use it), was compiled ok there using Espressif 2.0.11 y Arduino IDE 2.2.1. I suggest to use PlatformIO instead Arduino IDE, because this last one mix everything, is so buggy and it's more complicated. Thanks to @ElectroZeusTIC to test it on Arduino IDE.

---
59 changes: 59 additions & 0 deletions common/CamFreenove.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include "CamFreenove.h"

static camera_config_t camera_config = {
.pin_pwdn = -1,
.pin_reset = -1,
.pin_xclk = 15,
.pin_sscb_sda = 4,
.pin_sscb_scl = 5,
.pin_d7 = 16,
.pin_d6 = 17,
.pin_d5 = 18,
.pin_d4 = 12,
.pin_d3 = 10,
.pin_d2 = 8,
.pin_d1 = 9,
.pin_d0 = 11,

.pin_vsync = 6,
.pin_href = 7,
.pin_pclk = 13,

.xclk_freq_hz = 20000000,
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,

.pixel_format = PIXFORMAT_RGB565,
.frame_size = FRAMESIZE_QVGA,
.jpeg_quality = 0,
.fb_count = 2,
.fb_location = CAMERA_FB_IN_PSRAM,
.grab_mode = CAMERA_GRAB_WHEN_EMPTY,
.sccb_i2c_port = 0
};

bool CamFreenove::begin() {

esp_err_t err = esp_camera_init(&camera_config);
if (err != ESP_OK) {
return false;
}
sensor = esp_camera_sensor_get();
return true;
}

bool CamFreenove::get() {
fb = esp_camera_fb_get();
if (!fb) {
return false;
}
return true;
}

bool CamFreenove::free() {
if (fb) {
esp_camera_fb_return(fb);
return true;
}
return false;
}
17 changes: 17 additions & 0 deletions common/CamFreenove.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef CAMFREENOVE_H
#define CAMFREENOVE_H

#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();
};

#endif
77 changes: 77 additions & 0 deletions common/S3_Parallel16_ili9488.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#define LGFX_USE_V1

#include <LovyanGFX.hpp>


class LGFX : public lgfx::LGFX_Device
{
// lgfx::Panel_ILI9341 _panel_instance;
lgfx::Panel_ILI9488 _panel_instance;
lgfx::Bus_Parallel16 _bus_instance; // 8ビットパラレルバスのインスタンス (ESP32のみ)

public:
// コンストラクタを作成し、ここで各種設定を行います。
// クラス名を変更した場合はコンストラクタも同じ名前を指定してください。
LGFX(void)
{
{ // バス制御の設定を行います。
auto cfg = _bus_instance.config(); // バス設定用の構造体を取得します。

// 16位设置
cfg.port = 0; // 使用するI2Sポートを選択 (0 or 1) (ESP32のI2S LCDモードを使用します)
cfg.freq_write = 20000000; // 送信クロック (最大20MHz, 80MHzを整数で割った値に丸められます)
cfg.pin_wr = 35; // WR を接続しているピン番号
cfg.pin_rd = 48; // RD を接続しているピン番号
cfg.pin_rs = 36; // RS(D/C)を接続しているピン番号

cfg.pin_d0 = 47;
cfg.pin_d1 = 21;
cfg.pin_d2 = 14;
cfg.pin_d3 = 13;
cfg.pin_d4 = 12;
cfg.pin_d5 = 11;
cfg.pin_d6 = 10;
cfg.pin_d7 = 9;
cfg.pin_d8 = 3;
cfg.pin_d9 = 8;
cfg.pin_d10 = 16;
cfg.pin_d11 = 15;
cfg.pin_d12 = 7;
cfg.pin_d13 = 6;
cfg.pin_d14 = 5;
cfg.pin_d15 = 4;

_bus_instance.config(cfg); // 設定値をバスに反映します。
_panel_instance.setBus(&_bus_instance); // バスをパネルにセットします。
}

{ // 表示パネル制御の設定を行います。
auto cfg = _panel_instance.config(); // 表示パネル設定用の構造体を取得します。

cfg.pin_cs = -1; // CS要拉低
cfg.pin_rst = -1; // RST和开发板RST相连
cfg.pin_busy = -1; // BUSYが接続されているピン番号 (-1 = disable)

// ※ 以下の設定値はパネル毎に一般的な初期値が設定されていますので、不明な項目はコメントアウトして試してみてください。

cfg.memory_width = 320; // ドライバICがサポートしている最大の幅
cfg.memory_height = 480; // ドライバICがサポートしている最大の高さ
cfg.panel_width = 320; // 実際に表示可能な幅
cfg.panel_height = 480; // 実際に表示可能な高さ
cfg.offset_x = 0; // パネルのX方向オフセット量
cfg.offset_y = 0; // パネルのY方向オフセット量
cfg.offset_rotation = 0; // 回転方向の値のオフセット 0~7 (4~7は上下反転)
cfg.dummy_read_pixel = 8; // ピクセル読出し前のダミーリードのビット数
cfg.dummy_read_bits = 1; // ピクセル以外のデータ読出し前のダミーリードのビット数
cfg.readable = true; // データ読出しが可能な場合 trueに設定
cfg.invert = false; // パネルの明暗が反転してしまう場合 trueに設定
cfg.rgb_order = false; // パネルの赤と青が入れ替わってしまう場合 trueに設定
cfg.dlen_16bit = true; // データ長を16bit単位で送信するパネルの場合 trueに設定
cfg.bus_shared = true; // SDカードとバスを共有している場合 trueに設定(drawJpgFile等でバス制御を行います)

_panel_instance.config(cfg);
}

setPanel(&_panel_instance); // 使用するパネルをセットします。
}
};
15 changes: 15 additions & 0 deletions common/comm.pb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.4.4 */

#include "comm.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif

PB_BIND(JoystickMessage, JoystickMessage, AUTO)


PB_BIND(TelemetryMessage, TelemetryMessage, AUTO)



Loading

0 comments on commit b700bfa

Please sign in to comment.