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

Fix AI-Thinker power pin issue and new recivers #41

Merged
merged 6 commits into from
May 24, 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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ Some examples are for Arduino users (*.ino samples), but is possible too compile

## Credits

I want to extend my gratitude to @ElectroZeusTIC and @AcoranTf for testing it on Arduino IDE. Also to @UtaAoya for your findings around the M5UnitCam device.
I want to extend my gratitude to:

- @ElectroZeusTIC and @AcoranTf for testing it on Arduino IDE.
- @UtaAoya for your findings around the M5UnitCam device.
- @turmandreams for your tests around AIThinker Camera and M5Core receiver.
- @MeloCuentan for your fixes in AI-Thinker Camera issue.

---
2 changes: 1 addition & 1 deletion examples/tft-3.5-basic-receiver/tft-3.5-basic-receiver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void setup() {

if (radio.init()) {
tft.setTextSize(2);
tft.drawString("ESPNow Iniciado Correctamente", dw / 6, dh / 2);
tft.drawString("ESPNow Init success", dw / 6, dh / 2);
}
delay(1000);
}
Expand Down
59 changes: 59 additions & 0 deletions examples/tft-il9485-basic-receiver/lgfx_custom_ili9341_conf.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef LGFX_CUSTOMBOARD_CONF_HPP
#define LGFX_CUSTOMBOARD_CONF_HPP

#define LGFX_USE_V1

#include "LovyanGFX.hpp"

class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_ILI9341 _panel_instance;
lgfx::Bus_SPI _bus_instance;

public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.spi_host = VSPI_HOST;
cfg.spi_mode = 0;
cfg.freq_write = 27000000;
cfg.freq_read = 10000000;
cfg.spi_3wire = true;
cfg.use_lock = false;
//cfg.dma_channel = SPI_DMA_CH_AUTO;
cfg.pin_sclk = 18;
cfg.pin_mosi = 23;
cfg.pin_miso = 19;
cfg.pin_dc = 27;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}

{
auto cfg = _panel_instance.config();
cfg.pin_cs = 14;
cfg.pin_rst = 33;
cfg.pin_busy = -1;
cfg.panel_width = 320;
cfg.panel_height = 240;
cfg.memory_width = 320;
cfg.memory_height = 240;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.offset_rotation = 3;
cfg.dummy_read_pixel = 8;
cfg.dummy_read_bits = 1;
cfg.readable = true;
cfg.invert = true;
cfg.rgb_order = false;
cfg.dlen_16bit = false;
cfg.bus_shared = true;
_panel_instance.config(cfg);
}

setPanel(&_panel_instance);
}
};

#endif
55 changes: 55 additions & 0 deletions examples/tft-il9485-basic-receiver/tft-il9485-basic-receiver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Sample shared by @turmandreams
* Board: M5Stack Basic Core
*/

#include <Arduino.h>
#include <ESPNowCam.h>
#include "lgfx_custom_ili9341_conf.hpp"
#include <LGFX_TFT_eSPI.hpp>
// #include <Utils.h>

ESPNowCam radio;

static TFT_eSPI lcd; // Instance of LGFX
static TFT_eSprite sprite(&lcd); // Instance of LGFX_Sprite when using sprites

// frame buffer
uint8_t fb[60000];
// display globals
int32_t dw = 320;
int32_t dh = 240;

void onDataReady(uint32_t lenght) {
lcd.drawJpg(fb, lenght, 0, 0, dw, dh);
// printFPS("MF:");
}

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

pinMode(32, OUTPUT); // Back Light
digitalWrite(32, HIGH);

lcd.init();
lcd.setRotation(1);
lcd.setBrightness(128);
lcd.setColorDepth(16);

lcd.drawRect(0, 0, 320, 240, (uint16_t)0x1F); // green
delay(1000);

lcd.drawRect(0, 0, 320, 240, (uint16_t)0xF1); // green
delay(1000);

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

if (radio.init()) {
lcd.drawString("ESPNow Init Success", dw / 2, dh / 2);
Serial.println("ESPNow Init Success");
}
delay(500);
}

