Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
f2d3d8b6d7
|
@ -98,7 +98,8 @@ void board_init(void) {
|
||||||
false, // busy_state
|
false, // busy_state
|
||||||
5, // seconds_per_frame
|
5, // seconds_per_frame
|
||||||
false, // chip_select (don't always toggle chip select)
|
false, // chip_select (don't always toggle chip select)
|
||||||
false); // grayscale
|
false, // grayscale
|
||||||
|
false); // two_byte_sequence_length
|
||||||
}
|
}
|
||||||
|
|
||||||
bool board_requests_safe_mode(void) {
|
bool board_requests_safe_mode(void) {
|
||||||
|
|
|
@ -160,7 +160,8 @@ void board_init(void) {
|
||||||
false, // busy_state
|
false, // busy_state
|
||||||
5.0, // seconds_per_frame
|
5.0, // seconds_per_frame
|
||||||
false, // always_toggle_chip_select
|
false, // always_toggle_chip_select
|
||||||
true); // grayscale
|
true, // grayscale
|
||||||
|
false); // two_byte_sequence_length
|
||||||
}
|
}
|
||||||
|
|
||||||
bool board_requests_safe_mode(void) {
|
bool board_requests_safe_mode(void) {
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
//| refresh_display_command: int, refresh_time: float = 40,
|
//| refresh_display_command: int, refresh_time: float = 40,
|
||||||
//| busy_pin: Optional[microcontroller.Pin] = None, busy_state: bool = True,
|
//| busy_pin: Optional[microcontroller.Pin] = None, busy_state: bool = True,
|
||||||
//| seconds_per_frame: float = 180, always_toggle_chip_select: bool = False,
|
//| seconds_per_frame: float = 180, always_toggle_chip_select: bool = False,
|
||||||
//| grayscale: bool = False) -> None:
|
//| grayscale: bool = False, two_byte_sequence_length: bool = False) -> None:
|
||||||
//| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `paralleldisplay.ParallelBus`).
|
//| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `paralleldisplay.ParallelBus`).
|
||||||
//|
|
//|
|
||||||
//| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every
|
//| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every
|
||||||
|
@ -100,7 +100,8 @@
|
||||||
//| :param bool busy_state: State of the busy pin when the display is busy
|
//| :param bool busy_state: State of the busy pin when the display is busy
|
||||||
//| :param float seconds_per_frame: Minimum number of seconds between screen refreshes
|
//| :param float seconds_per_frame: Minimum number of seconds between screen refreshes
|
||||||
//| :param bool always_toggle_chip_select: When True, chip select is toggled every byte
|
//| :param bool always_toggle_chip_select: When True, chip select is toggled every byte
|
||||||
//| :param bool grayscale: When true, the color ram is the low bit of 2-bit grayscale"""
|
//| :param bool grayscale: When true, the color ram is the low bit of 2-bit grayscale
|
||||||
|
//| :param bool two_byte_sequence_length: When true, use two bytes to define sequence length"""
|
||||||
//| ...
|
//| ...
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||||
|
@ -110,7 +111,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size
|
||||||
ARG_set_current_row_command, ARG_write_black_ram_command, ARG_black_bits_inverted,
|
ARG_set_current_row_command, ARG_write_black_ram_command, ARG_black_bits_inverted,
|
||||||
ARG_write_color_ram_command, ARG_color_bits_inverted, ARG_highlight_color,
|
ARG_write_color_ram_command, ARG_color_bits_inverted, ARG_highlight_color,
|
||||||
ARG_refresh_display_command, ARG_refresh_time, ARG_busy_pin, ARG_busy_state,
|
ARG_refresh_display_command, ARG_refresh_time, ARG_busy_pin, ARG_busy_state,
|
||||||
ARG_seconds_per_frame, ARG_always_toggle_chip_select, ARG_grayscale };
|
ARG_seconds_per_frame, ARG_always_toggle_chip_select, ARG_grayscale, ARG_two_byte_sequence_length };
|
||||||
static const mp_arg_t allowed_args[] = {
|
static const mp_arg_t allowed_args[] = {
|
||||||
{ MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
{ MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||||
{ MP_QSTR_start_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
{ MP_QSTR_start_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||||
|
@ -138,6 +139,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size
|
||||||
{ MP_QSTR_seconds_per_frame, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(180)} },
|
{ MP_QSTR_seconds_per_frame, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(180)} },
|
||||||
{ MP_QSTR_always_toggle_chip_select, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
{ MP_QSTR_always_toggle_chip_select, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||||
{ MP_QSTR_grayscale, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
{ MP_QSTR_grayscale, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||||
|
{ MP_QSTR_two_byte_sequence_length, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
@ -182,7 +184,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size
|
||||||
args[ARG_write_black_ram_command].u_int, args[ARG_black_bits_inverted].u_bool, write_color_ram_command,
|
args[ARG_write_black_ram_command].u_int, args[ARG_black_bits_inverted].u_bool, write_color_ram_command,
|
||||||
args[ARG_color_bits_inverted].u_bool, highlight_color, args[ARG_refresh_display_command].u_int, refresh_time,
|
args[ARG_color_bits_inverted].u_bool, highlight_color, args[ARG_refresh_display_command].u_int, refresh_time,
|
||||||
busy_pin, args[ARG_busy_state].u_bool, seconds_per_frame,
|
busy_pin, args[ARG_busy_state].u_bool, seconds_per_frame,
|
||||||
args[ARG_always_toggle_chip_select].u_bool, args[ARG_grayscale].u_bool
|
args[ARG_always_toggle_chip_select].u_bool, args[ARG_grayscale].u_bool, args[ARG_two_byte_sequence_length].u_bool
|
||||||
);
|
);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|
|
@ -42,7 +42,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t
|
||||||
uint16_t set_column_window_command, uint16_t set_row_window_command,
|
uint16_t set_column_window_command, uint16_t set_row_window_command,
|
||||||
uint16_t set_current_column_command, uint16_t set_current_row_command,
|
uint16_t set_current_column_command, uint16_t set_current_row_command,
|
||||||
uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time,
|
uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time,
|
||||||
const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool always_toggle_chip_select, bool grayscale);
|
const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool always_toggle_chip_select, bool grayscale, bool two_byte_sequence_length);
|
||||||
|
|
||||||
bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *self);
|
bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *self);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t
|
||||||
uint16_t set_column_window_command, uint16_t set_row_window_command,
|
uint16_t set_column_window_command, uint16_t set_row_window_command,
|
||||||
uint16_t set_current_column_command, uint16_t set_current_row_command,
|
uint16_t set_current_column_command, uint16_t set_current_row_command,
|
||||||
uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time,
|
uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time,
|
||||||
const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool chip_select, bool grayscale) {
|
const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool chip_select, bool grayscale, bool two_byte_sequence_length) {
|
||||||
if (highlight_color != 0x000000) {
|
if (highlight_color != 0x000000) {
|
||||||
self->core.colorspace.tricolor = true;
|
self->core.colorspace.tricolor = true;
|
||||||
self->core.colorspace.tricolor_hue = displayio_colorconverter_compute_hue(highlight_color);
|
self->core.colorspace.tricolor_hue = displayio_colorconverter_compute_hue(highlight_color);
|
||||||
|
@ -85,6 +85,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t
|
||||||
self->stop_sequence_len = stop_sequence_len;
|
self->stop_sequence_len = stop_sequence_len;
|
||||||
|
|
||||||
self->busy.base.type = &mp_type_NoneType;
|
self->busy.base.type = &mp_type_NoneType;
|
||||||
|
self->two_byte_sequence_length = two_byte_sequence_length;
|
||||||
if (busy_pin != NULL) {
|
if (busy_pin != NULL) {
|
||||||
self->busy.base.type = &digitalio_digitalinout_type;
|
self->busy.base.type = &digitalio_digitalinout_type;
|
||||||
common_hal_digitalio_digitalinout_construct(&self->busy, busy_pin);
|
common_hal_digitalio_digitalinout_construct(&self->busy, busy_pin);
|
||||||
|
@ -145,8 +146,12 @@ STATIC void send_command_sequence(displayio_epaperdisplay_obj_t *self,
|
||||||
const uint8_t *cmd = sequence + i;
|
const uint8_t *cmd = sequence + i;
|
||||||
uint8_t data_size = *(cmd + 1);
|
uint8_t data_size = *(cmd + 1);
|
||||||
bool delay = (data_size & DELAY) != 0;
|
bool delay = (data_size & DELAY) != 0;
|
||||||
data_size &= ~DELAY;
|
|
||||||
const uint8_t *data = cmd + 2;
|
const uint8_t *data = cmd + 2;
|
||||||
|
data_size &= ~DELAY;
|
||||||
|
if (self->two_byte_sequence_length) {
|
||||||
|
data_size = ((data_size & ~DELAY) << 8) + *(cmd + 2);
|
||||||
|
data = cmd + 3;
|
||||||
|
}
|
||||||
displayio_display_core_begin_transaction(&self->core);
|
displayio_display_core_begin_transaction(&self->core);
|
||||||
self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, cmd, 1);
|
self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, cmd, 1);
|
||||||
self->core.send(self->core.bus, DISPLAY_DATA, self->chip_select, data, data_size);
|
self->core.send(self->core.bus, DISPLAY_DATA, self->chip_select, data, data_size);
|
||||||
|
@ -164,6 +169,9 @@ STATIC void send_command_sequence(displayio_epaperdisplay_obj_t *self,
|
||||||
wait_for_busy(self);
|
wait_for_busy(self);
|
||||||
}
|
}
|
||||||
i += 2 + data_size;
|
i += 2 + data_size;
|
||||||
|
if (self->two_byte_sequence_length) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ typedef struct {
|
||||||
bool refreshing;
|
bool refreshing;
|
||||||
bool grayscale;
|
bool grayscale;
|
||||||
display_chip_select_behavior_t chip_select;
|
display_chip_select_behavior_t chip_select;
|
||||||
|
bool two_byte_sequence_length;
|
||||||
} displayio_epaperdisplay_obj_t;
|
} displayio_epaperdisplay_obj_t;
|
||||||
|
|
||||||
void displayio_epaperdisplay_change_refresh_mode_parameters(displayio_epaperdisplay_obj_t *self,
|
void displayio_epaperdisplay_change_refresh_mode_parameters(displayio_epaperdisplay_obj_t *self,
|
||||||
|
|
Loading…
Reference in New Issue