Skip to content

Commit a5299ed

Browse files
authored
Merge pull request #47 from hpsaturn/crowpanel-receiver-sample
CrowPanel ESP32C3 240x240
2 parents b8dca20 + f0f51ce commit a5299ed

File tree

7 files changed

+218
-9
lines changed

7 files changed

+218
-9
lines changed

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Some video receivers
2929
| tft-3.5-basic-receiver | Any TFT display with LGFX [1] | STABLE |
3030
| tft-il9485-basic-receiver | M5Core TFT reciver il9481 [1] [2]| STABLE |
3131
| ft-rgb-hmi-basic-receiver | ESP32S3_RGB_ESP32-8048S043 [1] [2] | STABLE |
32+
| crowpanel-receiver | Elecrow round panel 320x240 [1] | TESTING |
3233

3334
[1] Use with any sender sample
3435
[2] Use with freenove HVGA sender sample for example.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/**************************************************
2+
* ESPNowCam video Receiver
3+
* by @hpsaturn Copyright (C) 2024
4+
* This file is part ESPNowCam tests project:
5+
* https://github.com/hpsaturn/ESPNowCam
6+
**************************************************/
7+
8+
#include <Arduino.h>
9+
#include <Wire.h>
10+
#include <ESPNowCam.h>
11+
#include "lgfx-esp32c3-crowpanel.h"
12+
#include <LGFX_TFT_eSPI.hpp>
13+
#include "Utils.h"
14+
15+
ESPNowCam radio;
16+
LGFX tft;
17+
18+
#define I2C_SDA 4
19+
#define I2C_SCL 5
20+
#define TP_INT 0
21+
#define TP_RST -1
22+
#define LCD_CS 10
23+
#define LCD_BLK -1
24+
#define PI4IO_I2C_ADDR 0x43
25+
26+
// frame buffer
27+
uint8_t *fb;
28+
// display globals
29+
int32_t dw, dh;
30+
31+
static uint32_t frame_camera = 0;
32+
static uint_fast64_t time_stamp_camera = 0;
33+
34+
static void print_FPS(int x, int y, const char *msg, uint32_t &frame, uint_fast64_t &time_stamp, uint32_t len) {
35+
frame++;
36+
if (millis() - time_stamp > 1000) {
37+
time_stamp = millis();
38+
char output[40];
39+
sprintf(output, "%s%2d FPS JPG: %05d\r\n",msg, frame, len);
40+
tft.drawString(output, x, y);
41+
frame = 0;
42+
Serial.print(output);
43+
}
44+
}
45+
46+
void onDataReady(uint32_t lenght) {
47+
tft.drawJpg(fb, lenght , 0, 0, dw, dh);
48+
print_FPS(5, 250, "CAM:", frame_camera, time_stamp_camera, lenght);
49+
}
50+
51+
//Extended IO function
52+
void init_IO_extender() {
53+
Wire.beginTransmission(PI4IO_I2C_ADDR);
54+
Wire.write(0x01); // test register
55+
Wire.endTransmission();
56+
Wire.requestFrom(PI4IO_I2C_ADDR, 1);
57+
uint8_t rxdata = Wire.read();
58+
Serial.print("Device ID: ");
59+
Serial.println(rxdata, HEX);
60+
61+
Wire.beginTransmission(PI4IO_I2C_ADDR);
62+
Wire.write(0x03); // IO direction register
63+
Wire.write((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)); // set pins 0, 1, 2 as outputs
64+
Wire.endTransmission();
65+
66+
Wire.beginTransmission(PI4IO_I2C_ADDR);
67+
Wire.write(0x07); // Output Hi-Z register
68+
Wire.write(~((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4))); // set pins 0, 1, 2 low
69+
Wire.endTransmission();
70+
}
71+
72+
void set_pin_io(uint8_t pin_number, bool value) {
73+
74+
Wire.beginTransmission(PI4IO_I2C_ADDR);
75+
Wire.write(0x05); // test register
76+
Wire.endTransmission();
77+
Wire.requestFrom(PI4IO_I2C_ADDR, 1);
78+
uint8_t rxdata = Wire.read();
79+
Serial.print("Before the change: ");
80+
Serial.println(rxdata, HEX);
81+
82+
Wire.beginTransmission(PI4IO_I2C_ADDR);
83+
Wire.write(0x05); // Output register
84+
85+
if (!value)
86+
Wire.write((~(1 << pin_number)) & rxdata); // set pin low
87+
else
88+
Wire.write((1 << pin_number) | rxdata); // set pin high
89+
Wire.endTransmission();
90+
91+
Wire.beginTransmission(PI4IO_I2C_ADDR);
92+
Wire.write(0x05); // test register
93+
Wire.endTransmission();
94+
Wire.requestFrom(PI4IO_I2C_ADDR, 1);
95+
rxdata = Wire.read();
96+
Serial.print("after the change: ");
97+
Serial.println(rxdata, HEX);
98+
}
99+
100+
101+
void setup() {
102+
Serial.begin(115200);
103+
104+
Wire.begin(4, 5);
105+
init_IO_extender();
106+
delay(100);
107+
set_pin_io(3, true);
108+
set_pin_io(4, true);
109+
set_pin_io(2, true);
110+
111+
pinMode(3, OUTPUT);
112+
digitalWrite(3, LOW);
113+
114+
// ticker.attach(1, tcr1s);
115+
tft.init();
116+
tft.initDMA();
117+
tft.startWrite();
118+
tft.setColor(0, 0, 0);
119+
120+
tft.fillScreen(TFT_BLACK);
121+
122+
dw = tft.width();
123+
dh = tft.height();
124+
125+
// if(psramFound()){
126+
// size_t psram_size = esp_spiram_get_size() / 1048576;
127+
// Serial.printf("PSRAM size: %dMb\r\n", psram_size);
128+
// }
129+
130+
// BE CAREFUL WITH IT, IF JPG LEVEL CHANGES, INCREASE IT
131+
fb = static_cast<uint8_t*>(malloc(10000 * sizeof(uint8_t)));
132+
133+
radio.setRecvBuffer(fb);
134+
radio.setRecvCallback(onDataReady);
135+
136+
if (radio.init()) {
137+
tft.setTextSize(2);
138+
tft.drawString("ESPNow Init Success", 5, 2);
139+
}
140+
delay(1000);
141+
}
142+
143+
void loop() {
144+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#define LGFX_USE_V1
2+
3+
#include <LovyanGFX.hpp>
4+
5+
class LGFX : public lgfx::LGFX_Device
6+
{
7+
lgfx::Panel_GC9A01 _panel_instance;
8+
lgfx::Bus_SPI _bus_instance;
9+
public:
10+
LGFX(void)
11+
{
12+
{
13+
auto cfg = _bus_instance.config();
14+
cfg.spi_host = SPI2_HOST;
15+
cfg.spi_mode = 0;
16+
cfg.freq_write = 80000000;
17+
cfg.freq_read = 20000000;
18+
cfg.spi_3wire = true;
19+
cfg.use_lock = true;
20+
cfg.dma_channel = SPI_DMA_CH_AUTO;
21+
cfg.pin_sclk = 6;
22+
cfg.pin_mosi = 7;
23+
cfg.pin_miso = -1;
24+
cfg.pin_dc = 2;
25+
_bus_instance.config(cfg);
26+
_panel_instance.setBus(&_bus_instance);
27+
}
28+
{
29+
auto cfg = _panel_instance.config();
30+
cfg.pin_cs = 10;
31+
cfg.pin_rst = -1;
32+
cfg.pin_busy = -1;
33+
cfg.memory_width = 240;
34+
cfg.memory_height = 240;
35+
cfg.panel_width = 240;
36+
cfg.panel_height = 240;
37+
cfg.offset_x = 0;
38+
cfg.offset_y = 0;
39+
cfg.offset_rotation = 0;
40+
cfg.dummy_read_pixel = 8;
41+
cfg.dummy_read_bits = 1;
42+
cfg.readable = false;
43+
cfg.invert = true;
44+
cfg.rgb_order = false;
45+
cfg.dlen_16bit = false;
46+
cfg.bus_shared = false;
47+
_panel_instance.config(cfg);
48+
}
49+
setPanel(&_panel_instance);
50+
}
51+
};
52+

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "EspNowCam",
3-
"version": "0.1.15",
3+
"version": "0.1.16",
44
"homepage":"https://github.com/hpsaturn/esp32s3-cam",
55
"keywords":
66
[

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=EspNowCam
2-
version=0.1.15
2+
version=0.1.16
33
author=@hpsaturn
44
maintainer=Antonio Vanegas <[email protected]>
55
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

platformio.ini

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extends = esp32common
4343
lib_deps =
4444
${esp32common.lib_deps}
4545
46-
m5stack/M5Unified@^0.1.17
46+
m5stack/M5Unified@0.2.0
4747
build_flags =
4848
${env.build_flags}
4949
-DESP32S3
@@ -126,7 +126,7 @@ board = esp32dev
126126
build_src_filter = -<*> +<m5core2-espnow-receiver/>
127127
lib_deps =
128128
${esp32common.lib_deps}
129-
m5stack/M5Unified@^0.1.6
129+
m5stack/M5Unified@^0.2.0
130130

131131
[env:makerfabs-receiver]
132132
extends = esp32common
@@ -150,6 +150,18 @@ lib_deps =
150150
${esp32common.lib_deps}
151151
lovyan03/LovyanGFX@^1.1.5
152152

153+
[env:crowpanel-receiver]
154+
extends = esp32common
155+
board = esp32-c3-devkitm-1
156+
build_src_filter = -<*> +<crowpanel-receiver/crowpanel-receiver.cpp>
157+
monitor_speed = 115200
158+
board_build.partitions = min_spiffs.csv
159+
monitor_rts = 0
160+
monitor_dtr = 0
161+
lib_deps =
162+
${esp32common.lib_deps}
163+
lovyan03/LovyanGFX@^1.2.0
164+
153165
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
154166
; N:1 EXAMPLES
155167
; Multi camera to one receiver examples.
@@ -162,7 +174,7 @@ board = esp32dev
162174
build_src_filter = -<*> +<multi-camera-one-receiver/m5core2-multi-receiver.cpp>
163175
lib_deps =
164176
${esp32common.lib_deps}
165-
m5stack/M5Unified@^0.1.6
177+
m5stack/M5Unified@^0.2.0
166178

167179
[env:makerfabs-multi-receiver]
168180
extends = esp32common
@@ -200,12 +212,12 @@ lib_deps =
200212
${esp32common.lib_deps}
201213
madhephaestus/[email protected]
202214
hpsaturn/EasyPreferences@^0.1.0
203-
hpsaturn/ESP32 Wifi CLI @^0.3.2
215+
hpsaturn/ESP32 Wifi CLI @^0.3.3
204216

205217
[env:m5stickCplus-joystick-tank]
206218
extends = esp32common
207219
board = esp32dev
208220
build_src_filter = -<*> +<common/> +<m5stickCplus-joystick-tank/>
209221
lib_deps =
210222
${esp32common.lib_deps}
211-
m5stack/M5Unified@^0.1.6
223+
m5stack/M5Unified@^0.2.0

src/ESPNowCam.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ extern "C" {
1313
typedef void (*RecvCb)(uint32_t lenght);
1414
}
1515

16-
#define ENC_VERSION "0.1.15"
17-
#define ENC_REVISION 080
16+
#define ENC_VERSION "0.1.16"
17+
#define ENC_REVISION 081
1818

1919
class ESPNowCam {
2020
private:

0 commit comments

Comments
 (0)