void loop(void) {}
110 changes: 110 additions & 0 deletions examples/tft-rgb-hmi-basic-receiver/LGFX_ESP32S3_RGB_ESP32-8048S043.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@

#define LGFX_USE_V1
#include <LovyanGFX.hpp>

#include <lgfx/v1/platforms/esp32s3/Panel_RGB.hpp>
#include <lgfx/v1/platforms/esp32s3/Bus_RGB.hpp>

#include <driver/i2c.h>

class LGFX : public lgfx::LGFX_Device
{
public:

lgfx::Bus_RGB _bus_instance;
lgfx::Panel_RGB _panel_instance;
lgfx::Light_PWM _light_instance;
lgfx::Touch_GT911 _touch_instance;

LGFX(void)
{
{
auto cfg = _panel_instance.config();

cfg.memory_width = 800;
cfg.memory_height = 480;
cfg.panel_width = 800;
cfg.panel_height = 480;

cfg.offset_x = 0;
cfg.offset_y = 0;

_panel_instance.config(cfg);
}

{
auto cfg = _panel_instance.config_detail();

cfg.use_psram = 1;

_panel_instance.config_detail(cfg);
}

{
auto cfg = _bus_instance.config();
cfg.panel = &_panel_instance;
cfg.pin_d0 = GPIO_NUM_8; // B0
cfg.pin_d1 = GPIO_NUM_3; // B1
cfg.pin_d2 = GPIO_NUM_46; // B2
cfg.pin_d3 = GPIO_NUM_9; // B3
cfg.pin_d4 = GPIO_NUM_1; // B4
cfg.pin_d5 = GPIO_NUM_5; // G0
cfg.pin_d6 = GPIO_NUM_6; // G1
cfg.pin_d7 = GPIO_NUM_7; // G2
cfg.pin_d8 = GPIO_NUM_15; // G3
cfg.pin_d9 = GPIO_NUM_16; // G4
cfg.pin_d10 = GPIO_NUM_4; // G5
cfg.pin_d11 = GPIO_NUM_45; // R0
cfg.pin_d12 = GPIO_NUM_48; // R1
cfg.pin_d13 = GPIO_NUM_47; // R2
cfg.pin_d14 = GPIO_NUM_21; // R3
cfg.pin_d15 = GPIO_NUM_14; // R4

cfg.pin_henable = GPIO_NUM_40;
cfg.pin_vsync = GPIO_NUM_41;
cfg.pin_hsync = GPIO_NUM_39;
cfg.pin_pclk = GPIO_NUM_42;
cfg.freq_write = 14000000;

cfg.hsync_polarity = 0;
cfg.hsync_front_porch = 8;
cfg.hsync_pulse_width = 4;
cfg.hsync_back_porch = 16;
cfg.vsync_polarity = 0;
cfg.vsync_front_porch = 4;
cfg.vsync_pulse_width = 4;
cfg.vsync_back_porch = 4;
cfg.pclk_idle_high = 1;
_bus_instance.config(cfg);
}
_panel_instance.setBus(&_bus_instance);

{
auto cfg = _light_instance.config();
cfg.pin_bl = GPIO_NUM_2;
_light_instance.config(cfg);
}
_panel_instance.light(&_light_instance);

{
auto cfg = _touch_instance.config();
cfg.x_min = 0;
cfg.x_max = 800;
cfg.y_min = 0;
cfg.y_max = 480;
cfg.pin_int = GPIO_NUM_18;
cfg.bus_shared = false;
cfg.offset_rotation = 0;
// I2C接続
cfg.i2c_port = I2C_NUM_1;
cfg.pin_sda = GPIO_NUM_19;
cfg.pin_scl = GPIO_NUM_20;
cfg.freq = 400000;
cfg.i2c_addr = 0x14; // 0x5D , 0x14
_touch_instance.config(cfg);
_panel_instance.setTouch(&_touch_instance);
}

setPanel(&_panel_instance);
}
};
57 changes: 57 additions & 0 deletions examples/tft-rgb-hmi-basic-receiver/tft-rgb-hmi-basic-receiver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Sample shared by @MeloCuentan
* Board:
* https://www.aliexpress.com/item/1005006625303218.html
*/

