Skip to content

Commit 6ba5ba8

Browse files
committed
update to atom 0.6 and esp-idf 5+ support
1 parent fcfc7d0 commit 6ba5ba8

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ idf_component_register(
2929
)
3030

3131
idf_build_set_property(
32-
LINK_OPTIONS "-Wl,--whole-archive ${CMAKE_CURRENT_BINARY_DIR}/lib${COMPONENT_NAME}.a -Wl,--no-whole-archive"
32+
LINK_OPTIONS "-Wl,--whole-archive;${CMAKE_CURRENT_BINARY_DIR}/lib${COMPONENT_NAME}.a;-Wl,--no-whole-archive"
3333
APPEND
3434
)

nifs/atomvm_esp32cam.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,19 @@ static framesize_t get_frame_size(Context *ctx, term frame_size)
7777
{
7878
if (term_is_nil(frame_size)) {
7979
return FRAMESIZE_XGA;
80-
} else if (frame_size == context_make_atom(ctx, qvga_a)) {
80+
} else if (frame_size == globalcontext_make_atom(ctx->global, qvga_a)) {
8181
return FRAMESIZE_QVGA;
82-
} else if (frame_size == context_make_atom(ctx, cif_a)) {
82+
} else if (frame_size == globalcontext_make_atom(ctx->global, cif_a)) {
8383
return FRAMESIZE_CIF;
84-
} else if (frame_size == context_make_atom(ctx, vga_a)) {
84+
} else if (frame_size == globalcontext_make_atom(ctx->global, vga_a)) {
8585
return FRAMESIZE_VGA;
86-
} else if (frame_size == context_make_atom(ctx, svga_a)) {
86+
} else if (frame_size == globalcontext_make_atom(ctx->global, svga_a)) {
8787
return FRAMESIZE_SVGA;
88-
} else if (frame_size == context_make_atom(ctx, xga_a)) {
88+
} else if (frame_size == globalcontext_make_atom(ctx->global, xga_a)) {
8989
return FRAMESIZE_XGA;
90-
} else if (frame_size == context_make_atom(ctx, sxga_a)) {
90+
} else if (frame_size == globalcontext_make_atom(ctx->global, sxga_a)) {
9191
return FRAMESIZE_SXGA;
92-
} else if (frame_size == context_make_atom(ctx, uxga_a)) {
92+
} else if (frame_size == globalcontext_make_atom(ctx->global, uxga_a)) {
9393
return FRAMESIZE_UXGA;
9494
} else {
9595
return FRAMESIZE_INVALID;
@@ -123,8 +123,8 @@ static camera_config_t *create_camera_config(framesize_t frame_size, int jpeg_qu
123123
config->pin_pwdn = AI_THINKER_CAM_PIN_PWDN;
124124
config->pin_reset = AI_THINKER_CAM_PIN_RESET;
125125
config->pin_xclk = AI_THINKER_CAM_PIN_XCLK;
126-
config->pin_sscb_sda = AI_THINKER_CAM_PIN_SIOD;
127-
config->pin_sscb_scl = AI_THINKER_CAM_PIN_SIOC;
126+
config->pin_sccb_sda = AI_THINKER_CAM_PIN_SIOD;
127+
config->pin_sccb_scl = AI_THINKER_CAM_PIN_SIOC;
128128
config->pin_d7 = AI_THINKER_CAM_PIN_D7;
129129
config->pin_d6 = AI_THINKER_CAM_PIN_D6;
130130
config->pin_d5 = AI_THINKER_CAM_PIN_D5;
@@ -158,13 +158,13 @@ static term nif_esp32cam_init(Context *ctx, int argc, term argv[])
158158
config = argv[0];
159159
}
160160

161-
framesize_t frame_size = get_frame_size(ctx, interop_proplist_get_value(config, context_make_atom(ctx, frame_size_a)));
161+
framesize_t frame_size = get_frame_size(ctx, interop_proplist_get_value(config, globalcontext_make_atom(ctx->global, frame_size_a)));
162162
if (frame_size == FRAMESIZE_INVALID) {
163163
ESP_LOGE(TAG, "Invalid frame_size=%i", frame_size);
164164
RAISE_ERROR(BADARG_ATOM);
165165
}
166166
TRACE("frame_size: %i\n", frame_size);
167-
int jpeg_quality = get_jpeg_quality(interop_proplist_get_value(config, context_make_atom(ctx, jpeg_quality_a)));
167+
int jpeg_quality = get_jpeg_quality(interop_proplist_get_value(config, globalcontext_make_atom(ctx->global, jpeg_quality_a)));
168168
if (jpeg_quality == INVALID_JPEG_QUALITY) {
169169
ESP_LOGE(TAG, "Invalid jpeg_quality=%i", jpeg_quality);
170170
RAISE_ERROR(BADARG_ATOM);
@@ -203,7 +203,7 @@ static term nif_esp32cam_capture(Context *ctx, int argc, term argv[])
203203

204204
if (!camera_initialized) {
205205
ESP_LOGE(TAG, "Camera not initialized! Bad state.");
206-
RAISE_ERROR(context_make_atom(ctx, bad_state_a));
206+
RAISE_ERROR(globalcontext_make_atom(ctx->global, bad_state_a));
207207
}
208208

209209
uint8_t use_flash = 0;
@@ -214,7 +214,7 @@ static term nif_esp32cam_capture(Context *ctx, int argc, term argv[])
214214
if (UNLIKELY(memory_ensure_free(ctx, 3) != MEMORY_GC_OK)) {
215215
RAISE_ERROR(MEMORY_ATOM);
216216
}
217-
term error = port_create_error_tuple(ctx, context_make_atom(ctx, capture_failed_a));
217+
term error = port_create_error_tuple(ctx, globalcontext_make_atom(ctx->global, capture_failed_a));
218218
return error;
219219
}
220220

@@ -223,7 +223,7 @@ static term nif_esp32cam_capture(Context *ctx, int argc, term argv[])
223223
ESP_LOGE(TAG, "Image memory allocation (%i) failed", fb->len);
224224
RAISE_ERROR(MEMORY_ATOM);
225225
}
226-
term image = term_from_literal_binary((const char *)fb->buf, fb->len, ctx);
226+
term image = term_from_literal_binary((const char *)fb->buf, fb->len, &ctx->heap, ctx->global);
227227
esp_camera_fb_return(fb);
228228

229229
return port_create_tuple2(ctx, OK_ATOM, image);
@@ -271,5 +271,5 @@ const struct Nif *atomvm_esp32cam_get_nif(const char *nifname)
271271

272272
#include <sdkconfig.h>
273273
#ifdef CONFIG_AVM_ESP32CAM_ENABLE
274-
REGISTER_NIF_COLLECTION(atomvm_esp32cam, atomvm_esp32cam_init, atomvm_esp32cam_get_nif)
274+
REGISTER_NIF_COLLECTION(atomvm_esp32cam, atomvm_esp32cam_init, NULL, atomvm_esp32cam_get_nif)
275275
#endif

0 commit comments

Comments
 (0)