|
18 | 18 | #include "shared-bindings/displayio/Bitmap.h"
|
19 | 19 | #include "shared-bindings/microcontroller/Pin.h"
|
20 | 20 | #include "shared-bindings/util.h"
|
| 21 | +#include "shared/runtime/context_manager_helpers.h" |
21 | 22 | #include "esp_camera.h"
|
22 | 23 | #include "sensor.h"
|
23 | 24 |
|
@@ -169,11 +170,7 @@ static void check_for_deinit(espcamera_camera_obj_t *self) {
|
169 | 170 | //| :ref:`lifetime-and-contextmanagers` for more info."""
|
170 | 171 | //| ...
|
171 | 172 | //|
|
172 |
| -static mp_obj_t espcamera_camera_obj___exit__(size_t n_args, const mp_obj_t *args) { |
173 |
| - (void)n_args; |
174 |
| - return espcamera_camera_deinit(args[0]); |
175 |
| -} |
176 |
| -static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espcamera_camera___exit___obj, 4, 4, espcamera_camera_obj___exit__); |
| 173 | +// Provided by context manager helper. |
177 | 174 |
|
178 | 175 | //| frame_available: bool
|
179 | 176 | //| """True if a frame is available, False otherwise"""
|
@@ -947,8 +944,8 @@ static const mp_rom_map_elem_t espcamera_camera_locals_table[] = {
|
947 | 944 | { MP_ROM_QSTR(MP_QSTR_denoise), MP_ROM_PTR(&espcamera_camera_denoise_obj) },
|
948 | 945 | { MP_ROM_QSTR(MP_QSTR_framebuffer_count), MP_ROM_PTR(&espcamera_camera_framebuffer_count_obj) },
|
949 | 946 | { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&espcamera_camera_deinit_obj) },
|
950 |
| - { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) }, |
951 |
| - { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&espcamera_camera___exit___obj) }, |
| 947 | + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, |
| 948 | + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) }, |
952 | 949 | { MP_ROM_QSTR(MP_QSTR_exposure_ctrl), MP_ROM_PTR(&espcamera_camera_exposure_ctrl_obj) },
|
953 | 950 | { MP_ROM_QSTR(MP_QSTR_frame_available), MP_ROM_PTR(&espcamera_camera_frame_available_obj) },
|
954 | 951 | { MP_ROM_QSTR(MP_QSTR_frame_size), MP_ROM_PTR(&espcamera_camera_frame_size_obj) },
|
|
0 commit comments