Skip to content

Commit d9ae2c0

Browse files
authored
Merge branch 'adafruit:main' into pycubed_v05c
2 parents aaf2c37 + cf5c32b commit d9ae2c0

File tree

10 files changed

+52
-24
lines changed

10 files changed

+52
-24
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,6 @@
191191
[submodule "lib/quirc"]
192192
path = lib/quirc
193193
url = https://github.com/adafruit/quirc.git
194+
[submodule "frozen/Adafruit_CircuitPython_APDS9960"]
195+
path = frozen/Adafruit_CircuitPython_APDS9960
196+
url = https://github.com/adafruit/Adafruit_CircuitPython_APDS9960

ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ CIRCUITPY_PULSEIO = 0
1919
CIRCUITPY_PWMIO = 0
2020
CIRCUITPY_ROTARYIO = 0
2121
CIRCUITPY_RTC = 0
22-
CIRCUITPY_USB_MIDI = 0
2322

2423
CIRCUITPY_GETPASS = 0
2524
CIRCUITPY_TRACEBACK = 0
@@ -28,5 +27,5 @@ CIRCUITPY_PIXELBUF = 1
2827
CIRCUITPY_BUSDEVICE = 1
2928

3029
# Include these Python libraries in firmware.
31-
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
30+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_APDS9960
3231
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel

shared-bindings/vectorio/Circle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg
4242

4343
// VectorShape parts
4444
mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj;
45-
int16_t x = args[ARG_x].u_int;
46-
int16_t y = args[ARG_y].u_int;
45+
int32_t x = args[ARG_x].u_int;
46+
int32_t y = args[ARG_y].u_int;
4747
mp_obj_t vector_shape = vectorio_vector_shape_make_new(self, pixel_shader, x, y);
4848
self->draw_protocol_instance = vector_shape;
4949

shared-bindings/vectorio/Polygon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar
4747

4848
// VectorShape parts
4949
mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj;
50-
int16_t x = args[ARG_x].u_int;
51-
int16_t y = args[ARG_y].u_int;
50+
int32_t x = args[ARG_x].u_int;
51+
int32_t y = args[ARG_y].u_int;
5252
mp_obj_t vector_shape = vectorio_vector_shape_make_new(self, pixel_shader, x, y);
5353
self->draw_protocol_instance = vector_shape;
5454

shared-bindings/vectorio/Rectangle.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_
4646

4747
// VectorShape parts
4848
mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj;
49-
int16_t x = args[ARG_x].u_int;
50-
int16_t y = args[ARG_y].u_int;
49+
int32_t x = args[ARG_x].u_int;
50+
int32_t y = args[ARG_y].u_int;
5151
mp_obj_t vector_shape = vectorio_vector_shape_make_new(self, pixel_shader, x, y);
5252
self->draw_protocol_instance = vector_shape;
5353

shared-bindings/vectorio/VectorShape.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// 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.
2424
// x: Initial x position of the center axis of the shape within the parent.
2525
// y: Initial y position of the center axis of the shape within the parent."""
26-
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) {
26+
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) {
2727
if (!mp_obj_is_type(pixel_shader, &displayio_colorconverter_type) &&
2828
!mp_obj_is_type(pixel_shader, &displayio_palette_type)) {
2929
mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader);

shared-bindings/vectorio/VectorShape.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
extern const mp_obj_type_t vectorio_vector_shape_type;
1212

1313
// Python shared bindings constructor
14-
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);
14+
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);
1515

1616
// C data constructor
1717
void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self,
1818
vectorio_ishape_t ishape,
19-
mp_obj_t pixel_shader, uint16_t x, uint16_t y);
19+
mp_obj_t pixel_shader, int32_t x, int32_t y);
2020

2121
void common_hal_vectorio_vector_shape_set_dirty(void *self);
2222

shared-module/vectorio/Polygon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple
2222
VECTORIO_POLYGON_DEBUG(" self.len: %d, len: %d, ", self->len, len);
2323

