summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorDavePutz <dwputz@gmail.com>2020-06-08 10:42:45 -0500
committerGitHub <noreply@github.com>2020-06-08 10:42:45 -0500
commitef87cc3ed389700f7d32d8a74b2e8499863f1a74 (patch)
tree1bcae9dd5dac92169db4435421aa1a4510a449ce /shared-module
parent1f40f9e04ff9be0eb82f56014bde5749be604ad9 (diff)
parent004d6441842981994d20027ab7e3248339524bec (diff)
Merge pull request #6 from adafruit/master
updating from adafruit
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/_bleio/ScanResults.c4
-rw-r--r--shared-module/_eve/__init__.c1
-rw-r--r--shared-module/_pixelbuf/PixelBuf.c27
-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/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
19 files changed, 39 insertions, 48 deletions
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/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c
index 31350b875..9d671e454 100644
--- a/shared-module/_pixelbuf/PixelBuf.c
+++ b/shared-module/_pixelbuf/PixelBuf.c
@@ -147,18 +147,11 @@ void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t* self, mp_obj_t color, uint8_
*r = value >> 16 & 0xff;
*g = (value >> 8) & 0xff;
*b = value & 0xff;
- // Int colors can't set white directly so convert to white when all components are equal.
- if (!byteorder->is_dotstar && byteorder->bpp == 4 && byteorder->has_white && *r == *g && *r == *b) {
- *w = *r;
- *r = 0;
- *g = 0;
- *b = 0;
- }
} else {
mp_obj_t *items;
size_t len;
mp_obj_get_array(color, &len, &items);
- if (len != byteorder->bpp && !byteorder->is_dotstar) {
+ if (len < 3 || len > 4) {
mp_raise_ValueError_varg(translate("Expected tuple of length %d, got %d"), byteorder->bpp, len);
}
@@ -171,8 +164,17 @@ void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t* self, mp_obj_t color, uint8_
} else {
*w = mp_obj_get_int_truncated(items[PIXEL_W]);
}
+ return;
}
}
+ // Int colors can't set white directly so convert to white when all components are equal.
+ // Also handles RGBW values assigned an RGB tuple.
+ if (!byteorder->is_dotstar && byteorder->bpp == 4 && byteorder->has_white && *r == *g && *r == *b) {
+ *w = *r;
+ *r = 0;
+ *g = 0;
+ *b = 0;
+ }
}
void _pixelbuf_set_pixel_color(pixelbuf_pixelbuf_obj_t* self, size_t index, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
@@ -216,12 +218,11 @@ void _pixelbuf_set_pixel(pixelbuf_pixelbuf_obj_t* self, size_t index, mp_obj_t v
_pixelbuf_set_pixel_color(self, index, r, g, b, w);
}
-void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, size_t start, size_t stop, size_t step, mp_obj_t* values) {
+void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, size_t start, mp_int_t step, size_t slice_len, mp_obj_t* values) {
pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in);
- size_t source_i = 0;
- for (size_t target_i = start; target_i < stop; target_i += step) {
- _pixelbuf_set_pixel(self, target_i, values[source_i]);
- source_i++;
+ for (size_t i = 0; i < slice_len; i++) {
+ _pixelbuf_set_pixel(self, start, values[i]);
+ start+=step;
}
if (self->auto_write) {
common_hal__pixelbuf_pixelbuf_show(self_in);
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/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
-