@geastack/targets 0.1.101 → 0.1.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/targets/esp32/components/gea_framework/CMakeLists.txt +1 -0
- package/targets/esp32/gea_framework.cmake +1 -0
- package/targets/esp32/uart.cpp +138 -0
- package/targets/esp32-s3-m5stack-stopwatch/.clang-format +10 -0
- package/targets/esp32-s31-espressif-mosaico/CMakeLists.txt +8 -0
- package/targets/esp32-s31-espressif-mosaico/README.md +24 -6
- package/targets/esp32-s31-espressif-mosaico/dependencies.lock +356 -0
- package/targets/esp32-s31-espressif-mosaico/main/CMakeLists.txt +8 -0
- package/targets/esp32-s31-espressif-mosaico/main/camera.cpp +76 -13
- package/targets/esp32-s31-espressif-mosaico/main/idf_component.yml +6 -3
- package/targets/esp32-s31-espressif-mosaico/main/include/mosaico_peer_uart_pins.h +68 -0
- package/targets/esp32-s31-espressif-mosaico/main/peer_uart.cpp +28 -72
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/targets",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.103",
|
|
4
4
|
"description": "Native embedded build targets (ESP32-IDF, RP2350) for geastack apps: board sources, target catalog, and CMake glue driven by the gea CLI.",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@geastack/chips": "^0.1.6",
|
|
40
|
-
"@geastack/compiler": "^1.0.
|
|
41
|
-
"@geastack/core": "
|
|
40
|
+
"@geastack/compiler": "^1.0.33",
|
|
41
|
+
"@geastack/core": "0.1.42",
|
|
42
42
|
"@geastack/elements": "^0.1.6",
|
|
43
|
-
"@geastack/engine": "^0.1.
|
|
43
|
+
"@geastack/engine": "^0.1.17",
|
|
44
44
|
"@geastack/geaos": "^0.1.3",
|
|
45
|
-
"@geastack/geatsc-plugin-gea": "
|
|
46
|
-
"@geastack/host": "
|
|
45
|
+
"@geastack/geatsc-plugin-gea": "0.1.23",
|
|
46
|
+
"@geastack/host": "0.1.17"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"test": "for f in $(git ls-files | grep -E '(^|/)(test[-_][^/]*|[^/]*\\.test)\\.mjs$'); do echo \"==> $f\"; node \"$f\" || exit 1; done"
|
|
@@ -75,6 +75,7 @@ idf_component_register(
|
|
|
75
75
|
# flag travels through the link INTERFACE because this component is a static
|
|
76
76
|
# archive, so a PRIVATE option would stop at the archive.
|
|
77
77
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl$<COMMA>-u$<COMMA>gea_gpio_link_bindings")
|
|
78
|
+
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl$<COMMA>-u$<COMMA>gea_uart_link_bindings")
|
|
78
79
|
if(GEA_EMBEDDED_APP)
|
|
79
80
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl$<COMMA>-u$<COMMA>gea_mjpeg_link_bindings")
|
|
80
81
|
endif()
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#include "platform/uart.h"
|
|
2
|
+
#include "driver/gpio.h"
|
|
3
|
+
#include "driver/uart.h"
|
|
4
|
+
#include "soc/soc_caps.h"
|
|
5
|
+
#include <array>
|
|
6
|
+
#include <limits>
|
|
7
|
+
#include <mutex>
|
|
8
|
+
|
|
9
|
+
// Board resource policy is separate from the chip's GPIO matrix capability.
|
|
10
|
+
extern "C" bool gea_board_uart_pin_allowed(int pin) __attribute__((weak));
|
|
11
|
+
extern "C" void gea_uart_link_bindings() {}
|
|
12
|
+
|
|
13
|
+
namespace {
|
|
14
|
+
struct Port {
|
|
15
|
+
bool open = false;
|
|
16
|
+
gea::platform::uart::Config config{-1, -1, 0};
|
|
17
|
+
};
|
|
18
|
+
std::array<Port, SOC_UART_HP_NUM> ports{};
|
|
19
|
+
std::mutex mutex;
|
|
20
|
+
bool validPort(int port) {
|
|
21
|
+
return port >= 0 && port < static_cast<int>(ports.size());
|
|
22
|
+
}
|
|
23
|
+
bool usablePin(int pin, bool output) {
|
|
24
|
+
if (pin < 0 || pin >= GPIO_NUM_MAX)
|
|
25
|
+
return false;
|
|
26
|
+
if (output ? !GPIO_IS_VALID_OUTPUT_GPIO(pin) : !GPIO_IS_VALID_GPIO(pin))
|
|
27
|
+
return false;
|
|
28
|
+
return !gea_board_uart_pin_allowed || gea_board_uart_pin_allowed(pin);
|
|
29
|
+
}
|
|
30
|
+
bool configured(int port) { return validPort(port) && ports[port].open; }
|
|
31
|
+
int writable(int port) {
|
|
32
|
+
std::size_t bytes = 0;
|
|
33
|
+
if (uart_get_tx_buffer_free_size(static_cast<uart_port_t>(port), &bytes) !=
|
|
34
|
+
ESP_OK)
|
|
35
|
+
return -1;
|
|
36
|
+
// IDF's ring buffer also needs an item header and alignment for each write.
|
|
37
|
+
return bytes > 32 ? static_cast<int>(bytes - 32) : 0;
|
|
38
|
+
}
|
|
39
|
+
} // namespace
|
|
40
|
+
|
|
41
|
+
extern "C" bool gea_uart_open(int port, int tx, int rx, int baud, int rxBytes,
|
|
42
|
+
int txBytes) {
|
|
43
|
+
std::lock_guard lock(mutex);
|
|
44
|
+
if (!validPort(port) || !usablePin(tx, true) || !usablePin(rx, false) ||
|
|
45
|
+
tx == rx || baud < 1 || baud > 5000000 || rxBytes < 256 ||
|
|
46
|
+
rxBytes > 65536 || txBytes < 256 || txBytes > 65536)
|
|
47
|
+
return false;
|
|
48
|
+
#if defined(CONFIG_ESP_CONSOLE_UART_NUM)
|
|
49
|
+
if (port == CONFIG_ESP_CONSOLE_UART_NUM)
|
|
50
|
+
return false;
|
|
51
|
+
#endif
|
|
52
|
+
const auto uart = static_cast<uart_port_t>(port);
|
|
53
|
+
if (ports[port].open) {
|
|
54
|
+
const auto &old = ports[port].config;
|
|
55
|
+
return old.tx == tx && old.rx == rx && old.baudRate == baud &&
|
|
56
|
+
old.rxBufferSize == rxBytes && old.txBufferSize == txBytes;
|
|
57
|
+
}
|
|
58
|
+
if (uart_is_driver_installed(uart))
|
|
59
|
+
return false;
|
|
60
|
+
for (const auto &other : ports) {
|
|
61
|
+
if (other.open && (other.config.tx == tx || other.config.rx == tx ||
|
|
62
|
+
other.config.tx == rx || other.config.rx == rx))
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
uart_config_t config{};
|
|
66
|
+
config.baud_rate = baud;
|
|
67
|
+
config.data_bits = UART_DATA_8_BITS;
|
|
68
|
+
config.parity = UART_PARITY_DISABLE;
|
|
69
|
+
config.stop_bits = UART_STOP_BITS_1;
|
|
70
|
+
config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;
|
|
71
|
+
config.source_clk = UART_SCLK_DEFAULT;
|
|
72
|
+
// Allocate before routing pins: a failed allocation cannot disturb the
|
|
73
|
+
// harness.
|
|
74
|
+
if (uart_driver_install(uart, rxBytes, txBytes, 0, nullptr, 0) != ESP_OK)
|
|
75
|
+
return false;
|
|
76
|
+
if (uart_param_config(uart, &config) != ESP_OK ||
|
|
77
|
+
uart_set_pin(uart, tx, rx, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE) !=
|
|
78
|
+
ESP_OK ||
|
|
79
|
+
uart_set_rx_full_threshold(uart, 96) != ESP_OK ||
|
|
80
|
+
uart_set_rx_timeout(uart, 2) != ESP_OK) {
|
|
81
|
+
uart_driver_delete(uart);
|
|
82
|
+
gpio_reset_pin(static_cast<gpio_num_t>(tx));
|
|
83
|
+
gpio_reset_pin(static_cast<gpio_num_t>(rx));
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
ports[port] = {true, {tx, rx, baud, rxBytes, txBytes}};
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
extern "C" bool gea_uart_is_open(int port) {
|
|
90
|
+
std::lock_guard lock(mutex);
|
|
91
|
+
return configured(port);
|
|
92
|
+
}
|
|
93
|
+
extern "C" void gea_uart_close(int port) {
|
|
94
|
+
std::lock_guard lock(mutex);
|
|
95
|
+
if (!configured(port))
|
|
96
|
+
return;
|
|
97
|
+
uart_driver_delete(static_cast<uart_port_t>(port));
|
|
98
|
+
gpio_reset_pin(static_cast<gpio_num_t>(ports[port].config.tx));
|
|
99
|
+
gpio_reset_pin(static_cast<gpio_num_t>(ports[port].config.rx));
|
|
100
|
+
ports[port] = {};
|
|
101
|
+
}
|
|
102
|
+
extern "C" int gea_uart_read(int port, void *bytes, std::size_t capacity) {
|
|
103
|
+
std::lock_guard lock(mutex);
|
|
104
|
+
if (!configured(port) || (!bytes && capacity) ||
|
|
105
|
+
capacity > std::numeric_limits<int>::max())
|
|
106
|
+
return -1;
|
|
107
|
+
return capacity ? uart_read_bytes(static_cast<uart_port_t>(port), bytes,
|
|
108
|
+
capacity, 0)
|
|
109
|
+
: 0;
|
|
110
|
+
}
|
|
111
|
+
extern "C" int gea_uart_write(int port, const void *bytes, std::size_t length) {
|
|
112
|
+
std::lock_guard lock(mutex);
|
|
113
|
+
if (!configured(port) || (!bytes && length) ||
|
|
114
|
+
length > std::numeric_limits<int>::max())
|
|
115
|
+
return -1;
|
|
116
|
+
if (!length)
|
|
117
|
+
return 0;
|
|
118
|
+
const int free = writable(port);
|
|
119
|
+
if (free < 0)
|
|
120
|
+
return -1;
|
|
121
|
+
if (length > static_cast<std::size_t>(free))
|
|
122
|
+
return 0;
|
|
123
|
+
return uart_write_bytes(static_cast<uart_port_t>(port), bytes, length);
|
|
124
|
+
}
|
|
125
|
+
extern "C" int gea_uart_available(int port) {
|
|
126
|
+
std::lock_guard lock(mutex);
|
|
127
|
+
if (!configured(port))
|
|
128
|
+
return -1;
|
|
129
|
+
std::size_t bytes = 0;
|
|
130
|
+
return uart_get_buffered_data_len(static_cast<uart_port_t>(port), &bytes) ==
|
|
131
|
+
ESP_OK
|
|
132
|
+
? static_cast<int>(bytes)
|
|
133
|
+
: -1;
|
|
134
|
+
}
|
|
135
|
+
extern "C" int gea_uart_writable(int port) {
|
|
136
|
+
std::lock_guard lock(mutex);
|
|
137
|
+
return configured(port) ? writable(port) : -1;
|
|
138
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
BasedOnStyle: LLVM
|
|
2
|
+
IndentWidth: 2
|
|
3
|
+
ColumnLimit: 100
|
|
4
|
+
PointerAlignment: Left
|
|
5
|
+
SeparateDefinitionBlocks: Always
|
|
6
|
+
AllowShortFunctionsOnASingleLine: None
|
|
7
|
+
AllowShortIfStatementsOnASingleLine: Never
|
|
8
|
+
AllowShortLoopsOnASingleLine: false
|
|
9
|
+
AllowShortBlocksOnASingleLine: Never
|
|
10
|
+
InsertBraces: true
|
|
@@ -7,4 +7,12 @@ set(PROJECT_VER "${GEA_EMBEDDED_APP}" CACHE STRING "Firmware app id" FORCE)
|
|
|
7
7
|
|
|
8
8
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
|
9
9
|
idf_build_set_property(MINIMAL_BUILD ON)
|
|
10
|
+
# Camera component patches use git apply --no-index against PROJECT_DIR.
|
|
11
|
+
# Inside a consumer Git checkout, discovery of its enclosing repository makes
|
|
12
|
+
# Git silently skip those project-relative paths and report success. Stop
|
|
13
|
+
# discovery at this target's parent while the SDK components configure.
|
|
14
|
+
set(GEA_CAMERA_PREVIOUS_GIT_CEILING "$ENV{GIT_CEILING_DIRECTORIES}")
|
|
15
|
+
get_filename_component(GEA_CAMERA_GIT_CEILING "${CMAKE_CURRENT_LIST_DIR}/.." REALPATH)
|
|
16
|
+
set(ENV{GIT_CEILING_DIRECTORIES} "${GEA_CAMERA_GIT_CEILING}")
|
|
10
17
|
project(gea_embedded)
|
|
18
|
+
set(ENV{GIT_CEILING_DIRECTORIES} "${GEA_CAMERA_PREVIOUS_GIT_CEILING}")
|
|
@@ -61,8 +61,13 @@ before display init touches the panel.
|
|
|
61
61
|
The panel's TE line is wired on GPIO43, so apps that ask for vsync
|
|
62
62
|
(`Display.setVSync(true)`) render locked to the panel's ~60 Hz refresh.
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
The 128 MB SPI NAND provides file storage at `/nand`, using FAT with Dhara
|
|
65
|
+
wear levelling. `main/nand_mount.cpp` installs the storage provider; file
|
|
66
|
+
operations mount it as needed, and a blank chip is formatted on first mount.
|
|
67
|
+
Assets can be uploaded with `gea devctl push <file> /nand/...`.
|
|
68
|
+
|
|
69
|
+
Not yet wired: the BQ27220 fuel gauge (the board reports no battery reading)
|
|
70
|
+
and the BMM150 magnetometers.
|
|
66
71
|
|
|
67
72
|
## Camera module
|
|
68
73
|
|
|
@@ -85,15 +90,28 @@ mounting orientation, then fit inside **320 × 240 pixels** at JPEG quality 70.
|
|
|
85
90
|
The encoder uses whole 16-pixel blocks: the SC101IOT's 1280 × 720 default becomes
|
|
86
91
|
an upright **128 × 240** image; the OV3640's 1024 × 768 default becomes
|
|
87
92
|
**176 × 240**. Encoded images are capped at 96 KiB before base64 encoding.
|
|
88
|
-
|
|
93
|
+
Local preview and still captures retain the sensor's original capture aspect
|
|
94
|
+
ratio at 160 pixels wide (160 × 90 on SC101IOT, 160 × 120 on OV3640), without
|
|
95
|
+
the upload's portrait rotation or JPEG block alignment. `Camera.orientation`
|
|
96
|
+
reports the configured 180° mounting; preview pixels are already corrected for it.
|
|
97
|
+
The module has no hinge-angle sensor, so this value does not detect folding
|
|
98
|
+
between front-facing and rear-facing positions.
|
|
99
|
+
Preview uses nearest-neighbor pixel sampling, with no averaging filter. A visible native
|
|
100
|
+
`<camera fit="contain">` preview refreshes up to ten times per second;
|
|
101
|
+
JPEG uploads remain limited to one every two seconds. Video recording,
|
|
89
102
|
zoom and manual sensor tuning are not implemented by this backend.
|
|
90
103
|
|
|
91
104
|
`Camera.close()` stops the worker, releases the module lease and capture
|
|
92
105
|
buffers, deletes the JPEG encoder and clears the pending image. Sensor reads
|
|
93
|
-
|
|
94
|
-
|
|
106
|
+
retain the SDK's 1000 ms timeout, including the first frames discarded during
|
|
107
|
+
stream startup, and encoding times out after 500 ms. The worker join waits at most 2000 ms;
|
|
108
|
+
if the SDK stalls during shutdown, it logs the failure and retains the live resources so that a
|
|
95
109
|
later close/open can safely retry.
|
|
110
|
+
After three consecutive capture timeouts, the capture worker calls the SDK's
|
|
111
|
+
stream restart with no borrowed frames to recover a stalled DVP queue.
|
|
96
112
|
|
|
97
113
|
The pinned official camera component applies its ESP-IDF DVP and SC101IOT
|
|
98
|
-
stability patches during configuration.
|
|
114
|
+
stability patches during configuration. The target scopes Git discovery to
|
|
115
|
+
prevent an enclosing consumer repository from silently skipping the sensor patch.
|
|
116
|
+
Check configuration output for patch
|
|
99
117
|
warnings: a failed patch application means those workarounds are absent.
|
|
@@ -1,4 +1,93 @@
|
|
|
1
1
|
dependencies:
|
|
2
|
+
78/esp-opus:
|
|
3
|
+
component_hash: 8182b733f071d7bfe1e837f4c9f8649a63e4c937177f089e65772880c02f2e17
|
|
4
|
+
dependencies:
|
|
5
|
+
- name: idf
|
|
6
|
+
require: private
|
|
7
|
+
version: '>=5.0'
|
|
8
|
+
source:
|
|
9
|
+
registry_url: https://components.espressif.com/
|
|
10
|
+
type: service
|
|
11
|
+
version: 1.0.5
|
|
12
|
+
esp-mosaico-bsp:
|
|
13
|
+
component_hash: 85897538499a0683b3f08d07620ae3e4a4c45a6c91cb21264d9c6361f21d7098
|
|
14
|
+
dependencies:
|
|
15
|
+
- name: idf
|
|
16
|
+
version: '>=6.2'
|
|
17
|
+
- git: https://github.com/esp-mosaico/esp-mosaico-bsp.git
|
|
18
|
+
name: mosaico_boot_splash
|
|
19
|
+
path: components/mosaico_boot_splash
|
|
20
|
+
version: a4bfb426afcf2911c01fdd9b6d6f024019f00f8f
|
|
21
|
+
- name: espressif/esp_lvgl_adapter
|
|
22
|
+
public: true
|
|
23
|
+
rules:
|
|
24
|
+
- if: $CONFIG{BSP_DISPLAY_ENABLE} == True && $CONFIG{BSP_DISPLAY_LVGL_ENABLE} == True
|
|
25
|
+
version: 0.6.2
|
|
26
|
+
- name: lvgl/lvgl
|
|
27
|
+
rules:
|
|
28
|
+
- if: $CONFIG{BSP_DISPLAY_ENABLE} == True && $CONFIG{BSP_DISPLAY_LVGL_ENABLE} == True
|
|
29
|
+
version: ^9.5.0,<9.6.0
|
|
30
|
+
- name: espressif/esp_lcd_co5300
|
|
31
|
+
version: ^2.2
|
|
32
|
+
- name: espressif/esp_lcd_touch_cst9220
|
|
33
|
+
version: ^0.1
|
|
34
|
+
- name: espressif/spi_nand_flash
|
|
35
|
+
public: true
|
|
36
|
+
version: ^1.3.0
|
|
37
|
+
- name: espressif/esp_codec_dev
|
|
38
|
+
public: true
|
|
39
|
+
version: ~1.6
|
|
40
|
+
- name: espressif/button
|
|
41
|
+
public: true
|
|
42
|
+
version: ^4
|
|
43
|
+
- name: espressif2022/bmi270
|
|
44
|
+
public: true
|
|
45
|
+
version: ^1.1.0~2
|
|
46
|
+
- name: tangyumei3535/bmm150_sensorapi
|
|
47
|
+
public: true
|
|
48
|
+
version: ^1.0.0
|
|
49
|
+
- name: espressif/bq27220
|
|
50
|
+
public: true
|
|
51
|
+
version: ^0.1.1~1
|
|
52
|
+
source:
|
|
53
|
+
git: https://github.com/esp-mosaico/esp-mosaico-bsp.git
|
|
54
|
+
path: components/esp-mosaico-bsp
|
|
55
|
+
type: git
|
|
56
|
+
targets:
|
|
57
|
+
- esp32s31
|
|
58
|
+
version: a4bfb426afcf2911c01fdd9b6d6f024019f00f8f
|
|
59
|
+
espressif/bq27220:
|
|
60
|
+
component_hash: 6f216c63304baed177cd70bdb1654223e55dfbf3ff5a272d793eed3e3be15e6d
|
|
61
|
+
dependencies:
|
|
62
|
+
- name: espressif/cmake_utilities
|
|
63
|
+
registry_url: https://components.espressif.com
|
|
64
|
+
require: private
|
|
65
|
+
version: 0.*
|
|
66
|
+
- name: espressif/i2c_bus
|
|
67
|
+
registry_url: https://components.espressif.com
|
|
68
|
+
require: public
|
|
69
|
+
version: ^1.4
|
|
70
|
+
- name: idf
|
|
71
|
+
require: private
|
|
72
|
+
version: '>=4.4'
|
|
73
|
+
source:
|
|
74
|
+
registry_url: https://components.espressif.com/
|
|
75
|
+
type: service
|
|
76
|
+
version: 0.1.3
|
|
77
|
+
espressif/button:
|
|
78
|
+
component_hash: a1f34e8ed2e61ffef1a230fd9477005c2db335c7e1f6a239f43e5f119dcbe1b0
|
|
79
|
+
dependencies:
|
|
80
|
+
- name: espressif/cmake_utilities
|
|
81
|
+
registry_url: https://components.espressif.com
|
|
82
|
+
require: private
|
|
83
|
+
version: '*'
|
|
84
|
+
- name: idf
|
|
85
|
+
require: private
|
|
86
|
+
version: '>=4.0'
|
|
87
|
+
source:
|
|
88
|
+
registry_url: https://components.espressif.com/
|
|
89
|
+
type: service
|
|
90
|
+
version: 4.2.1
|
|
2
91
|
espressif/cjson:
|
|
3
92
|
component_hash: e788323270d90738662d66fffa910bfe1fba019bba087f01557e70c40485b469
|
|
4
93
|
dependencies:
|
|
@@ -26,6 +115,32 @@ dependencies:
|
|
|
26
115
|
registry_url: https://components.espressif.com
|
|
27
116
|
type: service
|
|
28
117
|
version: 1.1.0
|
|
118
|
+
espressif/esp_cam_sensor:
|
|
119
|
+
component_hash: 0dd6634a71cc8756f0e46c961476304a23a82db4f4c4deb8aecfa30161d2185c
|
|
120
|
+
dependencies:
|
|
121
|
+
- name: espressif/cmake_utilities
|
|
122
|
+
registry_url: https://components.espressif.com
|
|
123
|
+
require: private
|
|
124
|
+
version: 0.*
|
|
125
|
+
- name: espressif/esp_sccb_intf
|
|
126
|
+
registry_url: https://components.espressif.com
|
|
127
|
+
require: private
|
|
128
|
+
version: '>=0.0.5'
|
|
129
|
+
- name: idf
|
|
130
|
+
require: private
|
|
131
|
+
version: '>=5.3'
|
|
132
|
+
source:
|
|
133
|
+
registry_url: https://components.espressif.com
|
|
134
|
+
type: service
|
|
135
|
+
targets:
|
|
136
|
+
- esp32p4
|
|
137
|
+
- esp32s3
|
|
138
|
+
- esp32c3
|
|
139
|
+
- esp32c5
|
|
140
|
+
- esp32c6
|
|
141
|
+
- esp32c61
|
|
142
|
+
- esp32s31
|
|
143
|
+
version: 2.6.0
|
|
29
144
|
espressif/esp_codec_dev:
|
|
30
145
|
component_hash: 4779f31a3ba3f9b38aee1afe6ccb9ba8f6108dc3a6e77d39d7d714e9a215371b
|
|
31
146
|
dependencies:
|
|
@@ -36,6 +151,20 @@ dependencies:
|
|
|
36
151
|
registry_url: https://components.espressif.com/
|
|
37
152
|
type: service
|
|
38
153
|
version: 1.6.2
|
|
154
|
+
espressif/esp_h264:
|
|
155
|
+
component_hash: 3d60078419ceac61cd87579664ae6a5a9b9a42d6f2edf4e23d753af8d2a67da9
|
|
156
|
+
dependencies:
|
|
157
|
+
- name: idf
|
|
158
|
+
require: private
|
|
159
|
+
version: '>=4.4'
|
|
160
|
+
source:
|
|
161
|
+
registry_url: https://components.espressif.com/
|
|
162
|
+
type: service
|
|
163
|
+
targets:
|
|
164
|
+
- esp32s3
|
|
165
|
+
- esp32s31
|
|
166
|
+
- esp32p4
|
|
167
|
+
version: 1.4.1
|
|
39
168
|
espressif/esp_io_expander:
|
|
40
169
|
component_hash: 7b7f91270172e46ca4597e3874f48d8412e280e8c295559f5922ec38656e3e5f
|
|
41
170
|
dependencies:
|
|
@@ -106,6 +235,34 @@ dependencies:
|
|
|
106
235
|
registry_url: https://components.espressif.com/
|
|
107
236
|
type: service
|
|
108
237
|
version: 0.1.1
|
|
238
|
+
espressif/esp_libsrtp:
|
|
239
|
+
component_hash: 131560184c73ec09f77d8904a2db709307803f0f9f111898921b6966776eac15
|
|
240
|
+
dependencies: []
|
|
241
|
+
source:
|
|
242
|
+
registry_url: https://components.espressif.com
|
|
243
|
+
type: service
|
|
244
|
+
version: 1.0.0
|
|
245
|
+
espressif/esp_peer:
|
|
246
|
+
component_hash: 92bc1b80772acf8a0e2dc36193ec24278e0793140eca2a4060d8ce7b45c47845
|
|
247
|
+
dependencies:
|
|
248
|
+
- name: espressif/esp_libsrtp
|
|
249
|
+
registry_url: https://components.espressif.com
|
|
250
|
+
require: private
|
|
251
|
+
version: ^1.0.0
|
|
252
|
+
source:
|
|
253
|
+
registry_url: https://components.espressif.com/
|
|
254
|
+
type: service
|
|
255
|
+
version: 1.5.7
|
|
256
|
+
espressif/esp_sccb_intf:
|
|
257
|
+
component_hash: eb6a7d5c992f09583c163b2e3f5e95a0fdc87a2d9f8e026f3e59153935553889
|
|
258
|
+
dependencies:
|
|
259
|
+
- name: idf
|
|
260
|
+
require: private
|
|
261
|
+
version: '>=5.3'
|
|
262
|
+
source:
|
|
263
|
+
registry_url: https://components.espressif.com
|
|
264
|
+
type: service
|
|
265
|
+
version: 0.0.9
|
|
109
266
|
espressif/esp_tinyusb:
|
|
110
267
|
component_hash: 0fab24246e07bdf919c6489d17a590cffbffbbf6a9c44d6235641645c8b946b7
|
|
111
268
|
dependencies:
|
|
@@ -126,6 +283,76 @@ dependencies:
|
|
|
126
283
|
- esp32h4
|
|
127
284
|
- esp32s31
|
|
128
285
|
version: 2.3.0
|
|
286
|
+
espressif/esp_video:
|
|
287
|
+
component_hash: 5694b16c12b8bb26b56ad3f999ad10119f1314d64b2d1c518bc7dfed902df9e1
|
|
288
|
+
dependencies:
|
|
289
|
+
- name: espressif/cmake_utilities
|
|
290
|
+
registry_url: https://components.espressif.com
|
|
291
|
+
require: private
|
|
292
|
+
version: 0.*
|
|
293
|
+
- name: espressif/esp_cam_sensor
|
|
294
|
+
registry_url: https://components.espressif.com
|
|
295
|
+
require: private
|
|
296
|
+
version: 2.6.*
|
|
297
|
+
- matches:
|
|
298
|
+
- if: $CONFIG{ESP_VIDEO_USE_CUSTOMIZED_ESP_H264_VERSION} == False
|
|
299
|
+
name: espressif/esp_h264
|
|
300
|
+
registry_url: https://components.espressif.com
|
|
301
|
+
require: private
|
|
302
|
+
rules:
|
|
303
|
+
- if: target in [esp32p4]
|
|
304
|
+
version: 1.4.*
|
|
305
|
+
- name: espressif/esp_ipa
|
|
306
|
+
registry_url: https://components.espressif.com
|
|
307
|
+
require: private
|
|
308
|
+
rules:
|
|
309
|
+
- if: target in [esp32p4]
|
|
310
|
+
version: 2.4.*
|
|
311
|
+
- name: idf
|
|
312
|
+
require: private
|
|
313
|
+
version: '>=5.4'
|
|
314
|
+
- name: espressif/usb_host_uvc
|
|
315
|
+
registry_url: https://components.espressif.com
|
|
316
|
+
require: private
|
|
317
|
+
rules:
|
|
318
|
+
- if: target in [esp32p4, esp32s3, esp32s31]
|
|
319
|
+
version: 2.5.*
|
|
320
|
+
source:
|
|
321
|
+
registry_url: https://components.espressif.com/
|
|
322
|
+
type: service
|
|
323
|
+
targets:
|
|
324
|
+
- esp32p4
|
|
325
|
+
- esp32s3
|
|
326
|
+
- esp32c3
|
|
327
|
+
- esp32c5
|
|
328
|
+
- esp32c6
|
|
329
|
+
- esp32c61
|
|
330
|
+
- esp32s31
|
|
331
|
+
version: 2.5.0
|
|
332
|
+
espressif/esp_websocket_client:
|
|
333
|
+
component_hash: dc00233af846f3a744ada283a300e0d586040aadc3ee67361645ecdce4523672
|
|
334
|
+
dependencies:
|
|
335
|
+
- name: idf
|
|
336
|
+
require: private
|
|
337
|
+
version: '>=5.0'
|
|
338
|
+
source:
|
|
339
|
+
registry_url: https://components.espressif.com/
|
|
340
|
+
type: service
|
|
341
|
+
version: 1.8.0
|
|
342
|
+
espressif/i2c_bus:
|
|
343
|
+
component_hash: 483112c1619c54c38d0b734fb25f1678733267858a77b7af2f48cc7db6dbbd84
|
|
344
|
+
dependencies:
|
|
345
|
+
- name: espressif/cmake_utilities
|
|
346
|
+
registry_url: https://components.espressif.com
|
|
347
|
+
require: private
|
|
348
|
+
version: '*'
|
|
349
|
+
- name: idf
|
|
350
|
+
require: private
|
|
351
|
+
version: '>=4.0'
|
|
352
|
+
source:
|
|
353
|
+
registry_url: https://components.espressif.com
|
|
354
|
+
type: service
|
|
355
|
+
version: 1.5.2
|
|
129
356
|
espressif/spi_nand_flash:
|
|
130
357
|
component_hash: aa7bae693eee90b2e5e7cd63e67d41f5c30e61a501873b5c2d02838b1b9df6b8
|
|
131
358
|
dependencies:
|
|
@@ -170,20 +397,149 @@ dependencies:
|
|
|
170
397
|
- esp32h4
|
|
171
398
|
- esp32s31
|
|
172
399
|
version: 0.21.0~2
|
|
400
|
+
espressif/usb:
|
|
401
|
+
component_hash: 99eee72ea224d9117d4c342442717a1f20bf8112e2ab5d7d7038b827874f4c92
|
|
402
|
+
dependencies:
|
|
403
|
+
- name: idf
|
|
404
|
+
require: private
|
|
405
|
+
version: '>=5.5.3'
|
|
406
|
+
source:
|
|
407
|
+
registry_url: https://components.espressif.com
|
|
408
|
+
type: service
|
|
409
|
+
targets:
|
|
410
|
+
- esp32s2
|
|
411
|
+
- esp32s3
|
|
412
|
+
- esp32s31
|
|
413
|
+
- esp32p4
|
|
414
|
+
- esp32h4
|
|
415
|
+
- linux
|
|
416
|
+
version: 1.6.0
|
|
417
|
+
espressif/usb_host_uvc:
|
|
418
|
+
component_hash: ecb2604b71cb5a65d64e5f441be54793b1838096043ad8cf1fa0d3012de18a9a
|
|
419
|
+
dependencies:
|
|
420
|
+
- name: idf
|
|
421
|
+
require: private
|
|
422
|
+
version: '>=5.0'
|
|
423
|
+
- name: espressif/usb
|
|
424
|
+
registry_url: https://components.espressif.com
|
|
425
|
+
require: public
|
|
426
|
+
rules:
|
|
427
|
+
- if: idf_version >=6.0
|
|
428
|
+
- if: target not in ["linux"]
|
|
429
|
+
version: ^1.0.0
|
|
430
|
+
source:
|
|
431
|
+
registry_url: https://components.espressif.com
|
|
432
|
+
type: service
|
|
433
|
+
targets:
|
|
434
|
+
- esp32s2
|
|
435
|
+
- esp32s3
|
|
436
|
+
- esp32p4
|
|
437
|
+
- esp32h4
|
|
438
|
+
- esp32s31
|
|
439
|
+
- linux
|
|
440
|
+
version: 2.5.2
|
|
441
|
+
espressif2022/bmi270:
|
|
442
|
+
component_hash: 6c6637680a233845d13961f23df39426a7fad9c02c6c289bf8facbb7f8624e22
|
|
443
|
+
dependencies:
|
|
444
|
+
- name: espressif/cmake_utilities
|
|
445
|
+
registry_url: https://components.espressif.com
|
|
446
|
+
require: private
|
|
447
|
+
version: 0.*
|
|
448
|
+
- name: espressif/i2c_bus
|
|
449
|
+
registry_url: https://components.espressif.com
|
|
450
|
+
require: private
|
|
451
|
+
version: 1.*
|
|
452
|
+
- name: idf
|
|
453
|
+
require: private
|
|
454
|
+
version: '>=4.4'
|
|
455
|
+
source:
|
|
456
|
+
registry_url: https://components.espressif.com/
|
|
457
|
+
type: service
|
|
458
|
+
version: 1.1.0~2
|
|
173
459
|
idf:
|
|
174
460
|
source:
|
|
175
461
|
type: idf
|
|
176
462
|
version: 6.2.0
|
|
463
|
+
mosaico_boot_splash:
|
|
464
|
+
component_hash: 75f0fe6ae0b23792a92a047d371fac351ae972cbb188632633b5b3c665424e1e
|
|
465
|
+
dependencies:
|
|
466
|
+
- name: idf
|
|
467
|
+
version: '>=6.2'
|
|
468
|
+
source:
|
|
469
|
+
git: https://github.com/esp-mosaico/esp-mosaico-bsp.git
|
|
470
|
+
path: components/mosaico_boot_splash
|
|
471
|
+
type: git
|
|
472
|
+
targets:
|
|
473
|
+
- esp32s31
|
|
474
|
+
version: a4bfb426afcf2911c01fdd9b6d6f024019f00f8f
|
|
475
|
+
mosaico_module_camera:
|
|
476
|
+
component_hash: ed3a838b50c512fa6d00aca444bae2bfa28574c094118435df93f3fc864d2945
|
|
477
|
+
dependencies:
|
|
478
|
+
- name: idf
|
|
479
|
+
version: '>=6.2'
|
|
480
|
+
- git: https://github.com/esp-mosaico/esp-mosaico-bsp.git
|
|
481
|
+
name: esp-mosaico-bsp
|
|
482
|
+
path: components/esp-mosaico-bsp
|
|
483
|
+
version: a4bfb426afcf2911c01fdd9b6d6f024019f00f8f
|
|
484
|
+
- git: https://github.com/esp-mosaico/esp-mosaico-bsp.git
|
|
485
|
+
name: mosaico_module_mgr
|
|
486
|
+
path: components/mosaico_module_mgr
|
|
487
|
+
public: true
|
|
488
|
+
version: a4bfb426afcf2911c01fdd9b6d6f024019f00f8f
|
|
489
|
+
- name: espressif/esp_video
|
|
490
|
+
public: true
|
|
491
|
+
version: ^2.4.1
|
|
492
|
+
source:
|
|
493
|
+
git: https://github.com/esp-mosaico/esp-mosaico-bsp.git
|
|
494
|
+
path: components/mosaico_module_camera
|
|
495
|
+
type: git
|
|
496
|
+
targets:
|
|
497
|
+
- esp32s31
|
|
498
|
+
version: a4bfb426afcf2911c01fdd9b6d6f024019f00f8f
|
|
499
|
+
mosaico_module_mgr:
|
|
500
|
+
component_hash: a8954bc6f445dfdfab66d63927718c5fcb1ea5c294db3a62f1ddc2103d8b03f9
|
|
501
|
+
dependencies:
|
|
502
|
+
- git: https://github.com/esp-mosaico/esp-mosaico-bsp.git
|
|
503
|
+
name: esp-mosaico-bsp
|
|
504
|
+
path: components/esp-mosaico-bsp
|
|
505
|
+
public: true
|
|
506
|
+
version: a4bfb426afcf2911c01fdd9b6d6f024019f00f8f
|
|
507
|
+
source:
|
|
508
|
+
git: https://github.com/esp-mosaico/esp-mosaico-bsp.git
|
|
509
|
+
path: components/mosaico_module_mgr
|
|
510
|
+
type: git
|
|
511
|
+
targets:
|
|
512
|
+
- esp32s31
|
|
513
|
+
version: a4bfb426afcf2911c01fdd9b6d6f024019f00f8f
|
|
514
|
+
tangyumei3535/bmm150_sensorapi:
|
|
515
|
+
component_hash: fe12d09c0ff06fabe9f4ae8fcc54b8b0ee59b936650bd26e8a3742e282fa4465
|
|
516
|
+
dependencies:
|
|
517
|
+
- name: espressif2022/bmi270
|
|
518
|
+
registry_url: https://components.espressif.com
|
|
519
|
+
require: private
|
|
520
|
+
version: '*'
|
|
521
|
+
- name: idf
|
|
522
|
+
require: private
|
|
523
|
+
version: '>=4.4'
|
|
524
|
+
source:
|
|
525
|
+
registry_url: https://components.espressif.com/
|
|
526
|
+
type: service
|
|
527
|
+
version: 1.0.0
|
|
177
528
|
direct_dependencies:
|
|
529
|
+
- 78/esp-opus
|
|
178
530
|
- espressif/cjson
|
|
179
531
|
- espressif/esp_codec_dev
|
|
532
|
+
- espressif/esp_h264
|
|
180
533
|
- espressif/esp_lcd_co5300
|
|
181
534
|
- espressif/esp_lcd_panel_io_additions
|
|
182
535
|
- espressif/esp_lcd_touch_cst9220
|
|
536
|
+
- espressif/esp_peer
|
|
183
537
|
- espressif/esp_tinyusb
|
|
538
|
+
- espressif/esp_websocket_client
|
|
184
539
|
- espressif/spi_nand_flash
|
|
185
540
|
- espressif/spi_nand_flash_fatfs
|
|
186
541
|
- idf
|
|
542
|
+
- mosaico_module_camera
|
|
187
543
|
manifest_hash: a6fdc7e010a8befa9c59a7ccd4b58665dba6209368539d6ae58315d28881a0da
|
|
188
544
|
target: esp32s31
|
|
189
545
|
version: 3.0.0
|
|
@@ -49,6 +49,14 @@ set(GEA_BOARD_EXTRA_COMPILE_DEFINITIONS
|
|
|
49
49
|
GEA_BOARD_TOUCH_CST9220=1
|
|
50
50
|
)
|
|
51
51
|
|
|
52
|
+
# Canvas rotation changes its native storage layout, so it must be enabled
|
|
53
|
+
# consistently by the app for both the framework and board compilation.
|
|
54
|
+
if(";${GEA_EMBEDDED_APP_DEFINES};$ENV{GEA_EMBEDDED_APP_DEFINES};" MATCHES ";GEA_EMBEDDED_DISPLAY_ROTATE_LANDSCAPE=1;")
|
|
55
|
+
list(APPEND GEA_BOARD_EXTRA_COMPILE_DEFINITIONS
|
|
56
|
+
GEA_EMBEDDED_DISPLAY_SOFTWARE_LANDSCAPE_PRIMARY=1
|
|
57
|
+
GEA_EMBEDDED_DISPLAY_RUNTIME_SOFTWARE_ORIENTATION=1)
|
|
58
|
+
endif()
|
|
59
|
+
|
|
52
60
|
set(GEA_BOARD_PLATFORM_SOURCES
|
|
53
61
|
"${CMAKE_CURRENT_LIST_DIR}/../../esp32-s3-touch-amoled-1.8/main/app_main.cpp"
|
|
54
62
|
"${CMAKE_CURRENT_LIST_DIR}/../../esp32-s3-touch-amoled-1.8/main/i2c.cpp"
|
|
@@ -36,6 +36,8 @@ public:
|
|
|
36
36
|
std::uint8_t *jpeg = nullptr;
|
|
37
37
|
std::size_t rgbCapacity = 0, jpegCapacity = 0;
|
|
38
38
|
frame::Size size;
|
|
39
|
+
frame::Size previewSize;
|
|
40
|
+
std::atomic<unsigned> previewCopies{0};
|
|
39
41
|
std::atomic<bool> running{false};
|
|
40
42
|
std::atomic<bool> mirror{false};
|
|
41
43
|
SemaphoreHandle_t exited = nullptr;
|
|
@@ -55,18 +57,55 @@ public:
|
|
|
55
57
|
static void captureTask(void *opaque) {
|
|
56
58
|
auto &self = *static_cast<CameraDriver *>(opaque);
|
|
57
59
|
std::int64_t nextEncode = 0;
|
|
60
|
+
std::int64_t nextPreview = 0;
|
|
61
|
+
std::int64_t previewReportAt = esp_timer_get_time();
|
|
62
|
+
unsigned previewFrames = 0;
|
|
63
|
+
unsigned consecutiveTimeouts = 0;
|
|
58
64
|
while (self.running.load()) {
|
|
59
65
|
mosaico_camera_frame_t source{};
|
|
60
66
|
const auto got = mosaico_camera_get_frame(self.camera, &source);
|
|
61
67
|
if (got != ESP_OK) {
|
|
68
|
+
if (got == ESP_ERR_TIMEOUT && ++consecutiveTimeouts == 3 && self.running.load()) {
|
|
69
|
+
// No frame is borrowed here. Re-arm a stalled DVP queue through the
|
|
70
|
+
// SDK's stream lifecycle instead of leaving the viewer frozen forever.
|
|
71
|
+
const auto restarted = mosaico_camera_restart(self.camera);
|
|
72
|
+
ESP_LOGW(kTag, "Camera timeout recovery: %s", esp_err_to_name(restarted));
|
|
73
|
+
consecutiveTimeouts = 0;
|
|
74
|
+
}
|
|
62
75
|
vTaskDelay(pdMS_TO_TICKS(10));
|
|
63
76
|
continue;
|
|
64
77
|
}
|
|
78
|
+
consecutiveTimeouts = 0;
|
|
65
79
|
const auto now = esp_timer_get_time();
|
|
66
80
|
bool converted = false;
|
|
81
|
+
std::vector<pixel::native_t> preview;
|
|
82
|
+
const std::size_t stride = source.bytes_per_line ? source.bytes_per_line : source.width * 2;
|
|
83
|
+
if (source.pixel_format == V4L2_PIX_FMT_UYVY &&
|
|
84
|
+
now >= nextPreview &&
|
|
85
|
+
source.size / stride >= source.height) {
|
|
86
|
+
// Keep a fixed cadence: scheduling from each received frame would
|
|
87
|
+
// drop every other frame on a 15 Hz sensor and cap preview at 7.5 Hz.
|
|
88
|
+
nextPreview = (now / 100000 + 1) * 100000;
|
|
89
|
+
const int w = self.previewSize.width, h = self.previewSize.height;
|
|
90
|
+
preview.resize(std::size_t(w) * h);
|
|
91
|
+
const auto channel = [](int value) { return std::uint8_t(std::clamp(value, 0, 255)); };
|
|
92
|
+
for (int y = 0; y < h; ++y) for (int x = 0; x < w; ++x) {
|
|
93
|
+
// The left-slot sensor is mounted upside down. Subsample directly
|
|
94
|
+
// from the sensor buffer, correcting its mounting without a resize pass.
|
|
95
|
+
const int sx = source.width - 1 - x * source.width / w;
|
|
96
|
+
const int sy = source.height - 1 - y * source.height / h;
|
|
97
|
+
const auto *pair = static_cast<const std::uint8_t *>(source.data) +
|
|
98
|
+
std::size_t(sy) * stride + std::size_t(sx / 2) * 4;
|
|
99
|
+
const int c = std::max(0, int(pair[sx & 1 ? 3 : 1]) - 16);
|
|
100
|
+
const int u = int(pair[0]) - 128, v = int(pair[2]) - 128;
|
|
101
|
+
preview[y * w + x] = pixel::nativeColor(
|
|
102
|
+
channel((298 * c + 409 * v + 128) >> 8),
|
|
103
|
+
channel((298 * c - 100 * u - 208 * v + 128) >> 8),
|
|
104
|
+
channel((298 * c + 516 * u + 128) >> 8));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
67
107
|
if (now >= nextEncode && source.pixel_format == V4L2_PIX_FMT_UYVY) {
|
|
68
108
|
nextEncode = now + kFrameIntervalUs;
|
|
69
|
-
const std::size_t stride = source.bytes_per_line ? source.bytes_per_line : source.width * 2;
|
|
70
109
|
converted = frame::uyvyToRgb888Ccw90(
|
|
71
110
|
static_cast<const std::uint8_t *>(source.data), source.size,
|
|
72
111
|
source.width, source.height, stride, self.rgb, self.rgbCapacity,
|
|
@@ -80,11 +119,21 @@ public:
|
|
|
80
119
|
self.running.store(false);
|
|
81
120
|
break;
|
|
82
121
|
}
|
|
122
|
+
if (!preview.empty()) {
|
|
123
|
+
std::lock_guard guard(self.lock);
|
|
124
|
+
self.pixels.swap(preview);
|
|
125
|
+
++previewFrames;
|
|
126
|
+
}
|
|
127
|
+
if (now - previewReportAt >= 5'000'000) {
|
|
128
|
+
ESP_LOGI(kTag, "Preview: %u sampled frames, %u surface copies in %lld ms",
|
|
129
|
+
previewFrames, self.previewCopies.exchange(0),
|
|
130
|
+
static_cast<long long>((now - previewReportAt) / 1000));
|
|
131
|
+
previewFrames = 0;
|
|
132
|
+
previewReportAt = now;
|
|
133
|
+
}
|
|
83
134
|
if (!converted || !self.running.load()) continue;
|
|
84
|
-
std::
|
|
85
|
-
for (std::size_t i = 0; i < preview.size(); ++i) {
|
|
135
|
+
for (std::size_t i = 0; i < std::size_t(self.size.width) * self.size.height; ++i) {
|
|
86
136
|
auto *color = self.rgb + i * 3;
|
|
87
|
-
preview[i] = pixel::nativeColor(color[0], color[1], color[2]);
|
|
88
137
|
// ESP-IDF's RGB888 encoder input is explicitly BGR24 (jpeg_types.h).
|
|
89
138
|
std::swap(color[0], color[2]);
|
|
90
139
|
}
|
|
@@ -105,7 +154,6 @@ public:
|
|
|
105
154
|
if (url.empty()) continue;
|
|
106
155
|
std::lock_guard guard(self.lock);
|
|
107
156
|
self.latest.swap(url);
|
|
108
|
-
self.pixels.swap(preview);
|
|
109
157
|
}
|
|
110
158
|
xSemaphoreGive(self.exited);
|
|
111
159
|
vTaskDelete(nullptr);
|
|
@@ -115,11 +163,11 @@ public:
|
|
|
115
163
|
Camera::setFrameProvider(nullptr);
|
|
116
164
|
running.store(false);
|
|
117
165
|
if (exited) {
|
|
118
|
-
// Sensor reads have a
|
|
166
|
+
// Sensor reads have a 1000ms deadline and JPEG has a 500ms deadline.
|
|
119
167
|
// If a driver nevertheless stalls, preserve its live buffers/handles
|
|
120
168
|
// and let a later close/open retry cleanup instead of hanging the app.
|
|
121
|
-
if (xSemaphoreTake(exited, pdMS_TO_TICKS(
|
|
122
|
-
ESP_LOGE(kTag, "Camera worker did not stop within
|
|
169
|
+
if (xSemaphoreTake(exited, pdMS_TO_TICKS(2000)) != pdTRUE) {
|
|
170
|
+
ESP_LOGE(kTag, "Camera worker did not stop within 2000ms; resources retained");
|
|
123
171
|
return;
|
|
124
172
|
}
|
|
125
173
|
vSemaphoreDelete(exited);
|
|
@@ -143,6 +191,8 @@ public:
|
|
|
143
191
|
std::string().swap(latest);
|
|
144
192
|
std::vector<pixel::native_t>().swap(pixels);
|
|
145
193
|
size = {};
|
|
194
|
+
previewSize = {};
|
|
195
|
+
previewCopies.store(0);
|
|
146
196
|
}
|
|
147
197
|
|
|
148
198
|
void close() {
|
|
@@ -158,7 +208,8 @@ public:
|
|
|
158
208
|
mosaico_camera_config_t config = MOSAICO_CAMERA_DEFAULT_CONFIG();
|
|
159
209
|
// The two sensors have different supported sizes. Let the SDK detect
|
|
160
210
|
// either sensor's UYVY default, then downsample for upload on this worker.
|
|
161
|
-
|
|
211
|
+
// Keep the SDK's 1000ms deadline: stream startup dequeues the first
|
|
212
|
+
// frame too, and the SC101IOT does not reliably deliver it within 100ms.
|
|
162
213
|
auto result = mosaico_camera_new(&config, &camera);
|
|
163
214
|
if (result == ESP_OK) result = mosaico_camera_open(camera);
|
|
164
215
|
mosaico_camera_info_t info{};
|
|
@@ -166,6 +217,7 @@ public:
|
|
|
166
217
|
if (result == ESP_OK) {
|
|
167
218
|
std::lock_guard guard(lock);
|
|
168
219
|
size = frame::uploadSize(info.width, info.height);
|
|
220
|
+
previewSize = {160, int(160 * info.height / info.width)};
|
|
169
221
|
if (info.pixel_format != V4L2_PIX_FMT_UYVY || size.width == 0) result = ESP_ERR_NOT_SUPPORTED;
|
|
170
222
|
}
|
|
171
223
|
if (result == ESP_OK) {
|
|
@@ -217,9 +269,9 @@ bool Camera::open(const std::string &hint, int, int) {
|
|
|
217
269
|
}
|
|
218
270
|
void Camera::close() { driver().close(); }
|
|
219
271
|
bool Camera::isOpen() { return driver().running.load(); }
|
|
220
|
-
int Camera::width() { auto &state = driver(); std::lock_guard guard(state.lock); return state.
|
|
221
|
-
int Camera::height() { auto &state = driver(); std::lock_guard guard(state.lock); return state.
|
|
222
|
-
int Camera::orientation() { return
|
|
272
|
+
int Camera::width() { auto &state = driver(); std::lock_guard guard(state.lock); return state.previewSize.width; }
|
|
273
|
+
int Camera::height() { auto &state = driver(); std::lock_guard guard(state.lock); return state.previewSize.height; }
|
|
274
|
+
int Camera::orientation() { return 180; }
|
|
223
275
|
Facing Camera::currentFacing() { return Facing::External; }
|
|
224
276
|
std::string Camera::currentFacingString() { return "external"; }
|
|
225
277
|
int Camera::deviceCount() { return 1; }
|
|
@@ -232,7 +284,18 @@ bool Camera::fillPreview(pixel::native_t *dst, int w, int h, int fit, bool mirro
|
|
|
232
284
|
if (!dst || w <= 0 || h <= 0) return false;
|
|
233
285
|
std::unique_lock guard(state.lock, std::try_to_lock);
|
|
234
286
|
if (!guard.owns_lock() || state.pixels.empty()) return false;
|
|
235
|
-
const int sw = state.
|
|
287
|
+
const int sw = state.previewSize.width, sh = state.previewSize.height;
|
|
288
|
+
++state.previewCopies;
|
|
289
|
+
if (w * sh == h * sw || fit == 2) {
|
|
290
|
+
for (int y = 0; y < h; ++y) {
|
|
291
|
+
const auto *row = state.pixels.data() + (y * sh / h) * sw;
|
|
292
|
+
for (int x = 0; x < w; ++x) {
|
|
293
|
+
const int sx = x * sw / w;
|
|
294
|
+
dst[y * w + x] = row[mirror ? sw - 1 - sx : sx];
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
236
299
|
const double scale = fit == 1 ? std::min(double(w) / sw, double(h) / sh) : std::max(double(w) / sw, double(h) / sh);
|
|
237
300
|
const double rw = fit == 2 ? w : sw * scale, rh = fit == 2 ? h : sh * scale;
|
|
238
301
|
for (int y = 0; y < h; ++y) for (int x = 0; x < w; ++x) {
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
# so each network-only component carries the same capability rule the other
|
|
3
3
|
# targets use (GEA_EMBEDDED_CAPABILITY_* comes from the gea CLI's app analysis).
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
# former, and an app that asks for echo cancellation is not supported yet.
|
|
5
|
+
# ESP-SR now ships S31 libraries. Keep them optional for voice apps using AEC;
|
|
6
|
+
# the portable Opus build below still replaces the unsupported audio codec.
|
|
8
7
|
dependencies:
|
|
8
|
+
espressif/esp-sr:
|
|
9
|
+
version: '==2.6.0'
|
|
10
|
+
rules:
|
|
11
|
+
- if: '$GEA_EMBEDDED_CAPABILITY_AEC == 1'
|
|
9
12
|
# Official module ownership, sensor autodetection and DVP stability patches.
|
|
10
13
|
# The pinned Git checkout also supplies its relative BSP/manager components.
|
|
11
14
|
mosaico_module_camera:
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// Override through the Mosaico board's package.json defines. Defaults retain
|
|
4
|
+
// the original H1 12 -> H2 12 and H1 11 <- H2 11 side-header harness.
|
|
5
|
+
#ifndef GEA_MOSAICO_PEER_LEFT_TX_GPIO
|
|
6
|
+
#define GEA_MOSAICO_PEER_LEFT_TX_GPIO 15
|
|
7
|
+
#endif
|
|
8
|
+
#ifndef GEA_MOSAICO_PEER_LEFT_RX_GPIO
|
|
9
|
+
#define GEA_MOSAICO_PEER_LEFT_RX_GPIO 4
|
|
10
|
+
#endif
|
|
11
|
+
#ifndef GEA_MOSAICO_PEER_RIGHT_TX_GPIO
|
|
12
|
+
#define GEA_MOSAICO_PEER_RIGHT_TX_GPIO 5
|
|
13
|
+
#endif
|
|
14
|
+
#ifndef GEA_MOSAICO_PEER_RIGHT_RX_GPIO
|
|
15
|
+
#define GEA_MOSAICO_PEER_RIGHT_RX_GPIO 38
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
namespace gea::platform::board::peer {
|
|
19
|
+
struct PinPair {
|
|
20
|
+
int tx;
|
|
21
|
+
int rx;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
inline constexpr PinPair left{GEA_MOSAICO_PEER_LEFT_TX_GPIO,
|
|
25
|
+
GEA_MOSAICO_PEER_LEFT_RX_GPIO};
|
|
26
|
+
inline constexpr PinPair right{GEA_MOSAICO_PEER_RIGHT_TX_GPIO,
|
|
27
|
+
GEA_MOSAICO_PEER_RIGHT_RX_GPIO};
|
|
28
|
+
|
|
29
|
+
// Only unclaimed V1.2 expansion GPIOs. In this target GPIO0/1 are the unused
|
|
30
|
+
// expansion I2C bus; the onboard touch/sensors use GPIO56/3. Exclude the
|
|
31
|
+
// codec, display, NAND, power controls, USB/JTAG and UART0 console pins.
|
|
32
|
+
constexpr bool isExpansionGpio(int pin) {
|
|
33
|
+
switch (pin) {
|
|
34
|
+
case 0:
|
|
35
|
+
case 1:
|
|
36
|
+
case 4:
|
|
37
|
+
case 5:
|
|
38
|
+
case 10:
|
|
39
|
+
case 11:
|
|
40
|
+
case 12:
|
|
41
|
+
case 13:
|
|
42
|
+
case 14:
|
|
43
|
+
case 15:
|
|
44
|
+
case 16:
|
|
45
|
+
case 17:
|
|
46
|
+
case 18:
|
|
47
|
+
case 19:
|
|
48
|
+
case 38:
|
|
49
|
+
case 39:
|
|
50
|
+
case 46:
|
|
51
|
+
case 47:
|
|
52
|
+
case 48:
|
|
53
|
+
case 53:
|
|
54
|
+
case 55:
|
|
55
|
+
return true;
|
|
56
|
+
default:
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static_assert(isExpansionGpio(left.tx) && isExpansionGpio(left.rx) &&
|
|
62
|
+
isExpansionGpio(right.tx) && isExpansionGpio(right.rx),
|
|
63
|
+
"Mosaico peer UART pins must be unclaimed expansion GPIOs");
|
|
64
|
+
static_assert(left.tx != left.rx && left.tx != right.tx &&
|
|
65
|
+
left.tx != right.rx && left.rx != right.tx &&
|
|
66
|
+
left.rx != right.rx && right.tx != right.rx,
|
|
67
|
+
"Mosaico peer UART requires four distinct GPIOs");
|
|
68
|
+
} // namespace gea::platform::board::peer
|
|
@@ -1,86 +1,42 @@
|
|
|
1
|
-
#include "driver/gpio.h"
|
|
2
|
-
#include "driver/uart.h"
|
|
3
|
-
#include "esp_err.h"
|
|
4
|
-
#include "freertos/FreeRTOS.h"
|
|
5
1
|
#include "mosaico_peer_uart.h"
|
|
6
|
-
#include
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
int tx, rx;
|
|
14
|
-
};
|
|
15
|
-
constexpr std::array<Pins, 2> pins{{{UART_NUM_1, 15, 4}, {UART_NUM_2, 5, 38}}};
|
|
16
|
-
bool opened = false;
|
|
17
|
-
} // namespace
|
|
18
|
-
extern "C" bool gea_mosaico_peer_uart_open(uint32_t baud) {
|
|
2
|
+
#include "mosaico_peer_uart_pins.h"
|
|
3
|
+
#include "platform/uart.h"
|
|
4
|
+
|
|
5
|
+
namespace peer = gea::platform::board::peer;
|
|
6
|
+
using gea::platform::uart::Uart;
|
|
7
|
+
|
|
8
|
+
extern "C" bool gea_board_uart_pin_allowed(int pin) {
|
|
19
9
|
#if GEA_MOSAICO_CAMERA_ENABLED
|
|
20
|
-
// Camera expansion owns these side GPIOs when that capability is enabled.
|
|
21
10
|
return false;
|
|
11
|
+
#else
|
|
12
|
+
return peer::isExpansionGpio(pin);
|
|
22
13
|
#endif
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Compatibility for native apps using the original side-link entry points.
|
|
17
|
+
// New applications configure controllers through the public Uart API.
|
|
18
|
+
extern "C" bool gea_mosaico_peer_uart_open(uint32_t baud) {
|
|
25
19
|
if (baud < 115200 || baud > 5000000)
|
|
26
20
|
return false;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
config.data_bits = UART_DATA_8_BITS;
|
|
36
|
-
config.parity = UART_PARITY_DISABLE;
|
|
37
|
-
config.stop_bits = UART_STOP_BITS_1;
|
|
38
|
-
config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;
|
|
39
|
-
config.source_clk = UART_SCLK_DEFAULT;
|
|
40
|
-
// RX driver storage and TX ring are reserved once, off the audio path.
|
|
41
|
-
if (uart_param_config(p.uart, &config) != ESP_OK ||
|
|
42
|
-
uart_set_pin(p.uart, p.tx, p.rx, UART_PIN_NO_CHANGE,
|
|
43
|
-
UART_PIN_NO_CHANGE) != ESP_OK ||
|
|
44
|
-
uart_driver_install(p.uart, 4096, 4096, 0, nullptr, 0) != ESP_OK) {
|
|
45
|
-
for (unsigned i = 0; i < installed; ++i)
|
|
46
|
-
uart_driver_delete(pins[i].uart);
|
|
47
|
-
for (const auto &reset : pins) {
|
|
48
|
-
gpio_reset_pin(static_cast<gpio_num_t>(reset.tx));
|
|
49
|
-
gpio_reset_pin(static_cast<gpio_num_t>(reset.rx));
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
++installed;
|
|
54
|
-
uart_set_rx_full_threshold(p.uart, 96);
|
|
55
|
-
uart_set_rx_timeout(p.uart, 2);
|
|
56
|
-
}
|
|
57
|
-
opened = true;
|
|
58
|
-
return true;
|
|
21
|
+
const bool leftWasOpen = Uart::isOpen(1);
|
|
22
|
+
if (!Uart::open(1, {peer::left.tx, peer::left.rx, static_cast<int>(baud)}))
|
|
23
|
+
return false;
|
|
24
|
+
if (Uart::open(2, {peer::right.tx, peer::right.rx, static_cast<int>(baud)}))
|
|
25
|
+
return true;
|
|
26
|
+
if (!leftWasOpen)
|
|
27
|
+
Uart::close(1);
|
|
28
|
+
return false;
|
|
59
29
|
}
|
|
60
|
-
extern "C" void gea_mosaico_peer_uart_close(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
for (const auto &p : pins) {
|
|
64
|
-
uart_driver_delete(p.uart);
|
|
65
|
-
gpio_reset_pin(static_cast<gpio_num_t>(p.tx));
|
|
66
|
-
gpio_reset_pin(static_cast<gpio_num_t>(p.rx));
|
|
67
|
-
}
|
|
68
|
-
opened = false;
|
|
30
|
+
extern "C" void gea_mosaico_peer_uart_close() {
|
|
31
|
+
Uart::close(1);
|
|
32
|
+
Uart::close(2);
|
|
69
33
|
}
|
|
70
34
|
extern "C" int gea_mosaico_peer_uart_read(unsigned side, void *bytes,
|
|
71
35
|
size_t capacity) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return uart_read_bytes(pins[side].uart, bytes, capacity, 0);
|
|
36
|
+
return side < 2 ? Uart::read(static_cast<int>(side) + 1, bytes, capacity)
|
|
37
|
+
: -1;
|
|
75
38
|
}
|
|
76
39
|
extern "C" int gea_mosaico_peer_uart_write(unsigned side, const void *bytes,
|
|
77
40
|
size_t length) {
|
|
78
|
-
|
|
79
|
-
return -1;
|
|
80
|
-
// The transport task owns this call. DSP only pushes its preallocated queue.
|
|
81
|
-
size_t free = 0;
|
|
82
|
-
if (uart_get_tx_buffer_free_size(pins[side].uart, &free) != ESP_OK ||
|
|
83
|
-
free < length + 32)
|
|
84
|
-
return 0;
|
|
85
|
-
return uart_write_bytes(pins[side].uart, bytes, length);
|
|
41
|
+
return side < 2 ? Uart::write(static_cast<int>(side) + 1, bytes, length) : -1;
|
|
86
42
|
}
|