@geastack/targets 0.1.101 → 0.1.102

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/targets",
3
- "version": "0.1.101",
3
+ "version": "0.1.102",
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,10 +37,10 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@geastack/chips": "^0.1.6",
40
- "@geastack/compiler": "^1.0.29",
40
+ "@geastack/compiler": "^1.0.33",
41
41
  "@geastack/core": "^0.1.40",
42
42
  "@geastack/elements": "^0.1.6",
43
- "@geastack/engine": "^0.1.16",
43
+ "@geastack/engine": "^0.1.17",
44
44
  "@geastack/geaos": "^0.1.3",
45
45
  "@geastack/geatsc-plugin-gea": "^0.1.22",
46
46
  "@geastack/host": "^0.1.15"
@@ -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
- Not yet wired: the BQ27220 fuel gauge (the board reports no battery reading),
65
- the magnetometers and the SPI NAND.
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
- Still captures and preview use the same bounded snapshots. Video recording,
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
- time out after 100 ms and encoding after 500 ms. The worker join waits at most 1500 ms;
94
- if the SDK stalls, it logs the failure and retains the live resources so that a
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. Check configuration output for patch
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::vector<pixel::native_t> preview(std::size_t(self.size.width) * self.size.height);
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 100ms deadline and JPEG has a 500ms deadline.
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(1500)) != pdTRUE) {
122
- ESP_LOGE(kTag, "Camera worker did not stop within 1500ms; resources retained");
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
- config.frame_timeout_ms = 100;
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.size.width; }
221
- int Camera::height() { auto &state = driver(); std::lock_guard guard(state.lock); return state.size.height; }
222
- int Camera::orientation() { return 0; }
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.size.width, sh = state.size.height;
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
- # Not here, unlike the S3 AMOLED targets: esp_audio_codec and esp-sr ship
6
- # prebuilt per-chip libraries; the portable Opus build below stands in for the
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: