camera: Implement new library for camera

This commit is contained in:
Kamil Tomaszewski 2020-09-02 15:42:57 +02:00
parent 814339abb9
commit 064c597b60
8 changed files with 512 additions and 0 deletions

View File

@ -139,6 +139,9 @@ endif
ifeq ($(CIRCUITPY_BUSIO),1)
SRC_PATTERNS += busio/% bitbangio/OneWire.%
endif
ifeq ($(CIRCUITPY_CAMERA),1)
SRC_PATTERNS += camera/%
endif
ifeq ($(CIRCUITPY_COUNTIO),1)
SRC_PATTERNS += countio/%
endif
@ -310,6 +313,9 @@ SRC_COMMON_HAL_ALL = \
busio/SPI.c \
busio/UART.c \
busio/__init__.c \
camera/__init__.c \
camera/Camera.c \
camera/ImageSize.c \
countio/Counter.c \
countio/__init__.c \
digitalio/DigitalInOut.c \

View File

@ -329,6 +329,13 @@ extern const struct _mp_obj_module_t busio_module;
#define BUSIO_MODULE
#endif
#if CIRCUITPY_CAMERA
extern const struct _mp_obj_module_t camera_module;
#define CAMERA_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_camera), (mp_obj_t)&camera_module },
#else
#define CAMERA_MODULE
#endif
#if CIRCUITPY_COUNTIO
extern const struct _mp_obj_module_t countio_module;
#define COUNTIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_countio), (mp_obj_t)&countio_module },
@ -758,6 +765,7 @@ extern const struct _mp_obj_module_t wifi_module;
BLEIO_MODULE \
BOARD_MODULE \
BUSIO_MODULE \
CAMERA_MODULE \
COUNTIO_MODULE \
DIGITALIO_MODULE \
DISPLAYIO_MODULE \

View File

@ -90,6 +90,9 @@ CFLAGS += -DCIRCUITPY_BOARD=$(CIRCUITPY_BOARD)
CIRCUITPY_BUSIO ?= 1
CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO)
CIRCUITPY_CAMERA ?= 0
CFLAGS += -DCIRCUITPY_CAMERA=$(CIRCUITPY_CAMERA)
CIRCUITPY_DIGITALIO ?= 1
CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO)

View File

@ -0,0 +1,178 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright 2020 Sony Semiconductor Solutions Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/camera/Camera.h"
#include "shared-bindings/util.h"
//| class Camera:
//| """The class to control camera.
//|
//| Usage::
//|
//| import board
//| import sdioio
//| import storage
//| import camera
//|
//| sd = sdioio.SDCard(
//| clock=board.SDIO_CLOCK,
//| command=board.SDIO_COMMAND,
//| data=board.SDIO_DATA,
//| frequency=25000000)
//| vfs = storage.VfsFat(sd)
//| storage.mount(vfs, '/sd')
//|
//| cam = camera.Camera(camera.ImageSize.IMAGE_SIZE_1920x1080)
//|
//| file = open("/sd/image.jpg","wb")
//| cam.take_picture()
//| file.write(cam.picture)
//| file.close()"""
//|
//| def __init__(self, ):
//| """Initialize camera.
//|
//| :param camera.ImageSize size: image size"""
//| ...
//|
STATIC mp_obj_t camera_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
camera_obj_t *self = m_new_obj(camera_obj_t);
self->base.type = &camera_type;
enum { ARG_size };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_OBJ },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
camera_imagesize_t size = camera_imagesize_obj_to_type(args[ARG_size].u_obj);
common_hal_camera_construct(self, size);
return MP_OBJ_FROM_PTR(self);
}
//| def deinit(self, ) -> Any:
//| """De-initialize camera."""
//| ...
//|
STATIC mp_obj_t camera_obj_deinit(mp_obj_t self_in) {
camera_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_camera_deinit(self);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(camera_deinit_obj, camera_obj_deinit);
STATIC void check_for_deinit(camera_obj_t *self) {
if (common_hal_camera_deinited(self)) {
raise_deinited_error();
}
}
//| def take_picture(self, ) -> Any:
//| """Take picture."""
//| ...
//|
STATIC mp_obj_t camera_obj_take_picture(mp_obj_t self_in) {
camera_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
common_hal_camera_take_picture(self);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(camera_take_picture_obj, camera_obj_take_picture);
//| picture: Any = ...
//| """Image buffer."""
//|
STATIC mp_obj_t camera_obj_get_picture(mp_obj_t self_in) {
camera_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
uint8_t *buffer = common_hal_camera_get_picture_buffer(self);
size_t size = common_hal_camera_get_picture_size(self);
return mp_obj_new_bytearray_by_ref(size, buffer);
}
MP_DEFINE_CONST_FUN_OBJ_1(camera_get_picture_obj, camera_obj_get_picture);
const mp_obj_property_t camera_picture_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&camera_get_picture_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj},
};
//| size: Any = ...
//| """Image size."""
//|
STATIC mp_obj_t camera_obj_get_size(mp_obj_t self_in) {
camera_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return camera_imagesize_type_to_obj(common_hal_camera_get_size(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(camera_get_size_obj, camera_obj_get_size);
STATIC mp_obj_t camera_obj_set_size(mp_obj_t self_in, mp_obj_t value) {
camera_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
camera_imagesize_t size = camera_imagesize_obj_to_type(value);
if (size == IMAGESIZE_NONE) {
mp_raise_ValueError(translate("Invalid image size."));
}
common_hal_camera_set_size(self, size);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(camera_set_size_obj, camera_obj_set_size);
const mp_obj_property_t camera_size_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&camera_get_size_obj,
(mp_obj_t)&camera_set_size_obj,
(mp_obj_t)&mp_const_none_obj},
};
STATIC const mp_rom_map_elem_t camera_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&camera_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_take_picture), MP_ROM_PTR(&camera_take_picture_obj) },
{ MP_ROM_QSTR(MP_QSTR_picture), MP_ROM_PTR(&camera_picture_obj) },
{ MP_ROM_QSTR(MP_QSTR_size), MP_ROM_PTR(&camera_size_obj) },
};
STATIC MP_DEFINE_CONST_DICT(camera_locals_dict, camera_locals_dict_table);
const mp_obj_type_t camera_type = {
{ &mp_type_type },
.name = MP_QSTR_GNSS,
.make_new = camera_make_new,
.locals_dict = (mp_obj_dict_t*)&camera_locals_dict,
};

View File

@ -0,0 +1,45 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright 2020 Sony Semiconductor Solutions Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_CAMERA_CAMERA_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_CAMERA_CAMERA_H
#include "common-hal/camera/Camera.h"
#include "shared-bindings/camera/ImageSize.h"
extern const mp_obj_type_t camera_type;
void common_hal_camera_construct(camera_obj_t *self, camera_imagesize_t size);
void common_hal_camera_deinit(camera_obj_t *self);
bool common_hal_camera_deinited(camera_obj_t *self);
void common_hal_camera_take_picture(camera_obj_t *self);
uint8_t* common_hal_camera_get_picture_buffer(camera_obj_t *self);
size_t common_hal_camera_get_picture_size(camera_obj_t *self);
camera_imagesize_t common_hal_camera_get_size(camera_obj_t *self);
void common_hal_camera_set_size(camera_obj_t *self, camera_imagesize_t size);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_CAMERA_CAMERA_H

View File

@ -0,0 +1,163 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright 2020 Sony Semiconductor Solutions Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "shared-bindings/camera/ImageSize.h"
//| class ImageSize:
//| """Image size"""
//|
//| def __init__(self) -> None:
//| """Enum-like class to define the image size."""
//|
//| IMAGE_SIZE_320x240: ImageSize
//| """Image size 320x240."""
//|
//| IMAGE_SIZE_640x480: ImageSize
//| """Image size 640x480."""
//|
//| IMAGE_SIZE_1280x720: ImageSize
//| """Image size 1280x720."""
//|
//| IMAGE_SIZE_1280x960: ImageSize
//| """Image size 1280x960."""
//|
//| IMAGE_SIZE_1920x1080: ImageSize
//| """Image size 1920x1080."""
//|
//| IMAGE_SIZE_2048x1536: ImageSize
//| """Image size 2048x1536."""
//|
//| IMAGE_SIZE_2560x1920: ImageSize
//| """Image size 2560x1920."""
//|
const mp_obj_type_t camera_imagesize_type;
const camera_imagesize_obj_t camera_imagesize_320x240_obj = {
{ &camera_imagesize_type },
};
const camera_imagesize_obj_t camera_imagesize_640x320_obj = {
{ &camera_imagesize_type },
};
const camera_imagesize_obj_t camera_imagesize_1280x720_obj = {
{ &camera_imagesize_type },
};
const camera_imagesize_obj_t camera_imagesize_1280x960_obj = {
{ &camera_imagesize_type },
};
const camera_imagesize_obj_t camera_imagesize_1920x1080_obj = {
{ &camera_imagesize_type },
};
const camera_imagesize_obj_t camera_imagesize_2048x1536_obj = {
{ &camera_imagesize_type },
};
const camera_imagesize_obj_t camera_imagesize_2560x1920_obj = {
{ &camera_imagesize_type },
};
camera_imagesize_t camera_imagesize_obj_to_type(mp_obj_t obj) {
if (obj == MP_ROM_PTR(&camera_imagesize_320x240_obj)) {
return IMAGESIZE_320x240;
} else if (obj == MP_ROM_PTR(&camera_imagesize_640x320_obj)) {
return IMAGESIZE_640x320;
} else if (obj == MP_ROM_PTR(&camera_imagesize_1280x720_obj)) {
return IMAGESIZE_1280x720;
} else if (obj == MP_ROM_PTR(&camera_imagesize_1280x960_obj)) {
return IMAGESIZE_1280x960;
} else if (obj == MP_ROM_PTR(&camera_imagesize_1920x1080_obj)) {
return IMAGESIZE_1920x1080;
} else if (obj == MP_ROM_PTR(&camera_imagesize_2048x1536_obj)) {
return IMAGESIZE_2048x1536;
} else if (obj == MP_ROM_PTR(&camera_imagesize_2560x1920_obj)) {
return IMAGESIZE_2560x1920;
}
return IMAGESIZE_NONE;
}
mp_obj_t camera_imagesize_type_to_obj(camera_imagesize_t size) {
switch (size) {
case IMAGESIZE_320x240:
return (mp_obj_t)MP_ROM_PTR(&camera_imagesize_320x240_obj);
case IMAGESIZE_640x320:
return (mp_obj_t)MP_ROM_PTR(&camera_imagesize_640x320_obj);
case IMAGESIZE_1280x720:
return (mp_obj_t)MP_ROM_PTR(&camera_imagesize_1280x720_obj);
case IMAGESIZE_1280x960:
return (mp_obj_t)MP_ROM_PTR(&camera_imagesize_1280x960_obj);
case IMAGESIZE_1920x1080:
return (mp_obj_t)MP_ROM_PTR(&camera_imagesize_1920x1080_obj);
case IMAGESIZE_2048x1536:
return (mp_obj_t)MP_ROM_PTR(&camera_imagesize_2048x1536_obj);
case IMAGESIZE_2560x1920:
return (mp_obj_t)MP_ROM_PTR(&camera_imagesize_2560x1920_obj);
case IMAGESIZE_NONE:
default:
return (mp_obj_t)MP_ROM_PTR(&mp_const_none_obj);
}
}
STATIC const mp_rom_map_elem_t camera_imagesize_locals_dict_table[] = {
{MP_ROM_QSTR(MP_QSTR_IMAGE_SIZE_320x240), MP_ROM_PTR(&camera_imagesize_320x240_obj)},
{MP_ROM_QSTR(MP_QSTR_IMAGE_SIZE_640x320), MP_ROM_PTR(&camera_imagesize_640x320_obj)},
{MP_ROM_QSTR(MP_QSTR_IMAGE_SIZE_1280x720), MP_ROM_PTR(&camera_imagesize_1280x720_obj)},
{MP_ROM_QSTR(MP_QSTR_IMAGE_SIZE_1280x960), MP_ROM_PTR(&camera_imagesize_1280x960_obj)},
{MP_ROM_QSTR(MP_QSTR_IMAGE_SIZE_1920x1080), MP_ROM_PTR(&camera_imagesize_1920x1080_obj)},
{MP_ROM_QSTR(MP_QSTR_IMAGE_SIZE_2048x1536), MP_ROM_PTR(&camera_imagesize_2048x1536_obj)},
{MP_ROM_QSTR(MP_QSTR_IMAGE_SIZE_2560x1920), MP_ROM_PTR(&camera_imagesize_2560x1920_obj)},
};
STATIC MP_DEFINE_CONST_DICT(camera_imagesize_locals_dict, camera_imagesize_locals_dict_table);
STATIC void camera_imagesize_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
qstr size = MP_QSTR_None;
if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&camera_imagesize_320x240_obj)) {
size = MP_QSTR_IMAGE_SIZE_320x240;
} else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&camera_imagesize_640x320_obj)) {
size = MP_QSTR_IMAGE_SIZE_640x320;
} else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&camera_imagesize_1280x720_obj)) {
size = MP_QSTR_IMAGE_SIZE_1280x720;
} else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&camera_imagesize_1280x960_obj)) {
size = MP_QSTR_IMAGE_SIZE_1280x960;
} else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&camera_imagesize_1920x1080_obj)) {
size = MP_QSTR_IMAGE_SIZE_1920x1080;
} else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&camera_imagesize_2048x1536_obj)) {
size = MP_QSTR_IMAGE_SIZE_2048x1536;
} else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&camera_imagesize_2560x1920_obj)) {
size = MP_QSTR_IMAGE_SIZE_2560x1920;
}
mp_printf(print, "%q.%q.%q", MP_QSTR_camera, MP_QSTR_ImageSize, size);
}
const mp_obj_type_t camera_imagesize_type = {
{ &mp_type_type },
.name = MP_QSTR_ImageSize,
.print = camera_imagesize_print,
.locals_dict = (mp_obj_t)&camera_imagesize_locals_dict,
};

