summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorDavePutz <dwputz@gmail.com>2020-11-16 10:30:10 -0600
committerGitHub <noreply@github.com>2020-11-16 10:30:10 -0600
commit3abc671bbdf617dcf87cbd4eda1201c944c05651 (patch)
tree47f6a854677781382d715791e7d7534d71887f7a /shared-bindings
parent2b4d12abcc09b22985d456f3a05fc8511fc9def4 (diff)
parentf2e911ad91db7c04673e76c884abbc19494a4e7f (diff)
Merge pull request #34 from adafruit/main
Update from adafruit/main
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/displayio/Display.c22
-rw-r--r--shared-bindings/displayio/EPaperDisplay.c29
-rw-r--r--shared-bindings/displayio/EPaperDisplay.h3
-rw-r--r--shared-bindings/displayio/FourWire.h3
-rw-r--r--shared-bindings/displayio/I2CDisplay.h3
-rw-r--r--shared-bindings/displayio/ParallelBus.h3
-rw-r--r--shared-bindings/displayio/__init__.h3
-rw-r--r--shared-bindings/rgbmatrix/RGBMatrix.c7
8 files changed, 52 insertions, 21 deletions
diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c
index 1ed59f233..8d1a888fe 100644
--- a/shared-bindings/displayio/Display.c
+++ b/shared-bindings/displayio/Display.c
@@ -58,24 +58,26 @@
//| r"""Create a Display object on the given display bus (`FourWire`, `ParallelBus` or `I2CDisplay`).
//|
//| The ``init_sequence`` is bitpacked to minimize the ram impact. Every command begins with a
-//| command byte followed by a byte to determine the parameter count and if a delay is need after.
-//| When the top bit of the second byte is 1, the next byte will be the delay time in milliseconds.
-//| The remaining 7 bits are the parameter count excluding any delay byte. The third through final
-//| bytes are the remaining command parameters. The next byte will begin a new command definition.
-//| Here is a portion of ILI9341 init code:
+//| command byte followed by a byte to determine the parameter count and delay. When the top bit
+//| of the second byte is 1 (0x80), a delay will occur after the command parameters are sent.
+//| The remaining 7 bits are the parameter count excluding any delay byte. The bytes following
+//| are the parameters. When the delay bit is set, a single byte after the parameters specifies
+//| the delay duration in milliseconds. The value 0xff will lead to an extra long 500 ms delay
+//| instead of 255 ms. The next byte will begin a new command definition.
+//| Here is an example:
//|
//| .. code-block:: python
//|
//| init_sequence = (b"\xe1\x0f\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F" # Set Gamma
//| b"\x11\x80\x78"# Exit Sleep then delay 0x78 (120ms)
-//| b"\x29\x80\x78"# Display on then delay 0x78 (120ms)
+//| b"\x29\x81\xaa\x78"# Display on then delay 0x78 (120ms)
//| )
//| display = displayio.Display(display_bus, init_sequence, width=320, height=240)
//|
-//| The first command is 0xe1 with 15 (0xf) parameters following. The second and third are 0x11 and
-//| 0x29 respectively with delays (0x80) of 120ms (0x78) and no parameters. Multiple byte literals
-//| (b"") are merged together on load. The parens are needed to allow byte literals on subsequent
-//| lines.
+//| The first command is 0xe1 with 15 (0xf) parameters following. The second is 0x11 with 0
+//| parameters and a 120ms (0x78) delay. The third command is 0x29 with one parameter 0xaa and a
+//| 120ms delay (0x78). Multiple byte literals (b"") are merged together on load. The parens
+//| are needed to allow byte literals on subsequent lines.
//|
//| The initialization sequence should always leave the display memory access inline with the scan
//| of the display to minimize tearing artifacts.
diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c
index e0326d9c8..ebff64008 100644
--- a/shared-bindings/displayio/EPaperDisplay.c
+++ b/shared-bindings/displayio/EPaperDisplay.c
@@ -65,11 +65,12 @@
//| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`).
//|
//| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every
-//| command begins with a command byte followed by a byte to determine the parameter count and if
-//| a delay is need after. When the top bit of the second byte is 1, the next byte will be the
-//| delay time in milliseconds. The remaining 7 bits are the parameter count excluding any delay
-//| byte. The third through final bytes are the remaining command parameters. The next byte will
-//| begin a new command definition.
+//| command begins with a command byte followed by a byte to determine the parameter count and
+//| delay. When the top bit of the second byte is 1 (0x80), a delay will occur after the command
+//| parameters are sent. The remaining 7 bits are the parameter count excluding any delay
+//| byte. The bytes following are the parameters. When the delay bit is set, a single byte after
+//| the parameters specifies the delay duration in milliseconds. The value 0xff will lead to an
+//| extra long 500 ms delay instead of 255 ms. The next byte will begin a new command definition.
//|
//| :param display_bus: The bus that the display is connected to
//| :type _DisplayBus: displayio.FourWire or displayio.ParallelBus
@@ -244,6 +245,23 @@ const mp_obj_property_t displayio_epaperdisplay_time_to_refresh_obj = {
(mp_obj_t)&mp_const_none_obj},
};
+//| busy: bool
+//| """True when the display is refreshing. This uses the ``busy_pin`` when available or the
+//| ``refresh_time`` otherwise."""
+//|
+STATIC mp_obj_t displayio_epaperdisplay_obj_get_busy(mp_obj_t self_in) {
+ displayio_epaperdisplay_obj_t *self = native_display(self_in);
+ return mp_obj_new_bool(common_hal_displayio_epaperdisplay_get_busy(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_busy_obj, displayio_epaperdisplay_obj_get_busy);
+
+const mp_obj_property_t displayio_epaperdisplay_busy_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&displayio_epaperdisplay_get_busy_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
//| width: int
//| """Gets the width of the display in pixels"""
//|
@@ -300,6 +318,7 @@ STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_epaperdisplay_width_obj) },
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_epaperdisplay_height_obj) },
{ MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_epaperdisplay_bus_obj) },
+ { MP_ROM_QSTR(MP_QSTR_busy), MP_ROM_PTR(&displayio_epaperdisplay_busy_obj) },
{ MP_ROM_QSTR(MP_QSTR_time_to_refresh), MP_ROM_PTR(&displayio_epaperdisplay_time_to_refresh_obj) },
};
STATIC MP_DEFINE_CONST_DICT(displayio_epaperdisplay_locals_dict, displayio_epaperdisplay_locals_dict_table);
diff --git a/shared-bindings/displayio/EPaperDisplay.h b/shared-bindings/displayio/EPaperDisplay.h
index 352de899a..f785203a4 100644
--- a/shared-bindings/displayio/EPaperDisplay.h
+++ b/shared-bindings/displayio/EPaperDisplay.h
@@ -39,7 +39,7 @@ extern const mp_obj_type_t displayio_epaperdisplay_type;
#define NO_COMMAND 0x100
void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t* self,
- mp_obj_t bus, uint8_t* start_sequence, uint16_t start_sequence_len, uint8_t* stop_sequence, uint16_t stop_sequence_len,
+ mp_obj_t bus, const uint8_t* start_sequence, uint16_t start_sequence_len, const uint8_t* stop_sequence, uint16_t stop_sequence_len,
uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation,
uint16_t set_column_window_command, uint16_t set_row_window_command,
uint16_t set_current_column_command, uint16_t set_current_row_command,
@@ -52,6 +52,7 @@ bool common_hal_displayio_epaperdisplay_show(displayio_epaperdisplay_obj_t* self
// Returns time in milliseconds.
uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaperdisplay_obj_t* self);
+bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t* self);
uint16_t common_hal_displayio_epaperdisplay_get_width(displayio_epaperdisplay_obj_t* self);
uint16_t common_hal_displayio_epaperdisplay_get_height(displayio_epaperdisplay_obj_t* self);
diff --git a/shared-bindings/displayio/FourWire.h b/shared-bindings/displayio/FourWire.h
index ac186d2c3..6f6b528e7 100644
--- a/shared-bindings/displayio/FourWire.h
+++ b/shared-bindings/displayio/FourWire.h
@@ -48,7 +48,8 @@ bool common_hal_displayio_fourwire_bus_free(mp_obj_t self);
bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t self);
-void common_hal_displayio_fourwire_send(mp_obj_t self, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length);
+void common_hal_displayio_fourwire_send(mp_obj_t self, display_byte_type_t byte_type,
+ display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length);
void common_hal_displayio_fourwire_end_transaction(mp_obj_t self);
diff --git a/shared-bindings/displayio/I2CDisplay.h b/shared-bindings/displayio/I2CDisplay.h
index bae53c491..37520202e 100644
--- a/shared-bindings/displayio/I2CDisplay.h
+++ b/shared-bindings/displayio/I2CDisplay.h
@@ -44,7 +44,8 @@ bool common_hal_displayio_i2cdisplay_bus_free(mp_obj_t self);
bool common_hal_displayio_i2cdisplay_begin_transaction(mp_obj_t self);
-void common_hal_displayio_i2cdisplay_send(mp_obj_t self, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length);
+void common_hal_displayio_i2cdisplay_send(mp_obj_t self, display_byte_type_t byte_type,
+ display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length);
void common_hal_displayio_i2cdisplay_end_transaction(mp_obj_t self);
diff --git a/shared-bindings/displayio/ParallelBus.h b/shared-bindings/displayio/ParallelBus.h
index be2aef7d4..1e74e3a0a 100644
--- a/shared-bindings/displayio/ParallelBus.h
+++ b/shared-bindings/displayio/ParallelBus.h
@@ -46,7 +46,8 @@ bool common_hal_displayio_parallelbus_bus_free(mp_obj_t self);
bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t self);
-void common_hal_displayio_parallelbus_send(mp_obj_t self, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length);
+void common_hal_displayio_parallelbus_send(mp_obj_t self, display_byte_type_t byte_type,
+ display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length);
void common_hal_displayio_parallelbus_end_transaction(mp_obj_t self);
diff --git a/shared-bindings/displayio/__init__.h b/shared-bindings/displayio/__init__.h
index a7748d029..4fc666c59 100644
--- a/shared-bindings/displayio/__init__.h
+++ b/shared-bindings/displayio/__init__.h
@@ -42,7 +42,8 @@ typedef enum {
typedef bool (*display_bus_bus_reset)(mp_obj_t bus);
typedef bool (*display_bus_bus_free)(mp_obj_t bus);
typedef bool (*display_bus_begin_transaction)(mp_obj_t bus);
-typedef void (*display_bus_send)(mp_obj_t bus, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length);
+typedef void (*display_bus_send)(mp_obj_t bus, display_byte_type_t byte_type,
+ display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length);
typedef void (*display_bus_end_transaction)(mp_obj_t bus);
void common_hal_displayio_release_displays(void);
diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c
index 753c1c920..5f5ea4fae 100644
--- a/shared-bindings/rgbmatrix/RGBMatrix.c
+++ b/shared-bindings/rgbmatrix/RGBMatrix.c
@@ -197,6 +197,11 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
uint8_t clock_pin = validate_pin(args[ARG_clock_pin].u_obj);
uint8_t latch_pin = validate_pin(args[ARG_latch_pin].u_obj);
uint8_t output_enable_pin = validate_pin(args[ARG_output_enable_pin].u_obj);
+ int bit_depth = args[ARG_bit_depth].u_int;
+
+ if (bit_depth <= 0 || bit_depth > 6) {
+ mp_raise_ValueError_varg(translate("Bit depth must be from 1 to 6 inclusive, not %d"), bit_depth);
+ }
validate_pins(MP_QSTR_rgb_pins, rgb_pins, MP_ARRAY_SIZE(self->rgb_pins), args[ARG_rgb_list].u_obj, &rgb_count);
validate_pins(MP_QSTR_addr_pins, addr_pins, MP_ARRAY_SIZE(self->addr_pins), args[ARG_addr_list].u_obj, &addr_count);
@@ -229,7 +234,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
common_hal_rgbmatrix_rgbmatrix_construct(self,
args[ARG_width].u_int,
- args[ARG_bit_depth].u_int,
+ bit_depth,
rgb_count, rgb_pins,
addr_count, addr_pins,
clock_pin, latch_pin, output_enable_pin,