@geastack/targets 0.1.110 → 0.1.112
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 +3 -3
- package/targets/esp32/chip_bindings/audio/ns4168.cpp +2 -2
- package/targets/esp32/chip_bindings/displays/rgb_panel.cpp +323 -4
- package/targets/esp32/chip_bindings/expanders/elecrow_stc8h1k17.cpp +155 -0
- package/targets/esp32/chip_bindings/expanders/elecrow_stc8h1k17.h +20 -0
- package/targets/esp32/chip_bindings/power/elecrow_stc8h1k17.cpp +35 -0
- package/targets/esp32/services/app_state.cpp +20 -2
- package/targets/esp32/services/device_control.cpp +59 -23
- package/targets/esp32-p4-elecrow-crowpanel-advanced-5.0.json +169 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/CMakeLists.txt +7 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/CMakeLists.txt +83 -15
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/camera.cpp +61 -5
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/launcher_button.cpp +7 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/sdcard_mount.cpp +30 -4
- package/targets.json +20 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#include "camera.h"
|
|
2
2
|
|
|
3
|
+
#include "board.h"
|
|
3
4
|
#include "canvas.h"
|
|
5
|
+
#if GEA_CUSTOM_TARGET_ACTIVE && GEA_BOARD_HAS_EXPANDER
|
|
6
|
+
#include "chip_bindings/expanders/io_expander.h"
|
|
7
|
+
#endif
|
|
4
8
|
#include "display.h"
|
|
5
9
|
#include "i2c.h"
|
|
6
10
|
#include "image.h"
|
|
@@ -60,16 +64,35 @@ namespace {
|
|
|
60
64
|
|
|
61
65
|
constexpr char kTag[] = "p4_camera";
|
|
62
66
|
constexpr char kDevicePath[] = "/dev/video0";
|
|
67
|
+
#if GEA_CUSTOM_TARGET_ACTIVE
|
|
68
|
+
// A composed board previews at its panel's size.
|
|
69
|
+
constexpr int kDefaultWidth = GEA_EMBEDDED_DISPLAY_WIDTH;
|
|
70
|
+
constexpr int kDefaultHeight = GEA_EMBEDDED_DISPLAY_HEIGHT;
|
|
71
|
+
#else
|
|
63
72
|
constexpr int kDefaultWidth = 800;
|
|
64
73
|
constexpr int kDefaultHeight = 1280;
|
|
74
|
+
#endif
|
|
65
75
|
constexpr int kBufferCount = 3;
|
|
66
76
|
constexpr int kSccbFrequencyHz = 400000;
|
|
67
77
|
// The OV5647 module is mounted 90deg rotated, so frames arrive rotated 90deg
|
|
68
78
|
// clockwise; rotate the preview 90deg counter-clockwise (one quarter turn) to
|
|
69
79
|
// bring the scene upright. With the display in LANDSCAPE orientation (it PPA-
|
|
70
80
|
// rotates the framebuffer 90deg), this rot=1 lands the scene upright on-screen.
|
|
71
|
-
// (Confirmed correct on-device.)
|
|
81
|
+
// (Confirmed correct on-device.) A composed board names its mounting in quarter
|
|
82
|
+
// turns counter-clockwise (the definition's camera.rotation).
|
|
83
|
+
#if !GEA_CUSTOM_TARGET_ACTIVE
|
|
72
84
|
constexpr int kPreviewRotateCcw = 1;
|
|
85
|
+
#elif GEA_BOARD_HAS_CAMERA
|
|
86
|
+
constexpr int kPreviewRotateCcw = gea::platform::board::camera.rotateCcw;
|
|
87
|
+
#else
|
|
88
|
+
constexpr int kPreviewRotateCcw = 0;
|
|
89
|
+
#endif
|
|
90
|
+
// Whether this build has a camera at all: the Waveshare board always does.
|
|
91
|
+
#if GEA_CUSTOM_TARGET_ACTIVE
|
|
92
|
+
constexpr bool kHasCamera = GEA_BOARD_HAS_CAMERA != 0;
|
|
93
|
+
#else
|
|
94
|
+
constexpr bool kHasCamera = true;
|
|
95
|
+
#endif
|
|
73
96
|
// OV5647 default auto-exposure target brightness (OV5647_AE_TARGET_DEFAULT, range
|
|
74
97
|
// 2..235). setExposure() shifts this to brighten/darken the auto-exposed preview.
|
|
75
98
|
constexpr int kAeTargetDefault = 0x50;
|
|
@@ -180,7 +203,7 @@ public:
|
|
|
180
203
|
return driver;
|
|
181
204
|
}
|
|
182
205
|
|
|
183
|
-
bool isAvailable() const { return
|
|
206
|
+
bool isAvailable() const { return kHasCamera; }
|
|
184
207
|
bool hasPermission() const { return true; }
|
|
185
208
|
bool requestPermission() const { return true; }
|
|
186
209
|
|
|
@@ -262,12 +285,19 @@ public:
|
|
|
262
285
|
}
|
|
263
286
|
}
|
|
264
287
|
|
|
265
|
-
int deviceCount() const { return 1; }
|
|
288
|
+
int deviceCount() const { return kHasCamera ? 1 : 0; }
|
|
266
289
|
|
|
267
290
|
gea::platform::camera::DeviceInfo deviceAt(int index) const
|
|
268
291
|
{
|
|
269
292
|
if (index != 0) return {};
|
|
293
|
+
#if !GEA_CUSTOM_TARGET_ACTIVE
|
|
270
294
|
return {"mipi-csi-ov5647-center", gea::platform::camera::Facing::Front, kDefaultWidth, kDefaultHeight};
|
|
295
|
+
#elif GEA_BOARD_HAS_CAMERA
|
|
296
|
+
return {gea::platform::board::camera.name, gea::platform::camera::Facing::Front, kDefaultWidth, kDefaultHeight};
|
|
297
|
+
#else
|
|
298
|
+
(void)index;
|
|
299
|
+
return {};
|
|
300
|
+
#endif
|
|
271
301
|
}
|
|
272
302
|
|
|
273
303
|
void drawPreview(int x, int y, int destW, int destH)
|
|
@@ -849,16 +879,42 @@ private:
|
|
|
849
879
|
bool initializeVideo()
|
|
850
880
|
{
|
|
851
881
|
if (videoInitialized_) return true;
|
|
882
|
+
esp_video_init_csi_config_t csiConfig{};
|
|
883
|
+
#if GEA_CUSTOM_TARGET_ACTIVE
|
|
884
|
+
#if !GEA_BOARD_HAS_CAMERA
|
|
885
|
+
return false;
|
|
886
|
+
#else
|
|
887
|
+
#if GEA_BOARD_HAS_EXPANDER
|
|
888
|
+
// A sensor reset routed through the board's I/O expander: pulse it low,
|
|
889
|
+
// then release it before esp_video probes the sensor.
|
|
890
|
+
const int resetLine = gea::platform::board::camera.expanderReset;
|
|
891
|
+
auto &boardControl = gea::platform::esp32::chip_bindings::expanders::ioExpander();
|
|
892
|
+
if (resetLine >= 0 && boardControl.init()) {
|
|
893
|
+
boardControl.writePin(resetLine, false);
|
|
894
|
+
vTaskDelay(pdMS_TO_TICKS(10));
|
|
895
|
+
boardControl.writePin(resetLine, true);
|
|
896
|
+
vTaskDelay(pdMS_TO_TICKS(20));
|
|
897
|
+
}
|
|
898
|
+
#endif
|
|
899
|
+
// SCCB has a bus of its own, so esp_video creates it on the other I2C port.
|
|
900
|
+
csiConfig.sccb_config.init_sccb = true;
|
|
901
|
+
csiConfig.sccb_config.i2c_config.port = I2C_NUM_0;
|
|
902
|
+
csiConfig.sccb_config.i2c_config.sda_pin = gea::platform::board::camera.sccbSda;
|
|
903
|
+
csiConfig.sccb_config.i2c_config.scl_pin = gea::platform::board::camera.sccbScl;
|
|
904
|
+
csiConfig.reset_pin = gea::platform::board::camera.reset;
|
|
905
|
+
#endif
|
|
906
|
+
#else
|
|
907
|
+
// The OV5647 shares the board's primary I2C bus.
|
|
852
908
|
auto bus = gea::platform::i2c::Bus::primary();
|
|
853
909
|
if (!bus.available()) {
|
|
854
910
|
ESP_LOGE(kTag, "I2C bus is not ready for camera SCCB");
|
|
855
911
|
return false;
|
|
856
912
|
}
|
|
857
|
-
esp_video_init_csi_config_t csiConfig{};
|
|
858
913
|
csiConfig.sccb_config.init_sccb = false;
|
|
859
914
|
csiConfig.sccb_config.i2c_handle = static_cast<i2c_master_bus_handle_t>(bus.nativeHandle());
|
|
860
|
-
csiConfig.sccb_config.freq = kSccbFrequencyHz;
|
|
861
915
|
csiConfig.reset_pin = -1;
|
|
916
|
+
#endif
|
|
917
|
+
csiConfig.sccb_config.freq = kSccbFrequencyHz;
|
|
862
918
|
csiConfig.pwdn_pin = -1;
|
|
863
919
|
|
|
864
920
|
esp_video_init_config_t videoConfig{};
|
|
@@ -13,13 +13,20 @@
|
|
|
13
13
|
#include "esp_log.h"
|
|
14
14
|
#include "freertos/FreeRTOS.h"
|
|
15
15
|
#include "freertos/task.h"
|
|
16
|
+
#include "board.h"
|
|
16
17
|
|
|
17
18
|
namespace gea::platform::esp32::apps {
|
|
18
19
|
|
|
19
20
|
namespace {
|
|
20
21
|
|
|
21
22
|
constexpr const char *kTag = "launcher_button";
|
|
23
|
+
// BOOT: GPIO0 on the Waveshare board, the definition's launcher button on a
|
|
24
|
+
// composed one.
|
|
25
|
+
#if GEA_CUSTOM_TARGET_ACTIVE
|
|
26
|
+
constexpr gpio_num_t kGpio = gea::platform::board::launcherButton.pin;
|
|
27
|
+
#else
|
|
22
28
|
constexpr gpio_num_t kGpio = GPIO_NUM_0;
|
|
29
|
+
#endif
|
|
23
30
|
constexpr int kActiveLevel = 0;
|
|
24
31
|
constexpr int kDebounceMs = 50;
|
|
25
32
|
constexpr int kPollMs = 25;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Mounts the
|
|
2
|
-
// maps OSM tile cache). Lazy + idempotent (mounts on first use).
|
|
1
|
+
// Mounts the microSD at /sdcard for the persistent file cache (e.g. the
|
|
2
|
+
// maps OSM tile cache): the Waveshare 4-bit slot, or a composed board's storage.microSD. Lazy + idempotent (mounts on first use).
|
|
3
3
|
//
|
|
4
4
|
// The ESP32-P4 has ONE SDMMC host controller with TWO slots. The onboard ESP32-C6
|
|
5
5
|
// WiFi co-processor (esp_hosted) creates that controller at boot and uses SLOT 1.
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
#include "esp_log.h"
|
|
21
21
|
#include "esp_vfs_fat.h"
|
|
22
22
|
#include "ff.h"
|
|
23
|
+
#include "board.h"
|
|
23
24
|
#include "sd_pwr_ctrl_by_on_chip_ldo.h"
|
|
24
25
|
#include "sdmmc_cmd.h"
|
|
25
26
|
|
|
@@ -36,6 +37,9 @@ bool mountSdCard()
|
|
|
36
37
|
{
|
|
37
38
|
if (g_attempted) return g_mounted;
|
|
38
39
|
g_attempted = true;
|
|
40
|
+
#if GEA_CUSTOM_TARGET_ACTIVE && !GEA_BOARD_HAS_MICROSD
|
|
41
|
+
return false;
|
|
42
|
+
#endif
|
|
39
43
|
|
|
40
44
|
// Reuse an existing mount (e.g. the camera already mounted /sdcard).
|
|
41
45
|
struct stat st {};
|
|
@@ -45,7 +49,24 @@ bool mountSdCard()
|
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
|
48
|
-
host.slot = SDMMC_HOST_SLOT_0; // the SD's slot (
|
|
52
|
+
host.slot = SDMMC_HOST_SLOT_0; // the SD's slot (the hosted WiFi has slot 1)
|
|
53
|
+
sdmmc_slot_config_t slot = SDMMC_SLOT_CONFIG_DEFAULT();
|
|
54
|
+
#if GEA_CUSTOM_TARGET_ACTIVE
|
|
55
|
+
// A composed board's slot (storage.microSD): SD_MMC 1-bit at the 20 MHz
|
|
56
|
+
// default speed over board-length lines, the card on VDD_3V3 rather than an
|
|
57
|
+
// on-chip LDO channel. Only CLK, CMD and D0 come from the definition.
|
|
58
|
+
host.max_freq_khz = SDMMC_FREQ_DEFAULT;
|
|
59
|
+
host.flags = SDMMC_HOST_FLAG_1BIT;
|
|
60
|
+
slot.width = 1;
|
|
61
|
+
slot.clk = gea::platform::board::storage.clk;
|
|
62
|
+
slot.cmd = gea::platform::board::storage.cmd;
|
|
63
|
+
slot.d0 = gea::platform::board::storage.data0;
|
|
64
|
+
slot.d1 = GPIO_NUM_NC;
|
|
65
|
+
slot.d2 = GPIO_NUM_NC;
|
|
66
|
+
slot.d3 = GPIO_NUM_NC;
|
|
67
|
+
slot.cd = SDMMC_SLOT_NO_CD;
|
|
68
|
+
slot.wp = SDMMC_SLOT_NO_WP;
|
|
69
|
+
#else
|
|
49
70
|
host.max_freq_khz = SDMMC_FREQ_HIGHSPEED; // 40 MHz
|
|
50
71
|
// On-chip LDO (chan 4) powers the SD I/O rail; card init drives voltage through it.
|
|
51
72
|
sd_pwr_ctrl_ldo_config_t ldo = {};
|
|
@@ -54,7 +75,6 @@ bool mountSdCard()
|
|
|
54
75
|
host.pwr_ctrl_handle = g_pwr;
|
|
55
76
|
}
|
|
56
77
|
|
|
57
|
-
sdmmc_slot_config_t slot = SDMMC_SLOT_CONFIG_DEFAULT();
|
|
58
78
|
slot.width = 4;
|
|
59
79
|
slot.clk = static_cast<gpio_num_t>(43);
|
|
60
80
|
slot.cmd = static_cast<gpio_num_t>(44);
|
|
@@ -62,10 +82,16 @@ bool mountSdCard()
|
|
|
62
82
|
slot.d1 = static_cast<gpio_num_t>(40);
|
|
63
83
|
slot.d2 = static_cast<gpio_num_t>(41);
|
|
64
84
|
slot.d3 = static_cast<gpio_num_t>(42);
|
|
85
|
+
#endif
|
|
65
86
|
slot.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
|
|
66
87
|
|
|
67
88
|
// Add slot 0 to the EXISTING controller (esp_hosted's). NOT sdmmc_host_init().
|
|
68
89
|
esp_err_t err = sdmmc_host_init_slot(SDMMC_HOST_SLOT_0, &slot);
|
|
90
|
+
if (err == ESP_ERR_INVALID_STATE) {
|
|
91
|
+
// Wi-Fi has not brought the shared controller up (an app with no network
|
|
92
|
+
// use never starts esp_hosted): create it here instead.
|
|
93
|
+
if (sdmmc_host_init() == ESP_OK) err = sdmmc_host_init_slot(SDMMC_HOST_SLOT_0, &slot);
|
|
94
|
+
}
|
|
69
95
|
if (err != ESP_OK) {
|
|
70
96
|
ESP_LOGW(kTag, "init slot 0 failed (%s); file cache disabled", esp_err_to_name(err));
|
|
71
97
|
return false;
|
package/targets.json
CHANGED
|
@@ -177,6 +177,26 @@
|
|
|
177
177
|
"esptoolChip": "esp32p4",
|
|
178
178
|
"ipcTaskStackSize": "4096"
|
|
179
179
|
},
|
|
180
|
+
"esp32-p4": {
|
|
181
|
+
"adapter": "esp32-idf",
|
|
182
|
+
"targetPath": "targets/esp32-p4-waveshare-touch-lcd-7",
|
|
183
|
+
"flashSize": "32MB",
|
|
184
|
+
"appPlatform": "esp32",
|
|
185
|
+
"idfTarget": "esp32p4",
|
|
186
|
+
"esptoolChip": "esp32p4",
|
|
187
|
+
"ipcTaskStackSize": "4096",
|
|
188
|
+
"composable": true
|
|
189
|
+
},
|
|
190
|
+
"esp32-p4-elecrow-crowpanel-advanced-5.0": {
|
|
191
|
+
"adapter": "esp32-idf",
|
|
192
|
+
"targetPath": "targets/esp32-p4-waveshare-touch-lcd-7",
|
|
193
|
+
"definition": "targets/esp32-p4-elecrow-crowpanel-advanced-5.0.json",
|
|
194
|
+
"flashSize": "16MB",
|
|
195
|
+
"appPlatform": "esp32",
|
|
196
|
+
"idfTarget": "esp32p4",
|
|
197
|
+
"esptoolChip": "esp32p4",
|
|
198
|
+
"ipcTaskStackSize": "4096"
|
|
199
|
+
},
|
|
180
200
|
"rp2350-waveshare-touch-amoled-2.41": {
|
|
181
201
|
"adapter": "rp2350-pico",
|
|
182
202
|
"targetPath": "targets/rp2350-waveshare-touch-amoled-2.41",
|