View File

@ -0,0 +1,59 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright 2020 Sony Semiconductor Solutions Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_CAMERA_IMAGESIZE_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_CAMERA_IMAGESIZE_H
#include "py/obj.h"
typedef enum {
IMAGESIZE_NONE,
IMAGESIZE_320x240,
IMAGESIZE_640x320,
IMAGESIZE_1280x720,
IMAGESIZE_1280x960,
IMAGESIZE_1920x1080,
IMAGESIZE_2048x1536,
IMAGESIZE_2560x1920,
} camera_imagesize_t;
const mp_obj_type_t camera_imagesize_type;
camera_imagesize_t camera_imagesize_obj_to_type(mp_obj_t obj);
mp_obj_t camera_imagesize_type_to_obj(camera_imagesize_t mode);
typedef struct {
mp_obj_base_t base;
} camera_imagesize_obj_t;
extern const camera_imagesize_obj_t camera_imagesize_320x240_obj;
extern const camera_imagesize_obj_t camera_imagesize_640x320_obj;
extern const camera_imagesize_obj_t camera_imagesize_1280x720_obj;
extern const camera_imagesize_obj_t camera_imagesize_1280x960_obj;
extern const camera_imagesize_obj_t camera_imagesize_1920x1080_obj;
extern const camera_imagesize_obj_t camera_imagesize_2048x1536_obj;
extern const camera_imagesize_obj_t camera_imagesize_2560x1920_obj;
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_CAMERA_IMAGESIZE_H

View File

@ -0,0 +1,50 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright 2020 Sony Semiconductor Solutions Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "py/obj.h"
#include "py/runtime.h"
#include "py/mphal.h"
#include "shared-bindings/camera/Camera.h"
#include "shared-bindings/util.h"
//| """Support for camera input
//|
//| The `camera` module contains classes to control the camera and take pictures."""
//|
STATIC const mp_rom_map_elem_t camera_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_camera) },
{ MP_ROM_QSTR(MP_QSTR_Camera), MP_ROM_PTR(&camera_type) },
// Enum-like Classes.
{ MP_ROM_QSTR(MP_QSTR_ImageSize), MP_ROM_PTR(&camera_imagesize_type) },
};
STATIC MP_DEFINE_CONST_DICT(camera_module_globals, camera_module_globals_table);
const mp_obj_module_t camera_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&camera_module_globals,
};