2021-11-06 15:00:11 -04:00
|
|
|
/*
|
|
|
|
* This file is part of the Micro Python project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
2021-11-13 16:36:59 -05:00
|
|
|
* Copyright (c) 2021 Mark Komus
|
2021-11-06 15:00:11 -04:00
|
|
|
*
|
|
|
|
* 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/objproperty.h"
|
|
|
|
#include "py/runtime.h"
|
|
|
|
#include "py/objarray.h"
|
|
|
|
|
2021-11-23 18:21:13 -05:00
|
|
|
#include "shared-bindings/is31fl3741/IS31FL3741.h"
|
2021-11-06 15:00:11 -04:00
|
|
|
#include "shared-bindings/util.h"
|
|
|
|
#include "shared-module/displayio/__init__.h"
|
|
|
|
#include "shared-module/framebufferio/__init__.h"
|
|
|
|
#include "shared-module/framebufferio/FramebufferDisplay.h"
|
|
|
|
#include "shared-bindings/busio/I2C.h"
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
//| class IS31FL3741:
|
2021-11-13 16:36:59 -05:00
|
|
|
//| """Displays an in-memory framebuffer to a IS31FL3741 drive display."""
|
2021-11-06 15:00:11 -04:00
|
|
|
//|
|
|
|
|
|
|
|
|
//| def __init__(self, *, width: int) -> None:
|
2021-11-23 18:06:39 -05:00
|
|
|
//| """Create a IS31FL3741 object with the given attributes.
|
2021-11-06 15:00:11 -04:00
|
|
|
//|
|
2021-11-13 16:36:59 -05:00
|
|
|
//| The framebuffer is in "RGB888" format using 4 bytes per pixel.
|
|
|
|
//| Bits 24-31 are ignored. The format is in RGB order.
|
2021-11-06 15:00:11 -04:00
|
|
|
//|
|
|
|
|
//| If a framebuffer is not passed in, one is allocated and initialized
|
|
|
|
//| to all black. In any case, the framebuffer can be retrieved
|
|
|
|
//| by passing the Is31fl3741 object to memoryview().
|
|
|
|
//|
|
|
|
|
//| A Is31fl3741 is often used in conjunction with a
|
|
|
|
//| `framebufferio.FramebufferDisplay`."""
|
|
|
|
//|
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC mp_obj_t is31fl3741_IS31FL3741_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
2021-11-20 13:42:58 -05:00
|
|
|
enum { ARG_width, ARG_height, ARG_i2c, ARG_addr, ARG_framebuffer, ARG_mapping, ARG_scale, ARG_gamma };
|
2021-11-06 15:00:11 -04:00
|
|
|
static const mp_arg_t allowed_args[] = {
|
|
|
|
{ MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY },
|
|
|
|
{ MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY },
|
|
|
|
{ MP_QSTR_i2c, MP_ARG_OBJ | MP_ARG_REQUIRED | MP_ARG_KW_ONLY },
|
|
|
|
{ MP_QSTR_addr, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0x30 } },
|
|
|
|
{ MP_QSTR_framebuffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } },
|
2021-11-20 13:42:58 -05:00
|
|
|
{ MP_QSTR_mapping, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
|
2021-11-09 23:53:01 -05:00
|
|
|
{ MP_QSTR_scale, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } },
|
2021-11-12 18:10:27 -05:00
|
|
|
{ MP_QSTR_gamma, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } },
|
2021-11-06 15:00:11 -04:00
|
|
|
};
|
|
|
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
|
|
|
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
|
|
|
|
|
|
mp_obj_t i2c = mp_arg_validate_type(args[ARG_i2c].u_obj, &busio_i2c_type, MP_QSTR_i2c_bus);
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
is31fl3741_IS31FL3741_obj_t *self = &allocate_display_bus_or_raise()->is31fl3741;
|
|
|
|
self->base.type = &is31fl3741_IS31FL3741_type;
|
2021-11-06 15:00:11 -04:00
|
|
|
|
|
|
|
if (args[ARG_width].u_int <= 0) {
|
|
|
|
mp_raise_ValueError(translate("width must be greater than zero"));
|
|
|
|
}
|
|
|
|
|
2021-11-09 23:53:01 -05:00
|
|
|
self->scale = args[ARG_scale].u_bool;
|
2021-11-12 18:10:27 -05:00
|
|
|
if (self->scale) {
|
2021-11-20 13:42:58 -05:00
|
|
|
if (((args[ARG_height].u_int % 3) != 0) || ((args[ARG_width].u_int % 3) != 0)) {
|
|
|
|
mp_raise_ValueError(translate("Scale dimensions must divide by 3"));
|
|
|
|
}
|
|
|
|
|
2021-11-12 18:10:27 -05:00
|
|
|
self->scale_width = args[ARG_width].u_int / 3;
|
|
|
|
self->scale_height = args[ARG_height].u_int / 3;
|
2021-11-20 14:41:18 -05:00
|
|
|
} else {
|
|
|
|
self->scale_width = args[ARG_width].u_int;
|
|
|
|
self->scale_height = args[ARG_height].u_int;
|
2021-11-12 18:10:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
self->auto_gamma = args[ARG_gamma].u_bool;
|
2021-11-09 23:53:01 -05:00
|
|
|
|
2021-11-06 15:00:11 -04:00
|
|
|
mp_obj_t framebuffer = args[ARG_framebuffer].u_obj;
|
|
|
|
if (framebuffer == mp_const_none) {
|
|
|
|
int width = args[ARG_width].u_int;
|
|
|
|
int height = args[ARG_height].u_int;
|
|
|
|
int bufsize = 4 * width * height;
|
|
|
|
framebuffer = mp_obj_new_bytearray_of_zeros(bufsize);
|
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
common_hal_is31fl3741_IS31FL3741_construct(self,
|
2021-11-06 15:00:11 -04:00
|
|
|
args[ARG_width].u_int,
|
|
|
|
args[ARG_height].u_int,
|
|
|
|
framebuffer,
|
|
|
|
MP_OBJ_TO_PTR(i2c),
|
2021-11-20 13:42:58 -05:00
|
|
|
args[ARG_addr].u_int,
|
|
|
|
args[ARG_mapping].u_obj
|
2021-11-06 15:00:11 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
return MP_OBJ_FROM_PTR(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
//| def deinit(self) -> None:
|
2021-11-13 16:36:59 -05:00
|
|
|
//| """Free the resources associated with this
|
2021-11-23 18:06:39 -05:00
|
|
|
//| IS31FL3741 instance. After deinitialization, no further operations
|
2021-11-06 15:00:11 -04:00
|
|
|
//| may be performed."""
|
|
|
|
//| ...
|
|
|
|
//|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC mp_obj_t is31fl3741_IS31FL3741_deinit(mp_obj_t self_in) {
|
|
|
|
is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in;
|
|
|
|
common_hal_is31fl3741_IS31FL3741_deinit(self);
|
2021-11-06 15:00:11 -04:00
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_deinit_obj, is31fl3741_IS31FL3741_deinit);
|
2021-11-06 15:00:11 -04:00
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
static void check_for_deinit(is31fl3741_IS31FL3741_obj_t *self) {
|
2021-11-13 16:36:59 -05:00
|
|
|
if (self->framebuffer == NULL) {
|
|
|
|
raise_deinited_error();
|
|
|
|
}
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//| brightness: float
|
|
|
|
//| """In the current implementation, 0.0 turns the display off entirely
|
|
|
|
//| and any other value up to 1.0 turns the display on fully."""
|
|
|
|
//|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC mp_obj_t is31fl3741_IS31FL3741_get_brightness(mp_obj_t self_in) {
|
|
|
|
is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in;
|
2021-11-06 15:00:11 -04:00
|
|
|
check_for_deinit(self);
|
2021-11-23 18:06:39 -05:00
|
|
|
uint8_t current = common_hal_is31fl3741_IS31FL3741_get_global_current(self);
|
2021-11-07 15:13:11 -05:00
|
|
|
|
|
|
|
float brightness = (float)current / (float)0xFF;
|
|
|
|
return mp_obj_new_float(brightness);
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
2021-11-23 18:06:39 -05:00
|
|
|
MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_get_brightness_obj, is31fl3741_IS31FL3741_get_brightness);
|
2021-11-06 15:00:11 -04:00
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC mp_obj_t is31fl3741_IS31FL3741_set_brightness(mp_obj_t self_in, mp_obj_t value_in) {
|
|
|
|
is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in;
|
2021-11-06 15:00:11 -04:00
|
|
|
check_for_deinit(self);
|
|
|
|
mp_float_t brightness = mp_obj_get_float(value_in);
|
|
|
|
if (brightness < 0.0f || brightness > 1.0f) {
|
|
|
|
mp_raise_ValueError(translate("Brightness must be 0-1.0"));
|
|
|
|
}
|
2021-11-07 15:13:11 -05:00
|
|
|
|
|
|
|
uint8_t current = (uint8_t)(brightness * 0xFF);
|
2021-11-23 18:06:39 -05:00
|
|
|
common_hal_is31fl3741_IS31FL3741_set_global_current(self, current);
|
2021-11-06 15:00:11 -04:00
|
|
|
|
|
|
|
return mp_const_none;
|
|
|
|
}
|
2021-11-23 18:06:39 -05:00
|
|
|
MP_DEFINE_CONST_FUN_OBJ_2(is31fl3741_IS31FL3741_set_brightness_obj, is31fl3741_IS31FL3741_set_brightness);
|
2021-11-06 15:00:11 -04:00
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
const mp_obj_property_t is31fl3741_IS31FL3741_brightness_obj = {
|
2021-11-06 15:00:11 -04:00
|
|
|
.base.type = &mp_type_property,
|
2021-11-23 18:06:39 -05:00
|
|
|
.proxy = {(mp_obj_t)&is31fl3741_IS31FL3741_get_brightness_obj,
|
|
|
|
(mp_obj_t)&is31fl3741_IS31FL3741_set_brightness_obj,
|
2021-11-06 15:00:11 -04:00
|
|
|
MP_ROM_NONE},
|
|
|
|
};
|
|
|
|
|
|
|
|
//| def refresh(self) -> None:
|
|
|
|
//| """Transmits the color data in the buffer to the pixels so that
|
|
|
|
//| they are shown."""
|
|
|
|
//| ...
|
|
|
|
//|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC mp_obj_t is31fl3741_IS31FL3741_refresh(mp_obj_t self_in) {
|
|
|
|
is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in;
|
2021-11-06 15:00:11 -04:00
|
|
|
check_for_deinit(self);
|
2021-11-23 18:06:39 -05:00
|
|
|
common_hal_is31fl3741_IS31FL3741_refresh(self, 0);
|
2021-11-06 15:00:11 -04:00
|
|
|
return mp_const_none;
|
|
|
|
}
|
2021-11-23 18:06:39 -05:00
|
|
|
MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_refresh_obj, is31fl3741_IS31FL3741_refresh);
|
2021-11-06 15:00:11 -04:00
|
|
|
|
|
|
|
//| width: int
|
|
|
|
//| """The width of the display, in pixels"""
|
|
|
|
//|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC mp_obj_t is31fl3741_IS31FL3741_get_width(mp_obj_t self_in) {
|
|
|
|
is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in;
|
2021-11-06 15:00:11 -04:00
|
|
|
check_for_deinit(self);
|
2021-11-23 18:06:39 -05:00
|
|
|
return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_IS31FL3741_get_width(self));
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
2021-11-23 18:06:39 -05:00
|
|
|
MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_get_width_obj, is31fl3741_IS31FL3741_get_width);
|
|
|
|
const mp_obj_property_t is31fl3741_IS31FL3741_width_obj = {
|
2021-11-06 15:00:11 -04:00
|
|
|
.base.type = &mp_type_property,
|
2021-11-23 18:06:39 -05:00
|
|
|
.proxy = {(mp_obj_t)&is31fl3741_IS31FL3741_get_width_obj,
|
2021-11-06 15:00:11 -04:00
|
|
|
MP_ROM_NONE,
|
|
|
|
MP_ROM_NONE},
|
|
|
|
};
|
|
|
|
|
|
|
|
//| height: int
|
|
|
|
//| """The height of the display, in pixels"""
|
|
|
|
//|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC mp_obj_t is31fl3741_IS31FL3741_get_height(mp_obj_t self_in) {
|
|
|
|
is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in;
|
2021-11-06 15:00:11 -04:00
|
|
|
check_for_deinit(self);
|
2021-11-23 18:06:39 -05:00
|
|
|
return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_IS31FL3741_get_height(self));
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
2021-11-23 18:06:39 -05:00
|
|
|
MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_get_height_obj, is31fl3741_IS31FL3741_get_height);
|
|
|
|
const mp_obj_property_t is31fl3741_IS31FL3741_height_obj = {
|
2021-11-06 15:00:11 -04:00
|
|
|
.base.type = &mp_type_property,
|
2021-11-23 18:06:39 -05:00
|
|
|
.proxy = {(mp_obj_t)&is31fl3741_IS31FL3741_get_height_obj,
|
2021-11-06 15:00:11 -04:00
|
|
|
MP_ROM_NONE,
|
|
|
|
MP_ROM_NONE},
|
|
|
|
};
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC const mp_rom_map_elem_t is31fl3741_IS31FL3741_locals_dict_table[] = {
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&is31fl3741_IS31FL3741_deinit_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&is31fl3741_IS31FL3741_brightness_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&is31fl3741_IS31FL3741_refresh_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&is31fl3741_IS31FL3741_width_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&is31fl3741_IS31FL3741_height_obj) },
|
2021-11-06 15:00:11 -04:00
|
|
|
};
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC MP_DEFINE_CONST_DICT(is31fl3741_IS31FL3741_locals_dict, is31fl3741_IS31FL3741_locals_dict_table);
|
2021-11-06 15:00:11 -04:00
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC void is31fl3741_IS31FL3741_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t *bufinfo) {
|
|
|
|
is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in;
|
2021-11-06 15:00:11 -04:00
|
|
|
check_for_deinit(self);
|
|
|
|
|
|
|
|
*bufinfo = self->bufinfo;
|
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC void is31fl3741_IS31FL3741_swapbuffers(mp_obj_t self_in, uint8_t *dirty_row_bitmap) {
|
|
|
|
common_hal_is31fl3741_IS31FL3741_refresh(self_in, dirty_row_bitmap);
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC void is31fl3741_IS31FL3741_deinit_proto(mp_obj_t self_in) {
|
|
|
|
common_hal_is31fl3741_IS31FL3741_deinit(self_in);
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC float is31fl3741_IS31FL3741_get_brightness_proto(mp_obj_t self_in) {
|
|
|
|
return common_hal_is31fl3741_IS31FL3741_get_paused(self_in) ? 0.0f : 1.0f;
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC bool is31fl3741_IS31FL3741_set_brightness_proto(mp_obj_t self_in, mp_float_t value) {
|
|
|
|
common_hal_is31fl3741_IS31FL3741_set_paused(self_in, value <= 0);
|
2021-11-06 15:00:11 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC int is31fl3741_IS31FL3741_get_width_proto(mp_obj_t self_in) {
|
|
|
|
return common_hal_is31fl3741_IS31FL3741_get_width(self_in);
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC int is31fl3741_IS31FL3741_get_height_proto(mp_obj_t self_in) {
|
|
|
|
return common_hal_is31fl3741_IS31FL3741_get_height(self_in);
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC int is31fl3741_IS31FL3741_get_color_depth_proto(mp_obj_t self_in) {
|
2021-11-07 15:13:11 -05:00
|
|
|
// The way displayio works depth is used to calculate bytes
|
|
|
|
// We use an uint32_t for color already so setting to 24 causes
|
|
|
|
// more changes required
|
2021-11-06 15:00:11 -04:00
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC int is31fl3741_IS31FL3741_get_bytes_per_cell_proto(mp_obj_t self_in) {
|
2021-11-06 15:00:11 -04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC int is31fl3741_IS31FL3741_get_native_frames_per_second_proto(mp_obj_t self_in) {
|
2021-11-13 16:36:59 -05:00
|
|
|
return 60; // This was just chosen may vary based on LEDs used?
|
2021-11-06 15:00:11 -04:00
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC const framebuffer_p_t is31fl3741_IS31FL3741_proto = {
|
2021-11-06 15:00:11 -04:00
|
|
|
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuffer)
|
2021-11-23 18:06:39 -05:00
|
|
|
.get_bufinfo = is31fl3741_IS31FL3741_get_bufinfo,
|
|
|
|
.set_brightness = is31fl3741_IS31FL3741_set_brightness_proto,
|
|
|
|
.get_brightness = is31fl3741_IS31FL3741_get_brightness_proto,
|
|
|
|
.get_width = is31fl3741_IS31FL3741_get_width_proto,
|
|
|
|
.get_height = is31fl3741_IS31FL3741_get_height_proto,
|
|
|
|
.get_color_depth = is31fl3741_IS31FL3741_get_color_depth_proto,
|
|
|
|
.get_bytes_per_cell = is31fl3741_IS31FL3741_get_bytes_per_cell_proto,
|
|
|
|
.get_native_frames_per_second = is31fl3741_IS31FL3741_get_native_frames_per_second_proto,
|
|
|
|
.swapbuffers = is31fl3741_IS31FL3741_swapbuffers,
|
|
|
|
.deinit = is31fl3741_IS31FL3741_deinit_proto,
|
2021-11-06 15:00:11 -04:00
|
|
|
};
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
STATIC mp_int_t is31fl3741_IS31FL3741_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
|
|
|
|
is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in;
|
2021-11-06 15:00:11 -04:00
|
|
|
// a readonly framebuffer would be unusual but not impossible
|
|
|
|
if ((flags & MP_BUFFER_WRITE) && !(self->bufinfo.typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
*bufinfo = self->bufinfo;
|
|
|
|
bufinfo->typecode = 'H';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-11-23 18:06:39 -05:00
|
|
|
const mp_obj_type_t is31fl3741_IS31FL3741_type = {
|
2021-11-06 15:00:11 -04:00
|
|
|
{ &mp_type_type },
|
|
|
|
.flags = MP_TYPE_FLAG_EXTENDED,
|
|
|
|
.name = MP_QSTR_is31fl3741,
|
2021-11-23 18:06:39 -05:00
|
|
|
.locals_dict = (mp_obj_dict_t *)&is31fl3741_IS31FL3741_locals_dict,
|
|
|
|
.make_new = is31fl3741_IS31FL3741_make_new,
|
2021-11-06 15:00:11 -04:00
|
|
|
MP_TYPE_EXTENDED_FIELDS(
|
2021-11-23 18:06:39 -05:00
|
|
|
.buffer_p = { .get_buffer = is31fl3741_IS31FL3741_get_buffer, },
|
|
|
|
.protocol = &is31fl3741_IS31FL3741_proto,
|
2021-11-06 15:00:11 -04:00
|
|
|
),
|
|
|
|
};
|