Merge branch 'adafruit:main' into pycubed_v05c

This commit is contained in:
Max Holliday 2021-09-11 20:09:59 -06:00 committed by GitHub
commit d9ae2c00b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 52 additions and 24 deletions

3
.gitmodules vendored
View File

@ -191,3 +191,6 @@
[submodule "lib/quirc"] [submodule "lib/quirc"]
path = lib/quirc path = lib/quirc
url = https://github.com/adafruit/quirc.git url = https://github.com/adafruit/quirc.git
[submodule "frozen/Adafruit_CircuitPython_APDS9960"]
path = frozen/Adafruit_CircuitPython_APDS9960
url = https://github.com/adafruit/Adafruit_CircuitPython_APDS9960

@ -0,0 +1 @@
Subproject commit ee411d34dfa2fb70a35aa99945eca77f16456619

View File

@ -19,7 +19,6 @@ CIRCUITPY_PULSEIO = 0
CIRCUITPY_PWMIO = 0 CIRCUITPY_PWMIO = 0
CIRCUITPY_ROTARYIO = 0 CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0 CIRCUITPY_RTC = 0
CIRCUITPY_USB_MIDI = 0
CIRCUITPY_GETPASS = 0 CIRCUITPY_GETPASS = 0
CIRCUITPY_TRACEBACK = 0 CIRCUITPY_TRACEBACK = 0
@ -28,5 +27,5 @@ CIRCUITPY_PIXELBUF = 1
CIRCUITPY_BUSDEVICE = 1 CIRCUITPY_BUSDEVICE = 1
# Include these Python libraries in firmware. # Include these Python libraries in firmware.
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_APDS9960
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel

View File

@ -42,8 +42,8 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg
// VectorShape parts // VectorShape parts
mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj; mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj;
int16_t x = args[ARG_x].u_int; int32_t x = args[ARG_x].u_int;
int16_t y = args[ARG_y].u_int; int32_t y = args[ARG_y].u_int;
mp_obj_t vector_shape = vectorio_vector_shape_make_new(self, pixel_shader, x, y); mp_obj_t vector_shape = vectorio_vector_shape_make_new(self, pixel_shader, x, y);
self->draw_protocol_instance = vector_shape; self->draw_protocol_instance = vector_shape;

View File

@ -47,8 +47,8 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar
// VectorShape parts // VectorShape parts
mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj; mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj;
int16_t x = args[ARG_x].u_int; int32_t x = args[ARG_x].u_int;
int16_t y = args[ARG_y].u_int; int32_t y = args[ARG_y].u_int;
mp_obj_t vector_shape = vectorio_vector_shape_make_new(self, pixel_shader, x, y); mp_obj_t vector_shape = vectorio_vector_shape_make_new(self, pixel_shader, x, y);
self->draw_protocol_instance = vector_shape; self->draw_protocol_instance = vector_shape;

View File

@ -46,8 +46,8 @@ static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_
// VectorShape parts // VectorShape parts
mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj; mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj;
int16_t x = args[ARG_x].u_int; int32_t x = args[ARG_x].u_int;
int16_t y = args[ARG_y].u_int; int32_t y = args[ARG_y].u_int;
mp_obj_t vector_shape = vectorio_vector_shape_make_new(self, pixel_shader, x, y); mp_obj_t vector_shape = vectorio_vector_shape_make_new(self, pixel_shader, x, y);
self->draw_protocol_instance = vector_shape; self->draw_protocol_instance = vector_shape;

View File

@ -23,7 +23,7 @@
// pixel_shader: The pixel shader that produces colors from values. The shader can be a displayio.Palette(1); it will be asked to color pixel value 0. // pixel_shader: The pixel shader that produces colors from values. The shader can be a displayio.Palette(1); it will be asked to color pixel value 0.
// x: Initial x position of the center axis of the shape within the parent. // x: Initial x position of the center axis of the shape within the parent.
// y: Initial y position of the center axis of the shape within the parent.""" // y: Initial y position of the center axis of the shape within the parent."""
mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pixel_shader, int16_t x, int16_t y) { mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pixel_shader, int32_t x, int32_t y) {
if (!mp_obj_is_type(pixel_shader, &displayio_colorconverter_type) && if (!mp_obj_is_type(pixel_shader, &displayio_colorconverter_type) &&
!mp_obj_is_type(pixel_shader, &displayio_palette_type)) { !mp_obj_is_type(pixel_shader, &displayio_palette_type)) {
mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader); mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader);

View File

@ -11,12 +11,12 @@
extern const mp_obj_type_t vectorio_vector_shape_type; extern const mp_obj_type_t vectorio_vector_shape_type;
// Python shared bindings constructor // Python shared bindings constructor
mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pixel_shader, int16_t x, int16_t y); mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pixel_shader, int32_t x, int32_t y);
// C data constructor // C data constructor
void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self,
vectorio_ishape_t ishape, vectorio_ishape_t ishape,
mp_obj_t pixel_shader, uint16_t x, uint16_t y); mp_obj_t pixel_shader, int32_t x, int32_t y);
void common_hal_vectorio_vector_shape_set_dirty(void *self); void common_hal_vectorio_vector_shape_set_dirty(void *self);

