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

Makerfab refactor #35

Merged
merged 5 commits into from
May 7, 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
2 changes: 1 addition & 1 deletion .github/workflows/devel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
pio pkg update
- name: PlatformIO Build Test
run: |
pio run -e freenove-tank
pio run -e freenove-tank -e makerfabs-multi-receiver -e xiao-camera3
2 changes: 1 addition & 1 deletion .github/workflows/platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
pio pkg update
- name: PlatformIO Build Test
run: |
pio run
pio run -e freenove-tank -e m5stickCplus-joystick-tank -e custom-camera-sender -e m5cores3-espnow-receiver -e makerfabs-multi-receiver -e xiao-camera2
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ The current version tested with the next cameras:
| Sender | Frame | JPGQ | FPS | Status |
|:-----------------|:-------:|:-----:|:------:|:------:|
| TTGO TJournal | QVGA | 12 | ~11 FPS | STABLE |
| XIAO ESP32S3 | QVGA | 12 | ~11 FPS | STABLE |
| Freenove S3 | QVGA | 12 | ~10 FPS | STABLE |
| Freenove S3 | HVGA | 12 | ~6 FPS | STABLE |
| M5CoreS3 | QVGA | 12 | ~11 FPS | STABLE |
| M5UnitCamS3 | QVGA | 12 | ~9 FPS | STABLE |
| XIAO ESP32S3 | QVGA | 12 | ~9 FPS | STABLE |

[Full list of senders and receivers devices supported](#supported-devices)

Expand Down
2 changes: 1 addition & 1 deletion examples/freenove-hvga-sender/freenove-hvga-sender.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void setup() {

radio.init();

Camera.config->frame_size = FRAMESIZE_HVGA;
Camera.config.frame_size = FRAMESIZE_HVGA;

if (!Camera.begin()) {
Serial.println("Camera Init Fail");
Expand Down
77 changes: 77 additions & 0 deletions examples/makerfabs-receiver/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); // 使用するパネルをセットします。
}
};
80 changes: 80 additions & 0 deletions examples/makerfabs-receiver/makerfabs-receiver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**************************************************
* ESPNowCam video Receiver
* 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 "S3_Parallel16_ili9488.h"
#include <LGFX_TFT_eSPI.hpp>
#include "Utils.h"

ESPNowCam radio;
LGFX tft;

#define LCD_CS 37
#define LCD_BLK 45

// frame buffer
uint8_t *fb;
// display globals
int32_t dw, dh;

static uint32_t frame_camera = 0;
static uint_fast64_t time_stamp_camera = 0;

static void print_FPS(int x, int y, const char *msg, uint32_t &frame, uint_fast64_t &time_stamp, uint32_t len) {
frame++;
if (millis() - time_stamp > 1000) {
time_stamp = millis();
char output[40];
sprintf(output, "%s %2d FPS JPG: %05d\r\n",msg, frame, len);
// tft.drawString(output, x, y);
frame = 0;
Serial.print(output);
}
}

void onDataReady(uint32_t lenght) {
tft.drawJpg(fb, lenght , 0, 0, dw, dh);
print_FPS(5, 250, "CAM:", frame_camera, time_stamp_camera, lenght);
}

void setup() {
Serial.begin(115200);

pinMode(LCD_CS, OUTPUT);
pinMode(LCD_BLK, OUTPUT);

digitalWrite(LCD_CS, LOW);
digitalWrite(LCD_BLK, HIGH);

tft.init();
tft.setRotation(1);
tft.startWrite();

dw = tft.width();
dh = tft.height();

if(psramFound()){
size_t psram_size = esp_spiram_get_size() / 1048576;
Serial.printf("PSRAM size: %dMb\r\n", psram_size);
}

// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
fb = (uint8_t *)ps_malloc(20000 * sizeof(uint8_t));

radio.setRecvBuffer(fb);
radio.setRecvCallback(onDataReady);

if (radio.init()) {
tft.setTextSize(2);
tft.drawString("ESPNow Init Success", 5, 2);
}
delay(1000);
}

void loop() {
}
1 change: 1 addition & 0 deletions examples/multi-camera-one-receiver/m5cores3-camera1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void setup() {
CoreS3.Display.drawString("Camera Init Fail", 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
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ void setup() {
}

// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
fb_camera1 = (uint8_t *)ps_malloc(5000 * sizeof(uint8_t));
fb_camera2 = (uint8_t *)malloc(5000 * sizeof(uint8_t));
fb_camera3 = (uint8_t *)malloc(5000 * sizeof(uint8_t));
fb_camera1 = (uint8_t *)ps_malloc(20000 * sizeof(uint8_t));
fb_camera2 = (uint8_t *)ps_malloc(10000 * sizeof(uint8_t));
fb_camera3 = (uint8_t *)ps_malloc(10000 * sizeof(uint8_t));

// M5CoreS3 Camera f4:12:fa:85:f4:9c
uint8_t camera1[6] = {0xF4, 0x12, 0xFA, 0x85, 0xF4, 0x9C};
Expand Down
4 changes: 2 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(35); // ==> weird delay for NOPSRAM camera.
delay(40); // ==> weird delay for NOPSRAM camera.
printFPS("CAM:");
Camera.free();
}
Expand All @@ -36,7 +36,7 @@ void setup() {

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

if (!Camera.begin()) {
Serial.println("Camera Init Fail");
Expand Down
13 changes: 10 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ lib_deps =
${esp32common.lib_deps}
m5stack/M5Unified@^0.1.6

[env:makerfabs-receiver]
extends = esp32common
build_src_filter = -<*> +<makerfabs-receiver/makerfabs-receiver.cpp>
lib_deps =
${esp32common.lib_deps}
lovyan03/LovyanGFX@^1.1.5

[env:m5stickCplus-joystick-tank]
extends = esp32common
board = esp32dev
Expand Down Expand Up @@ -142,17 +149,17 @@ lib_deps =
${esp32common.lib_deps}
lovyan03/LovyanGFX@^1.1.5

[env:m5cores3-camera3]
[env:m5cores3-camera1]
extends = m5cores3_common
build_src_filter = -<*> +<multi-camera-one-receiver/m5cores3-camera1.cpp>

[env:tjournal-camera1]
[env:tjournal-camera2]
platform = espressif32
extends = env
board = esp32dev
build_src_filter = -<*> +<multi-camera-one-receiver/tjournal-camera2.cpp>

[env:xiao-camera2]
[env:xiao-camera3]
extends = xiao-common
build_src_filter = -<*> +<multi-camera-one-receiver/xiao-camera3.cpp>
lib_deps =
Expand Down
Loading