summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorsommersoft <sommersoft@gmail.com>2020-06-20 08:41:41 -0500
committersommersoft <sommersoft@gmail.com>2020-06-20 08:41:41 -0500
commit023054e67acdd209c7990bba19b460adc4d6001e (patch)
treeb6002654bee95398f620cbdfd002d8e04c04ca7d /shared-module
parentc7b6d35fd43ca192c3e7e95bf0a0f2ea0b0fc4a5 (diff)
parent986664659e8408f25d3d8aa58926046cafede39f (diff)
Merge branch 'main' of https://github.com/adafruit/circuitpython into ci_check_vid_pid
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/_bleio/ScanEntry.c14
-rw-r--r--shared-module/_bleio/ScanResults.c4
-rw-r--r--shared-module/_eve/__init__.c1
-rw-r--r--shared-module/audiomixer/Mixer.c21
-rw-r--r--shared-module/displayio/ColorConverter.c5
-rw-r--r--shared-module/displayio/Display.c4
-rw-r--r--shared-module/displayio/Palette.c2
-rw-r--r--shared-module/displayio/TileGrid.c2
-rw-r--r--shared-module/framebufferio/FramebufferDisplay.c2
-rw-r--r--shared-module/network/__init__.c6
-rw-r--r--shared-module/rgbmatrix/RGBMatrix.c1
-rw-r--r--shared-module/ustack/__init__.c1
-rw-r--r--shared-module/vectorio/Circle.c1
-rw-r--r--shared-module/vectorio/Circle.h1
-rw-r--r--shared-module/vectorio/Polygon.c3
-rw-r--r--shared-module/vectorio/Rectangle.c1
-rw-r--r--shared-module/vectorio/Rectangle.h1
-rw-r--r--shared-module/vectorio/VectorShape.c4
-rw-r--r--shared-module/vectorio/__init__.c1
-rw-r--r--shared-module/vectorio/__init__.h1
20 files changed, 39 insertions, 37 deletions
diff --git a/shared-module/_bleio/ScanEntry.c b/shared-module/_bleio/ScanEntry.c
index 785209c4a..af9e4b347 100644
--- a/shared-module/_bleio/ScanEntry.c
+++ b/shared-module/_bleio/ScanEntry.c
@@ -56,11 +56,16 @@ bool bleio_scanentry_data_matches(const uint8_t* data, size_t len, const uint8_t
if (prefixes_length == 0) {
return true;
}
+ if (len == 0) {
+ // Prefixes exist, but no data.
+ return false;
+ }
size_t i = 0;
while(i < prefixes_length) {
uint8_t prefix_length = prefixes[i];
i += 1;
size_t j = 0;
+ bool prefix_matched = false;
while (j < len) {
uint8_t structure_length = data[j];
j += 1;
@@ -71,13 +76,18 @@ bool bleio_scanentry_data_matches(const uint8_t* data, size_t len, const uint8_t
if (any) {
return true;
}
- } else if (!any) {
- return false;
+ prefix_matched = true;
+ break;
}
j += structure_length;
}
+ // If all (!any), the current prefix must have matched at least one field.
+ if (!prefix_matched && !any) {
+ return false;
+ }
i += prefix_length;
}
+ // All prefixes matched some field (if !any), or none did (if any).
return !any;
}
diff --git a/shared-module/_bleio/ScanResults.c b/shared-module/_bleio/ScanResults.c
index ae36f8863..cb48d636d 100644
--- a/shared-module/_bleio/ScanResults.c
+++ b/shared-module/_bleio/ScanResults.c
@@ -56,7 +56,7 @@ mp_obj_t common_hal_bleio_scanresults_next(bleio_scanresults_obj_t *self) {
uint8_t type = ringbuf_get(&self->buf);
bool connectable = (type & (1 << 0)) != 0;
bool scan_response = (type & (1 << 1)) != 0;
- uint64_t ticks_ms;
+ uint64_t ticks_ms;
ringbuf_get_n(&self->buf, (uint8_t*) &ticks_ms, sizeof(ticks_ms));
uint8_t rssi = ringbuf_get(&self->buf);
uint8_t peer_addr[NUM_BLEIO_ADDRESS_BYTES];
@@ -81,7 +81,7 @@ mp_obj_t common_hal_bleio_scanresults_next(bleio_scanresults_obj_t *self) {
entry->time_received = ticks_ms;
entry->connectable = connectable;
entry->scan_response = scan_response;
-
+
return MP_OBJ_FROM_PTR(entry);
}
diff --git a/shared-module/_eve/__init__.c b/shared-module/_eve/__init__.c
index 2c93eb69f..0f1e12d9f 100644
--- a/shared-module/_eve/__init__.c
+++ b/shared-module/_eve/__init__.c
@@ -314,4 +314,3 @@ void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y) {
void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell) {
C4(eve, ((2 << 30) | (((x) & 511) << 21) | (((y) & 511) << 12) | (((handle) & 31) << 7) | (((cell) & 127) << 0)));
}
-
diff --git a/shared-module/audiomixer/Mixer.c b/shared-module/audiomixer/Mixer.c
index 4a72dab28..6c1ba1973 100644
--- a/shared-module/audiomixer/Mixer.c
+++ b/shared-module/audiomixer/Mixer.c
@@ -143,19 +143,17 @@ static inline uint32_t pack8(uint32_t val) {
static void mix_down_one_voice(audiomixer_mixer_obj_t* self,
audiomixer_mixervoice_obj_t* voice, bool voices_active,
uint32_t* word_buffer, uint32_t length) {
- bool voice_done = voice->sample == NULL;
- while (!voice_done && length != 0) {
+ while (length != 0) {
if (voice->buffer_length == 0) {
if (!voice->more_data) {
if (voice->loop) {
audiosample_reset_buffer(voice->sample, false, 0);
} else {
voice->sample = NULL;
- voice_done = true;
break;
}
}
- if (!voice_done) {
+ if (voice->sample) {
// Load another buffer
audioio_get_buffer_result_t result = audiosample_get_buffer(voice->sample, false, 0, (uint8_t**) &voice->remaining_buffer, &voice->buffer_length);
// Track length in terms of words.
@@ -230,10 +228,8 @@ static void mix_down_one_voice(audiomixer_mixer_obj_t* self,
}
if (length && !voices_active) {
- uint32_t sample_value = self->bits_per_sample == 8
- ? 0x80808080 : 0x80008000;
for (uint32_t i = 0; i<length; i++) {
- word_buffer[i] = sample_value;
+ word_buffer[i] = 0;
}
}
}
@@ -269,9 +265,16 @@ audioio_get_buffer_result_t audiomixer_mixer_get_buffer(audiomixer_mixer_obj_t*
for (int32_t v = 0; v < self->voice_count; v++) {
audiomixer_mixervoice_obj_t* voice = MP_OBJ_TO_PTR(self->voice[v]);
+ if(voice->sample) {
+ mix_down_one_voice(self, voice, voices_active, word_buffer, length);
+ voices_active = true;
+ }
+ }
- mix_down_one_voice(self, voice, voices_active, word_buffer, length);
- voices_active = true;
+ if (!voices_active) {
+ for (uint32_t i = 0; i<length; i++) {
+ word_buffer[i] = 0;
+ }
}
if (!self->samples_signed) {
diff --git a/shared-module/displayio/ColorConverter.c b/shared-module/displayio/ColorConverter.c
index 2c9fb6d78..c2c3214aa 100644
--- a/shared-module/displayio/ColorConverter.c
+++ b/shared-module/displayio/ColorConverter.c
@@ -110,7 +110,7 @@ void common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *sel
displayio_input_pixel_t input_pixel;
input_pixel.pixel = input_color;
input_pixel.x = input_pixel.y = input_pixel.tile = input_pixel.tile_x = input_pixel.tile_y = 0;
-
+
displayio_output_pixel_t output_pixel;
output_pixel.pixel = 0;
output_pixel.opaque = false;
@@ -130,7 +130,7 @@ bool common_hal_displayio_colorconverter_get_dither(displayio_colorconverter_t*
void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t* colorspace, const displayio_input_pixel_t *input_pixel, displayio_output_pixel_t *output_color) {
uint32_t pixel = input_pixel->pixel;
-
+
if (self->dither){
uint8_t randr = (displayio_colorconverter_dither_noise_2(input_pixel->tile_x,input_pixel->tile_y));
uint8_t randg = (displayio_colorconverter_dither_noise_2(input_pixel->tile_x+33,input_pixel->tile_y));
@@ -193,4 +193,3 @@ bool displayio_colorconverter_needs_refresh(displayio_colorconverter_t *self) {
void displayio_colorconverter_finish_refresh(displayio_colorconverter_t *self) {
}
-
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c
index 281c6fe90..a3d877f1a 100644
--- a/shared-module/displayio/Display.c
+++ b/shared-module/displayio/Display.c
@@ -170,7 +170,7 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self,
brightness = 1.0-brightness;
}
bool ok = false;
-
+
// Avoid PWM types and functions when the module isn't enabled
#if (CIRCUITPY_PULSEIO)
bool ispwm = (self->backlight_pwm.base.type == &pulseio_pwmout_type) ? true : false;
@@ -413,7 +413,7 @@ void release_display(displayio_display_obj_t* self) {
#if (CIRCUITPY_PULSEIO)
if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
common_hal_pulseio_pwmout_reset_ok(&self->backlight_pwm);
- common_hal_pulseio_pwmout_deinit(&self->backlight_pwm);
+ common_hal_pulseio_pwmout_deinit(&self->backlight_pwm);
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
common_hal_digitalio_digitalinout_deinit(&self->backlight_inout);
}
diff --git a/shared-module/displayio/Palette.c b/shared-module/displayio/Palette.c
index 1ef03aab4..facb1fa73 100644
--- a/shared-module/displayio/Palette.c
+++ b/shared-module/displayio/Palette.c
@@ -35,10 +35,12 @@ void common_hal_displayio_palette_construct(displayio_palette_t* self, uint16_t
void common_hal_displayio_palette_make_opaque(displayio_palette_t* self, uint32_t palette_index) {
self->colors[palette_index].transparent = false;
+ self->needs_refresh = true;
}
void common_hal_displayio_palette_make_transparent(displayio_palette_t* self, uint32_t palette_index) {
self->colors[palette_index].transparent = true;
+ self->needs_refresh = true;
}
uint32_t common_hal_displayio_palette_get_len(displayio_palette_t* self) {
diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c
index c4855c333..2766cbecd 100644
--- a/shared-module/displayio/TileGrid.c
+++ b/shared-module/displayio/TileGrid.c
@@ -435,7 +435,7 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const _displayio_c
} else if (MP_OBJ_IS_TYPE(self->bitmap, &displayio_ondiskbitmap_type)) {
input_pixel.pixel = common_hal_displayio_ondiskbitmap_get_pixel(self->bitmap, input_pixel.tile_x, input_pixel.tile_y);
}
-
+
output_pixel.opaque = true;
if (self->pixel_shader == mp_const_none) {
output_pixel.pixel = input_pixel.pixel;
diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c
index 2a88b5307..f296da409 100644
--- a/shared-module/framebufferio/FramebufferDisplay.c
+++ b/shared-module/framebufferio/FramebufferDisplay.c
@@ -57,7 +57,7 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu
NULL,
self->framebuffer_protocol->get_width(self->framebuffer),
self->framebuffer_protocol->get_height(self->framebuffer),
- ram_width,
+ ram_width,
ram_height,
0,
0,
diff --git a/shared-module/network/__init__.c b/shared-module/network/__init__.c
index 925e9a2a3..a45191d8c 100644
--- a/shared-module/network/__init__.c
+++ b/shared-module/network/__init__.c
@@ -37,7 +37,7 @@
#include "shared-module/network/__init__.h"
-// mod_network_nic_list needs to be declared in mpconfigport.h
+// mod_network_nic_list needs to be declared in mpconfigport.h
void network_module_init(void) {
@@ -47,7 +47,7 @@ void network_module_init(void) {
void network_module_deinit(void) {
for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) {
mp_obj_t nic = MP_STATE_PORT(mod_network_nic_list).items[i];
- mod_network_nic_type_t *nic_type = (mod_network_nic_type_t*)mp_obj_get_type(nic);
+ mod_network_nic_type_t *nic_type = (mod_network_nic_type_t*)mp_obj_get_type(nic);
if (nic_type->deinit != NULL) nic_type->deinit(nic);
}
mp_obj_list_set_len(&MP_STATE_PORT(mod_network_nic_list), 0);
@@ -61,7 +61,7 @@ void network_module_background(void) {
for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) {
mp_obj_t nic = MP_STATE_PORT(mod_network_nic_list).items[i];
- mod_network_nic_type_t *nic_type = (mod_network_nic_type_t*)mp_obj_get_type(nic);
+ mod_network_nic_type_t *nic_type = (mod_network_nic_type_t*)mp_obj_get_type(nic);
if (nic_type->timer_tick != NULL) nic_type->timer_tick(nic);
}
}
diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c
index df064ff81..6dad91679 100644
--- a/shared-module/rgbmatrix/RGBMatrix.c
+++ b/shared-module/rgbmatrix/RGBMatrix.c
@@ -206,4 +206,3 @@ int common_hal_rgbmatrix_rgbmatrix_get_height(rgbmatrix_rgbmatrix_obj_t* self) {
int computed_height = (self->rgb_count / 3) << (self->addr_count);
return computed_height;
}
-
diff --git a/shared-module/ustack/__init__.c b/shared-module/ustack/__init__.c
index 947f81f8e..1e168ad6a 100644
--- a/shared-module/ustack/__init__.c
+++ b/shared-module/ustack/__init__.c
@@ -49,4 +49,3 @@ uint32_t shared_module_ustack_stack_size() {
uint32_t shared_module_ustack_stack_usage() {
return mp_stack_usage();
}
-
diff --git a/shared-module/vectorio/Circle.c b/shared-module/vectorio/Circle.c
index 999d62512..73629b8ce 100644
--- a/shared-module/vectorio/Circle.c
+++ b/shared-module/vectorio/Circle.c
@@ -53,4 +53,3 @@ void common_hal_vectorio_circle_set_radius(void *obj, int16_t radius) {
self->on_dirty.event(self->on_dirty.obj);
}
}
-
diff --git a/shared-module/vectorio/Circle.h b/shared-module/vectorio/Circle.h
index 4b43d767e..d6a77b166 100644
--- a/shared-module/vectorio/Circle.h
+++ b/shared-module/vectorio/Circle.h
@@ -14,4 +14,3 @@ typedef struct {
} vectorio_circle_t;
#endif // MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_CIRCLE_H
-
diff --git a/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c
index aadf47911..0025d4bfc 100644
--- a/shared-module/vectorio/Polygon.c
+++ b/shared-module/vectorio/Polygon.c
@@ -136,7 +136,7 @@ uint32_t common_hal_vectorio_polygon_get_pixel(void *obj, int16_t x, int16_t y)
} else if ( y2 <= y && line_side(x1, y1, x2, y2, x, y) < 0 ) {
// Wind down, point is to the left of the edge vector
--winding_number;
- VECTORIO_POLYGON_DEBUG(" wind:%2d winding_number:%2d\n", -1, winding_number);
+ VECTORIO_POLYGON_DEBUG(" wind:%2d winding_number:%2d\n", -1, winding_number);
}
x1 = x2;
@@ -144,4 +144,3 @@ uint32_t common_hal_vectorio_polygon_get_pixel(void *obj, int16_t x, int16_t y)
}
return winding_number == 0 ? 0 : 1;
}
-
diff --git a/shared-module/vectorio/Rectangle.c b/shared-module/vectorio/Rectangle.c
index 7fabe6ff9..5d48cc648 100644
--- a/shared-module/vectorio/Rectangle.c
+++ b/shared-module/vectorio/Rectangle.c
@@ -32,4 +32,3 @@ uint32_t common_hal_vectorio_rectangle_get_height(void *rectangle) {
vectorio_rectangle_t *self = rectangle;
return self->height;
}
-
diff --git a/shared-module/vectorio/Rectangle.h b/shared-module/vectorio/Rectangle.h
index c1f2a7a64..56342a6d7 100644
--- a/shared-module/vectorio/Rectangle.h
+++ b/shared-module/vectorio/Rectangle.h
@@ -12,4 +12,3 @@ typedef struct {
} vectorio_rectangle_t;
#endif // MICROPY_INCLUDED_SHARED_MODULE_VECTORIO_RECTANGLE_H
-
diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c
index 4fb353aae..bfe8a7b25 100644
--- a/shared-module/vectorio/VectorShape.c
+++ b/shared-module/vectorio/VectorShape.c
@@ -191,7 +191,7 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ
bool full_coverage = displayio_area_equal(area, &overlap);
uint8_t pixels_per_byte = 8 / colorspace->depth;
-
+
uint32_t linestride_px = displayio_area_width(area);
uint32_t line_dirty_offset_px = (overlap.y1 - area->y1) * linestride_px;
uint32_t column_dirty_offset_px = overlap.x1 - area->x1;
@@ -332,5 +332,3 @@ void vectorio_vector_shape_update_transform(vectorio_vector_shape_t *self, displ
self->absolute_transform = group_transform == NULL ? &null_transform : group_transform;
common_hal_vectorio_vector_shape_set_dirty(self);
}
-
-
diff --git a/shared-module/vectorio/__init__.c b/shared-module/vectorio/__init__.c
index 473c509c3..f5227ef01 100644
--- a/shared-module/vectorio/__init__.c
+++ b/shared-module/vectorio/__init__.c
@@ -1,3 +1,2 @@
// Don't need anything in here yet
-
diff --git a/shared-module/vectorio/__init__.h b/shared-module/vectorio/__init__.h
index 6ae381f06..8da85bba4 100644
--- a/shared-module/vectorio/__init__.h
+++ b/shared-module/vectorio/__init__.h
@@ -12,4 +12,3 @@ typedef struct {
#endif
-