#include <Arduino.h>
#include <HardwareSerial.h>

#include "LGFX_ESP32S3_RGB_ESP32-8048S043.h"
#include <LGFX_TFT_eSPI.hpp>

#include "ESPNowCam.h"

static LGFX tft;

ESPNowCam radio;

// frame buffer
uint8_t *fb;

// display globals
int32_t dw = 800;
int32_t dh = 480;

void onDataReady(uint32_t lenght) { tft.drawJpg(fb, lenght, 0, 0, dw, dh); }

void setup(void) {
tft.init();
tft.setRotation(0);

pinMode(2, OUTPUT); // Display brightness enable
analogWriteResolution(8); // PWM resolution
analogWriteFrequency(1000); // PWM frequency
analogWrite(2, 127); // Brightness set

tft.setTextColor(TFT_WHITE);

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

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

if (radio.init()) {
String text = "ESPNow Init Success";
uint8_t textLenght = text.length();
uint8_t textSize = 4;
uint16_t posX = (800 - (textSize * 6 * textLenght)) / 2;
uint16_t posY = ((480 - (textSize * 8)) / 3) * 2;
tft.setTextSize(textSize);
tft.drawString(text, posX, posY);
}
delay(500);
}

void loop(void) {}
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 @@ -33,8 +33,8 @@ void setup() {
}

// Makerfabs receiver 7C:DF:A1:F3:73:3C
uint8_t macRecv[6] = {0x7C,0xDF,0xA1,0xF3,0x73,0x3C};
radio.setTarget(macRecv);
// uint8_t macRecv[6] = {0x7C,0xDF,0xA1,0xF3,0x73,0x3C};
// radio.setTarget(macRecv);
radio.init();

// You are able to change the Camera config E.g:
Expand Down
1 change: 1 addition & 0 deletions examples/unitcams3-basic-sender/unitcams3-basic-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void setup() {
}

radio.init();

if (!Camera.begin()) {
Serial.println("Camera Init Fail");
delay(1000);
Expand Down
2 changes: 1 addition & 1 deletion examples/xiao-fpv-sender/xiao-fpv-sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void setup() {
size_t psram_size = esp_spiram_get_size() / 1048576;
Serial.printf("PSRAM size: %dMb\r\n", psram_size);
}

// M5Core2 receiver B8:F0:09:C6:0E:CC
// uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
// radio.setTarget(macRecv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ void shutdown() {
void setup() {
Serial.begin(115200);

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

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

// Makerfabs receiver 7C:DF:A1:F3:73:3C
uint8_t macRecv[6] = {0x7C, 0xDF, 0xA1, 0xF3, 0x73, 0x3C};
radio.setTarget(macRecv);
// uint8_t macRecv[6] = {0x7C, 0xDF, 0xA1, 0xF3, 0x73, 0x3C};
// M5Core2 receiver B8:F0:09:C6:0E:CC
// uint8_t macRecv[6] = {0xB8,0xF0,0x09,0xC6,0x0E,0xCC};
// radio.setTarget(macRecv);
radio.init();

// Configuration without using the PSRAM, only DRAM. (more faster)
Expand Down
15 changes: 15 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ lib_deps =
${esp32common.lib_deps}
lovyan03/LovyanGFX@^1.1.5

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

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; N:1 EXAMPLES
; Multi camera to one receiver examples.
Expand Down
3 changes: 2 additions & 1 deletion src/drivers/CamAIThinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CamAIThinker : public CameraBase {

CamAIThinker(){
config.pin_reset = -1;
config.pin_pwdn = 32;
config.pin_xclk = 0;
config.pin_sccb_sda = 26;
config.pin_sccb_scl = 27;
Expand All @@ -26,7 +27,7 @@ class CamAIThinker : public CameraBase {
config.pin_vsync = 25;
config.pin_href = 23;
config.pin_pclk = 22;
config.xclk_freq_hz = 20000000;
config.xclk_freq_hz = 16000000;
config.ledc_timer = LEDC_TIMER_0;
config.ledc_channel = LEDC_CHANNEL_0;
config.pixel_format = PIXFORMAT_RGB565;
Expand Down
Loading