View File

@ -22,7 +22,7 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple
VECTORIO_POLYGON_DEBUG(" self.len: %d, len: %d, ", self->len, len); VECTORIO_POLYGON_DEBUG(" self.len: %d, len: %d, ", self->len, len);
if (len < 3) { if (len < 3) {
mp_raise_TypeError_varg(translate("Polygon needs at least 3 points")); mp_raise_TypeError(translate("Polygon needs at least 3 points"));
} }
if (self->len < 2 * len) { if (self->len < 2 * len) {

View File

@ -125,6 +125,24 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou
} }
STATIC
void check_bounds_and_set_x(vectorio_vector_shape_t *self, mp_int_t x) {
if (x < SHRT_MIN || x > SHRT_MAX) {
mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_x, SHRT_MIN, SHRT_MAX);
}
self->x = x;
}
STATIC
void check_bounds_and_set_y(vectorio_vector_shape_t *self, mp_int_t y) {
if (y < SHRT_MIN || y > SHRT_MAX) {
mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_y, SHRT_MIN, SHRT_MAX);
}
self->y = y;
}
// For use by Group to know where it needs to redraw on layer removal. // For use by Group to know where it needs to redraw on layer removal.
bool vectorio_vector_shape_get_dirty_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) { bool vectorio_vector_shape_get_dirty_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) {
out_area->x1 = out_area->x2; out_area->x1 = out_area->x2;
@ -164,10 +182,10 @@ void common_hal_vectorio_vector_shape_set_dirty(void *vector_shape) {
void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self,
vectorio_ishape_t ishape, vectorio_ishape_t ishape,
mp_obj_t pixel_shader, uint16_t x, uint16_t y) { mp_obj_t pixel_shader, int32_t x, int32_t y) {
VECTORIO_SHAPE_DEBUG("%p vector_shape_construct x:%3d, y:%3d\n", self, x, y); VECTORIO_SHAPE_DEBUG("%p vector_shape_construct x:%3d, y:%3d\n", self, x, y);
self->x = x; check_bounds_and_set_x(self, x);
self->y = y; check_bounds_and_set_y(self, y);
self->pixel_shader = pixel_shader; self->pixel_shader = pixel_shader;
self->ishape = ishape; self->ishape = ishape;
self->absolute_transform = &null_transform; // Critical to have a valid transform before getting screen area. self->absolute_transform = &null_transform; // Critical to have a valid transform before getting screen area.
@ -189,7 +207,7 @@ void common_hal_vectorio_vector_shape_set_x(vectorio_vector_shape_t *self, mp_in
if (self->x == x) { if (self->x == x) {
return; return;
} }
self->x = x; check_bounds_and_set_x(self, x);
common_hal_vectorio_vector_shape_set_dirty(self); common_hal_vectorio_vector_shape_set_dirty(self);
} }
@ -205,7 +223,7 @@ void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_in
if (self->y == y) { if (self->y == y) {
return; return;
} }
self->y = y; check_bounds_and_set_y(self, y);
common_hal_vectorio_vector_shape_set_dirty(self); common_hal_vectorio_vector_shape_set_dirty(self);
} }
@ -224,20 +242,27 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self
mp_obj_t *tuple_items; mp_obj_t *tuple_items;
mp_obj_tuple_get(xy, &tuple_len, &tuple_items); mp_obj_tuple_get(xy, &tuple_len, &tuple_items);
if (tuple_len != 2) { if (tuple_len != 2) {
mp_raise_TypeError_varg(translate("(x,y) integers required")); mp_raise_TypeError(translate("(x,y) integers required"));
} }
mp_int_t x; mp_int_t x;
mp_int_t y; mp_int_t y;
if (!mp_obj_get_int_maybe(tuple_items[ 0 ], &x) if (!mp_obj_get_int_maybe(tuple_items[ 0 ], &x)
|| !mp_obj_get_int_maybe(tuple_items[ 1 ], &y) || !mp_obj_get_int_maybe(tuple_items[ 1 ], &y)) {
|| x < SHRT_MIN || x > SHRT_MAX || y < SHRT_MIN || y > SHRT_MAX
) {
mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point);
} }
self->x = (int16_t)x; bool dirty = false;
self->y = (int16_t)y; if (self->x != x) {
common_hal_vectorio_vector_shape_set_dirty(self); check_bounds_and_set_x(self, x);
dirty = true;
}
if (self->y != y) {
check_bounds_and_set_y(self, y);
dirty = true;
}
if (dirty) {
common_hal_vectorio_vector_shape_set_dirty(self);
}
} }