|
25 | 25 | */
|
26 | 26 |
|
27 | 27 | #include "py/obj.h"
|
| 28 | +#include "py/objproperty.h" |
28 | 29 | #include "py/runtime.h"
|
29 | 30 |
|
30 | 31 | #include "shared/runtime/context_manager_helpers.h"
|
@@ -82,20 +83,62 @@ STATIC mp_obj_t imagecapture_parallelimagecapture_make_new(const mp_obj_type_t *
|
82 | 83 | return self;
|
83 | 84 | }
|
84 | 85 |
|
85 |
| -//| def capture(self, buffer: WriteableBuffer, width: int, height: int, bpp: int=16) -> None: |
86 |
| -//| """Capture a single frame into the given buffer""" |
| 86 | +//| def capture(self, buffer: WriteableBuffer) -> WriteableBuffer: |
| 87 | +//| """Capture a single frame into the given buffer. |
| 88 | +//| |
| 89 | +//| This will stop a continuous-mode capture, if one is in progress.""" |
87 | 90 | //| ...
|
88 | 91 | //|
|
89 | 92 | STATIC mp_obj_t imagecapture_parallelimagecapture_capture(mp_obj_t self_in, mp_obj_t buffer) {
|
90 | 93 | imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in;
|
91 |
| - mp_buffer_info_t bufinfo; |
92 |
| - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_RW); |
93 |
| - common_hal_imagecapture_parallelimagecapture_capture(self, bufinfo.buf, bufinfo.len); |
| 94 | + common_hal_imagecapture_parallelimagecapture_singleshot_capture(self, buffer); |
94 | 95 |
|
95 |
| - return mp_const_none; |
| 96 | + return buffer; |
96 | 97 | }
|
97 | 98 | STATIC MP_DEFINE_CONST_FUN_OBJ_2(imagecapture_parallelimagecapture_capture_obj, imagecapture_parallelimagecapture_capture);
|
98 | 99 |
|
| 100 | +//| def continuous_capture_start(self, buffer1: WriteableBuffer, buffer2: WriteableBuffer) -> None: |
| 101 | +//| """Begin capturing into the given buffers in the background. |
| 102 | +//| |
| 103 | +//| Call `continuous_capture_get_frame` to get the next available |
| 104 | +//| frame, and `continuous_capture_stop` to stop capturing.""" |
| 105 | +//| ... |
| 106 | +//| |
| 107 | +STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_start(mp_obj_t self_in, mp_obj_t buffer1, mp_obj_t buffer2) { |
| 108 | + imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; |
| 109 | + common_hal_imagecapture_parallelimagecapture_continuous_capture_start(self, buffer1, buffer2); |
| 110 | + |
| 111 | + return mp_const_none; |
| 112 | +} |
| 113 | +STATIC MP_DEFINE_CONST_FUN_OBJ_3(imagecapture_parallelimagecapture_continuous_capture_start_obj, imagecapture_parallelimagecapture_continuous_capture_start); |
| 114 | + |
| 115 | +//| def continuous_capture_get_frame(self) -> WritableBuffer: |
| 116 | +//| """Return the next available frame, one of the two buffers passed to `continuous_capture_start`""" |
| 117 | +//| ... |
| 118 | +//| |
| 119 | +STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_get_frame(mp_obj_t self_in) { |
| 120 | + imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; |
| 121 | + return common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(self); |
| 122 | +} |
| 123 | +STATIC MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_continuous_capture_get_frame_obj, imagecapture_parallelimagecapture_continuous_capture_get_frame); |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | +//| def continuous_capture_stop(self) -> None: |
| 128 | +//| """Stop continuous capture""" |
| 129 | +//| ... |
| 130 | +//| |
| 131 | +STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_stop(mp_obj_t self_in) { |
| 132 | + imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; |
| 133 | + common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(self); |
| 134 | + |
| 135 | + return mp_const_none; |
| 136 | +} |
| 137 | +STATIC MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_continuous_capture_stop_obj, imagecapture_parallelimagecapture_continuous_capture_stop); |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
99 | 142 | //| def deinit(self) -> None:
|
100 | 143 | //| """Deinitialize this instance"""
|
101 | 144 | //| ...
|
@@ -134,6 +177,9 @@ STATIC const mp_rom_map_elem_t imagecapture_parallelimagecapture_locals_dict_tab
|
134 | 177 | { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&imagecapture_parallelimagecapture___exit___obj) },
|
135 | 178 |
|
136 | 179 | { MP_ROM_QSTR(MP_QSTR_capture), MP_ROM_PTR(&imagecapture_parallelimagecapture_capture_obj) },
|
| 180 | + { MP_ROM_QSTR(MP_QSTR_continuous_capture_start), MP_ROM_PTR(&imagecapture_parallelimagecapture_continuous_capture_start_obj) }, |
| 181 | + { MP_ROM_QSTR(MP_QSTR_continuous_capture_stop), MP_ROM_PTR(&imagecapture_parallelimagecapture_continuous_capture_stop_obj) }, |
| 182 | + { MP_ROM_QSTR(MP_QSTR_continuous_capture_get_frame), MP_ROM_PTR(&imagecapture_parallelimagecapture_continuous_capture_get_frame_obj) }, |
137 | 183 | };
|
138 | 184 |
|
139 | 185 | STATIC MP_DEFINE_CONST_DICT(imagecapture_parallelimagecapture_locals_dict, imagecapture_parallelimagecapture_locals_dict_table);
|
|
0 commit comments