2424
if (len < 3) {
25-
mp_raise_TypeError_varg(translate("Polygon needs at least 3 points"));
25+
mp_raise_TypeError(translate("Polygon needs at least 3 points"));
2626
}
2727

2828
if (self->len < 2 * len) {

shared-module/vectorio/VectorShape.c

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou
125125
}
126126

127127

128+
STATIC
129+
void check_bounds_and_set_x(vectorio_vector_shape_t *self, mp_int_t x) {
130+
if (x < SHRT_MIN || x > SHRT_MAX) {
131+
mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_x, SHRT_MIN, SHRT_MAX);
132+
}
133+
self->x = x;
134+
}
135+
136+
137+
STATIC
138+
void check_bounds_and_set_y(vectorio_vector_shape_t *self, mp_int_t y) {
139+
if (y < SHRT_MIN || y > SHRT_MAX) {
140+
mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_y, SHRT_MIN, SHRT_MAX);
141+
}
142+
self->y = y;
143+
}
144+
145+
128146
// For use by Group to know where it needs to redraw on layer removal.
129147
bool vectorio_vector_shape_get_dirty_area(vectorio_vector_shape_t *self, displayio_area_t *out_area) {
130148
out_area->x1 = out_area->x2;
@@ -164,10 +182,10 @@ void common_hal_vectorio_vector_shape_set_dirty(void *vector_shape) {
164182

165183
void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self,
166184
vectorio_ishape_t ishape,
167-
mp_obj_t pixel_shader, uint16_t x, uint16_t y) {
185+
mp_obj_t pixel_shader, int32_t x, int32_t y) {
168186
VECTORIO_SHAPE_DEBUG("%p vector_shape_construct x:%3d, y:%3d\n", self, x, y);
169-
self->x = x;
170-
self->y = y;
187+
check_bounds_and_set_x(self, x);
188+
check_bounds_and_set_y(self, y);
171189
self->pixel_shader = pixel_shader;
172190
self->ishape = ishape;
173191
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
189207
if (self->x == x) {
190208
return;
191209
}
192-
self->x = x;
210+
check_bounds_and_set_x(self, x);
193211
common_hal_vectorio_vector_shape_set_dirty(self);
194212
}
195213

@@ -205,7 +223,7 @@ void common_hal_vectorio_vector_shape_set_y(vectorio_vector_shape_t *self, mp_in
205223
if (self->y == y) {
206224
return;
207225
}
208-
self->y = y;
226+
check_bounds_and_set_y(self, y);
209227
common_hal_vectorio_vector_shape_set_dirty(self);
210228
}
211229

@@ -224,20 +242,27 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self
224242
mp_obj_t *tuple_items;
225243
mp_obj_tuple_get(xy, &tuple_len, &tuple_items);
226244
if (tuple_len != 2) {
227-
mp_raise_TypeError_varg(translate("(x,y) integers required"));
245+
mp_raise_TypeError(translate("(x,y) integers required"));
228246
}
229247

230248
mp_int_t x;
231249
mp_int_t y;
232250
if (!mp_obj_get_int_maybe(tuple_items[ 0 ], &x)
233-
|| !mp_obj_get_int_maybe(tuple_items[ 1 ], &y)
234-
|| x < SHRT_MIN || x > SHRT_MAX || y < SHRT_MIN || y > SHRT_MAX
235-
) {
251+
|| !mp_obj_get_int_maybe(tuple_items[ 1 ], &y)) {
236252
mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point);
237253
}
238-
self->x = (int16_t)x;
239-
self->y = (int16_t)y;
240-
common_hal_vectorio_vector_shape_set_dirty(self);
254+
bool dirty = false;
255+
if (self->x != x) {
256+
check_bounds_and_set_x(self, x);
257+
dirty = true;
258+
}
259+
if (self->y != y) {
260+
check_bounds_and_set_y(self, y);
261+
dirty = true;
262+
}
263+
if (dirty) {
264+
common_hal_vectorio_vector_shape_set_dirty(self);
265+
}
241266
}
242267

243268

0 commit comments

Comments
 (0)