summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authormicroDev <70126934+microDev1@users.noreply.github.com>2020-12-30 22:44:22 +0530
committermicroDev <70126934+microDev1@users.noreply.github.com>2020-12-30 22:44:22 +0530
commit28ce5e898864a6205ab3c0483991f27707164954 (patch)
tree0f5f353feb7b8b4f1ce0b6fd8e147e74083d9b26 /shared-module
parentc7f68022efa1306b0c7cb2fa47dcc84dbca2c605 (diff)
parent48de52c8ab62fae93e1382cb774802828cf92edd (diff)
Merge branch 'main' into touch-s2
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/adafruit_bus_device/I2CDevice.c4
-rw-r--r--shared-module/displayio/ColorConverter.c9
-rw-r--r--shared-module/displayio/FourWire.c4
-rw-r--r--shared-module/displayio/OnDiskBitmap.c5
4 files changed, 13 insertions, 9 deletions
diff --git a/shared-module/adafruit_bus_device/I2CDevice.c b/shared-module/adafruit_bus_device/I2CDevice.c
index ee4b4fa55..83abe80d6 100644
--- a/shared-module/adafruit_bus_device/I2CDevice.c
+++ b/shared-module/adafruit_bus_device/I2CDevice.c
@@ -57,8 +57,8 @@ uint8_t common_hal_adafruit_bus_device_i2cdevice_readinto(adafruit_bus_device_i2
return common_hal_busio_i2c_read(self->i2c, self->device_address, buffer, length);
}
-uint8_t common_hal_adafruit_bus_device_i2cdevice_write(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) {
- return common_hal_busio_i2c_write(self->i2c, self->device_address, buffer, length, true);
+uint8_t common_hal_adafruit_bus_device_i2cdevice_write(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length, bool transmit_stop_bit) {
+ return common_hal_busio_i2c_write(self->i2c, self->device_address, buffer, length, transmit_stop_bit);
}
void common_hal_adafruit_bus_device_i2cdevice_probe_for_device(adafruit_bus_device_i2cdevice_obj_t *self) {
diff --git a/shared-module/displayio/ColorConverter.c b/shared-module/displayio/ColorConverter.c
index 80558d037..40dcd9d16 100644
--- a/shared-module/displayio/ColorConverter.c
+++ b/shared-module/displayio/ColorConverter.c
@@ -29,6 +29,8 @@
#include "py/misc.h"
#include "py/runtime.h"
+#define NO_TRANSPARENT_COLOR (0x1000000)
+
uint32_t displayio_colorconverter_dither_noise_1 (uint32_t n)
{
n = (n >> 13) ^ n;
@@ -42,6 +44,7 @@ uint32_t displayio_colorconverter_dither_noise_2(uint32_t x, uint32_t y) {
void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t* self, bool dither) {
self->dither = dither;
+ self->transparent_color = NO_TRANSPARENT_COLOR;
}
uint16_t displayio_colorconverter_compute_rgb565(uint32_t color_rgb888) {
@@ -130,7 +133,7 @@ bool common_hal_displayio_colorconverter_get_dither(displayio_colorconverter_t*
}
void common_hal_displayio_colorconverter_make_transparent(displayio_colorconverter_t* self, uint32_t transparent_color) {
- if (self->transparent_color >= 0x1000000) {
+ if (self->transparent_color != NO_TRANSPARENT_COLOR) {
mp_raise_RuntimeError(translate("Only one color can be transparent at a time"));
}
self->transparent_color = transparent_color;
@@ -138,8 +141,8 @@ void common_hal_displayio_colorconverter_make_transparent(displayio_colorconvert
void common_hal_displayio_colorconverter_make_opaque(displayio_colorconverter_t* self, uint32_t transparent_color) {
(void) transparent_color;
- // 0x1000000 will never equal a valid color
- self->transparent_color = 0x1000000;
+ // NO_TRANSPARENT_COLOR will never equal a valid color
+ self->transparent_color = NO_TRANSPARENT_COLOR;
}
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) {
diff --git a/shared-module/displayio/FourWire.c b/shared-module/displayio/FourWire.c
index 06f8a84e3..e993f2480 100644
--- a/shared-module/displayio/FourWire.c
+++ b/shared-module/displayio/FourWire.c
@@ -76,9 +76,7 @@ void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t* self) {
common_hal_reset_pin(self->command.pin);
common_hal_reset_pin(self->chip_select.pin);
- if (self->reset.pin) {
- common_hal_reset_pin(self->reset.pin);
- }
+ common_hal_reset_pin(self->reset.pin);
}
bool common_hal_displayio_fourwire_reset(mp_obj_t obj) {
diff --git a/shared-module/displayio/OnDiskBitmap.c b/shared-module/displayio/OnDiskBitmap.c
index 993fc03de..c1a0ddeb7 100644
--- a/shared-module/displayio/OnDiskBitmap.c
+++ b/shared-module/displayio/OnDiskBitmap.c
@@ -57,7 +57,7 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
uint32_t compression = read_word(bmp_header, 15);
uint32_t number_of_colors = read_word(bmp_header, 23);
- bool indexed = ((bits_per_pixel <= 8) && (number_of_colors != 0));
+ bool indexed = bits_per_pixel <= 8;
self->bitfield_compressed = (compression == 3);
self->bits_per_pixel = bits_per_pixel;
self->width = read_word(bmp_header, 9);
@@ -75,6 +75,9 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
self->b_bitmask = 0x1f;
}
} else if (indexed && self->bits_per_pixel != 1) {
+ if (number_of_colors == 0) {
+ number_of_colors = 1 << bits_per_pixel;
+ }
uint16_t palette_size = number_of_colors * sizeof(uint32_t);
uint16_t palette_offset = 0xe + header_size;