Skip to content

Commit f2e911a

Browse files
authored
Merge pull request #3680 from tannewt/magtag_builtin_display
Add board.DISPLAY to MagTag. Fix luma computation
2 parents 9169878 + bda3267 commit f2e911a

File tree

22 files changed

+191
-24
lines changed

22 files changed

+191
-24
lines changed

ports/atmel-samd/boards/metro_m0_express/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#define DEFAULT_UART_BUS_RX (&pin_PA11)
3434
#define DEFAULT_UART_BUS_TX (&pin_PA10)
3535

36+
// These pins are connected to the external crystal.
37+
#define IGNORE_PIN_PA00 1
38+
#define IGNORE_PIN_PA01 1
39+
3640
// USB is always used internally so skip the pin objects for it.
3741
#define IGNORE_PIN_PA24 1
3842
#define IGNORE_PIN_PA25 1

ports/atmel-samd/common-hal/audiobusio/PDMIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static void setup_dma(audiobusio_pdmin_obj_t* self, uint32_t length,
326326
// higher sample rate than specified. Then after the audio is
327327
// recorded, a more expensive filter non-real-time filter could be
328328
// used to down-sample and low-pass.
329-
uint16_t sinc_filter [OVERSAMPLING] = {
329+
const uint16_t sinc_filter [OVERSAMPLING] = {
330330
0, 2, 9, 21, 39, 63, 94, 132,
331331
179, 236, 302, 379, 467, 565, 674, 792,
332332
920, 1055, 1196, 1341, 1487, 1633, 1776, 1913,

ports/atmel-samd/common-hal/displayio/ParallelBus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
129129
return true;
130130
}
131131

132-
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
132+
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type,
133+
display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) {
133134
displayio_parallelbus_obj_t* self = MP_OBJ_TO_PTR(obj);
134135
common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA);
135136
uint32_t* clear_write = (uint32_t*) &self->write_group->OUTCLR.reg;

ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/board.c

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,83 @@
2626

2727
#include "boards/board.h"
2828
#include "mpconfigboard.h"
29+
#include "shared-bindings/busio/SPI.h"
30+
#include "shared-bindings/displayio/FourWire.h"
2931
#include "shared-bindings/microcontroller/Pin.h"
32+
#include "shared-module/displayio/__init__.h"
33+
#include "supervisor/shared/board.h"
34+
35+
#define DELAY 0x80
36+
37+
// This is an ILO373 control chip. The display is a 2.9" grayscale EInk.
38+
39+
const uint8_t display_start_sequence[] = {
40+
0x01, 5, 0x03, 0x00, 0x2b, 0x2b, 0x13, // power setting
41+
0x06, 3, 0x17, 0x17, 0x17, // booster soft start
42+
0x04, DELAY, 200, // power on and wait 200 ms
43+
0x00, 1, 0x7f, // panel setting
44+
0x50, 1, 0x97, // CDI setting
45+
0x30, 1, 0x3c, // PLL set to 50 Hx (M = 7, N = 4)
46+
0x61, 3, 0x80, 0x01, 0x28, // Resolution
47+
0x82, DELAY | 1, 0x12, 50, // VCM DC and delay 50ms
48+
49+
// Look up tables for voltage sequence for pixel transition
50+
// Common voltage
51+
0x20, 0x2a,
52+
0x00, 0x0a, 0x00, 0x00, 0x00, 0x01,
53+
0x60, 0x14, 0x14, 0x00, 0x00, 0x01,
54+
0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
55+
0x00, 0x13, 0x0a, 0x01, 0x00, 0x01,
56+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59+
60+
// White to white
61+
0x21, 0x2a,
62+
0x40, 0x0a, 0x00, 0x00, 0x00, 0x01,
63+
0x90, 0x14, 0x14, 0x00, 0x00, 0x01,
64+
0x10, 0x14, 0x0a, 0x00, 0x00, 0x01,
65+
0xa0, 0x13, 0x01, 0x00, 0x00, 0x01,
66+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
67+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69+
70+
// Black to white
71+
0x22, 0x2a,
72+
0x40, 0x0a, 0x00, 0x00, 0x00, 0x01,
73+
0x90, 0x14, 0x14, 0x00, 0x00, 0x01,
74+
0x00, 0x14, 0x0a, 0x00, 0x00, 0x01,
75+
0x99, 0x0c, 0x01, 0x03, 0x04, 0x01,
76+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
79+
80+
// White to black
81+
0x23, 0x2a,
82+
0x40, 0x0a, 0x00, 0x00, 0x00, 0x01,
83+
0x90, 0x14, 0x14, 0x00, 0x00, 0x01,
84+
0x00, 0x14, 0x0a, 0x00, 0x00, 0x01,
85+
0x99, 0x0b, 0x04, 0x04, 0x01, 0x01,
86+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
87+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
88+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
89+
90+
// Black to black
91+
0x24, 0x2a,
92+
0x80, 0x0a, 0x00, 0x00, 0x00, 0x01,
93+
0x90, 0x14, 0x14, 0x00, 0x00, 0x01,
94+
0x20, 0x14, 0x0a, 0x00, 0x00, 0x01,
95+
0x50, 0x13, 0x01, 0x00, 0x00, 0x01,
96+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
97+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
98+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
99+
};
100+
101+
const uint8_t display_stop_sequence[] = {
102+
0x50, 0x01, 0x17, // CDI Setting
103+
0x82, 0x01, 0x00, // VCM DC to -0.1V
104+
0x02, 0x00 // Power off
105+
};
30106

31107
void board_init(void) {
32108
// USB
@@ -36,6 +112,52 @@ void board_init(void) {
36112
// Debug UART
37113
common_hal_never_reset_pin(&pin_GPIO43);
38114
common_hal_never_reset_pin(&pin_GPIO44);
115+
116+
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
117+
common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL);
118+
common_hal_busio_spi_never_reset(spi);
119+
120+
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
121+
bus->base.type = &displayio_fourwire_type;
122+
common_hal_displayio_fourwire_construct(bus,
123+
spi,
124+
&pin_GPIO7, // EPD_DC Command or data
125+
&pin_GPIO8, // EPD_CS Chip select
126+
&pin_GPIO6, // EPD_RST Reset
127+
4000000, // Baudrate
128+
0, // Polarity
129+
0); // Phase
130+
131+
displayio_epaperdisplay_obj_t* display = &displays[0].epaper_display;
132+
display->base.type = &displayio_epaperdisplay_type;
133+
common_hal_displayio_epaperdisplay_construct(
134+
display,
135+
bus,
136+
display_start_sequence, sizeof(display_start_sequence),
137+
display_stop_sequence, sizeof(display_stop_sequence),
138+
296, // width
139+
128, // height
140+
160, // ram_width
141+
296, // ram_height
142+
0, // colstart
143+
0, // rowstart
144+
270, // rotation
145+
NO_COMMAND, // set_column_window_command
146+
NO_COMMAND, // set_row_window_command
147+
NO_COMMAND, // set_current_column_command
148+
NO_COMMAND, // set_current_row_command
149+
0x10, // write_black_ram_command
150+
false, // black_bits_inverted
151+
0x13, // write_color_ram_command
152+
false, // color_bits_inverted
153+
0x000000, // highlight_color
154+
0x12, // refresh_display_command
155+
1.0, // refresh_time
156+
&pin_GPIO5, // busy_pin
157+
false, // busy_state
158+
5.0, // seconds_per_frame
159+
false, // always_toggle_chip_select
160+
true); // grayscale
39161
}
40162

41163
bool board_requests_safe_mode(void) {

ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/pins.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "shared-bindings/board/__init__.h"
22

3+
#include "shared-module/displayio/__init__.h"
4+
35
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
46
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) },
57
{ MP_ROM_QSTR(MP_QSTR_AD1), MP_ROM_PTR(&pin_GPIO18) },
@@ -37,5 +39,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
3739

3840
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
3941
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
42+
43+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)}
4044
};
4145
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

ports/esp32s2/common-hal/displayio/ParallelBus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
5757
return false;
5858
}
5959

60-
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
60+
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type,
61+
display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) {
6162

6263
}
6364

ports/mimxrt10xx/common-hal/displayio/ParallelBus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
5757
return false;
5858
}
5959

60-
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
60+
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type,
61+
display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) {
6162

6263
}
6364

ports/nrf/common-hal/displayio/ParallelBus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
141141
}
142142

143143
// This ignores chip_select behaviour because data is clocked in by the write line toggling.
144-
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
144+
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type,
145+
display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) {
145146
displayio_parallelbus_obj_t* self = MP_OBJ_TO_PTR(obj);
146147
common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA);
147148
uint32_t* clear_write = (uint32_t*) &self->write_group->OUTCLR;

ports/stm/common-hal/displayio/ParallelBus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
5757
return false;
5858
}
5959

60-
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
60+
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type,
61+
display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) {
6162

6263
}
6364

py/circuitpy_mpconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ typedef long mp_off_t;
186186
#define MICROPY_CPYTHON_COMPAT (CIRCUITPY_FULL_BUILD)
187187
#define MICROPY_PY_BUILTINS_POW3 (CIRCUITPY_FULL_BUILD)
188188
#define MICROPY_COMP_FSTRING_LITERAL (MICROPY_CPYTHON_COMPAT)
189-
#define MICROPY_MODULE_WEAK_LINKS (CIRCUITPY_FULL_BUILD)
189+
#define MICROPY_MODULE_WEAK_LINKS (0)
190190
#define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD)
191191
#define MICROPY_PY_BUILTINS_COMPLEX (CIRCUITPY_FULL_BUILD)
192192
#define MICROPY_PY_BUILTINS_FROZENSET (CIRCUITPY_FULL_BUILD)

shared-bindings/displayio/EPaperDisplay.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,23 @@ const mp_obj_property_t displayio_epaperdisplay_time_to_refresh_obj = {
245245
(mp_obj_t)&mp_const_none_obj},
246246
};
247247

248+
//| busy: bool
249+
//| """True when the display is refreshing. This uses the ``busy_pin`` when available or the
250+
//| ``refresh_time`` otherwise."""
251+
//|
252+
STATIC mp_obj_t displayio_epaperdisplay_obj_get_busy(mp_obj_t self_in) {
253+
displayio_epaperdisplay_obj_t *self = native_display(self_in);
254+
return mp_obj_new_bool(common_hal_displayio_epaperdisplay_get_busy(self));
255+
}
256+
MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_get_busy_obj, displayio_epaperdisplay_obj_get_busy);
257+
258+
const mp_obj_property_t displayio_epaperdisplay_busy_obj = {
259+
.base.type = &mp_type_property,
260+
.proxy = {(mp_obj_t)&displayio_epaperdisplay_get_busy_obj,
261+
(mp_obj_t)&mp_const_none_obj,
262+
(mp_obj_t)&mp_const_none_obj},
263+
};
264+
248265
//| width: int
249266
//| """Gets the width of the display in pixels"""
250267
//|
@@ -301,6 +318,7 @@ STATIC const mp_rom_map_elem_t displayio_epaperdisplay_locals_dict_table[] = {
301318
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_epaperdisplay_width_obj) },
302319
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_epaperdisplay_height_obj) },
303320
{ MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_epaperdisplay_bus_obj) },
321+
{ MP_ROM_QSTR(MP_QSTR_busy), MP_ROM_PTR(&displayio_epaperdisplay_busy_obj) },
304322
{ MP_ROM_QSTR(MP_QSTR_time_to_refresh), MP_ROM_PTR(&displayio_epaperdisplay_time_to_refresh_obj) },
305323
};
306324
STATIC MP_DEFINE_CONST_DICT(displayio_epaperdisplay_locals_dict, displayio_epaperdisplay_locals_dict_table);

shared-bindings/displayio/EPaperDisplay.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern const mp_obj_type_t displayio_epaperdisplay_type;
3939
#define NO_COMMAND 0x100
4040

4141
void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t* self,
42-
mp_obj_t bus, uint8_t* start_sequence, uint16_t start_sequence_len, uint8_t* stop_sequence, uint16_t stop_sequence_len,
42+
mp_obj_t bus, const uint8_t* start_sequence, uint16_t start_sequence_len, const uint8_t* stop_sequence, uint16_t stop_sequence_len,
4343
uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation,
4444
uint16_t set_column_window_command, uint16_t set_row_window_command,
4545
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
5252

5353
// Returns time in milliseconds.
5454
uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaperdisplay_obj_t* self);
55+
bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t* self);
5556

5657
uint16_t common_hal_displayio_epaperdisplay_get_width(displayio_epaperdisplay_obj_t* self);
5758
uint16_t common_hal_displayio_epaperdisplay_get_height(displayio_epaperdisplay_obj_t* self);

shared-bindings/displayio/FourWire.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ bool common_hal_displayio_fourwire_bus_free(mp_obj_t self);
4848

4949
bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t self);
5050

51-
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);
51+
void common_hal_displayio_fourwire_send(mp_obj_t self, display_byte_type_t byte_type,
52+
display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length);
5253

5354
void common_hal_displayio_fourwire_end_transaction(mp_obj_t self);
5455

shared-bindings/displayio/I2CDisplay.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ bool common_hal_displayio_i2cdisplay_bus_free(mp_obj_t self);
4444

4545
bool common_hal_displayio_i2cdisplay_begin_transaction(mp_obj_t self);
4646

47-
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);
47+
void common_hal_displayio_i2cdisplay_send(mp_obj_t self, display_byte_type_t byte_type,
48+
display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length);
4849

4950
void common_hal_displayio_i2cdisplay_end_transaction(mp_obj_t self);
5051

shared-bindings/displayio/ParallelBus.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ bool common_hal_displayio_parallelbus_bus_free(mp_obj_t self);
4646

4747
bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t self);
4848

49-
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);
49+
void common_hal_displayio_parallelbus_send(mp_obj_t self, display_byte_type_t byte_type,
50+
display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length);
5051

5152
void common_hal_displayio_parallelbus_end_transaction(mp_obj_t self);
5253

shared-bindings/displayio/__init__.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ typedef enum {
4242
typedef bool (*display_bus_bus_reset)(mp_obj_t bus);
4343
typedef bool (*display_bus_bus_free)(mp_obj_t bus);
4444
typedef bool (*display_bus_begin_transaction)(mp_obj_t bus);
45-
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);
45+
typedef void (*display_bus_send)(mp_obj_t bus, display_byte_type_t byte_type,
46+
display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length);
4647
typedef void (*display_bus_end_transaction)(mp_obj_t bus);
4748

4849
void common_hal_displayio_release_displays(void);

shared-module/displayio/ColorConverter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ uint8_t displayio_colorconverter_compute_luma(uint32_t color_rgb888) {
5555
uint32_t r8 = (color_rgb888 >> 16);
5656
uint32_t g8 = (color_rgb888 >> 8) & 0xff;
5757
uint32_t b8 = color_rgb888 & 0xff;
58-
return (r8 * 19) / 255 + (g8 * 182) / 255 + (b8 + 54) / 255;
58+
return (r8 * 19 + g8 * 182 + b8 * 54) / 255;
5959
}
6060

6161
uint8_t displayio_colorconverter_compute_chroma(uint32_t color_rgb888) {

shared-module/displayio/EPaperDisplay.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
#include <string.h>
4444

4545
void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t* self,
46-
mp_obj_t bus, uint8_t* start_sequence, uint16_t start_sequence_len, uint8_t* stop_sequence, uint16_t stop_sequence_len,
46+
mp_obj_t bus, const uint8_t* start_sequence, uint16_t start_sequence_len,
47+
const uint8_t* stop_sequence, uint16_t stop_sequence_len,
4748
uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height,
4849
int16_t colstart, int16_t rowstart, uint16_t rotation,
4950
uint16_t set_column_window_command, uint16_t set_row_window_command,
@@ -133,14 +134,15 @@ STATIC void wait_for_busy(displayio_epaperdisplay_obj_t* self) {
133134
}
134135
}
135136

136-
STATIC void send_command_sequence(displayio_epaperdisplay_obj_t* self, bool should_wait_for_busy, uint8_t* sequence, uint32_t sequence_len) {
137+
STATIC void send_command_sequence(displayio_epaperdisplay_obj_t* self,
138+
bool should_wait_for_busy, const uint8_t* sequence, uint32_t sequence_len) {
137139
uint32_t i = 0;
138140
while (i < sequence_len) {
139-
uint8_t *cmd = sequence + i;
141+
const uint8_t *cmd = sequence + i;
140142
uint8_t data_size = *(cmd + 1);
141143
bool delay = (data_size & DELAY) != 0;
142144
data_size &= ~DELAY;
143-
uint8_t *data = cmd + 2;
145+
const uint8_t *data = cmd + 2;
144146
displayio_display_core_begin_transaction(&self->core);
145147
self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, cmd, 1);
146148
self->core.send(self->core.bus, DISPLAY_DATA, self->chip_select, data, data_size);
@@ -358,6 +360,11 @@ void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t* self) {
358360
}
359361
}
360362

363+
bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t* self) {
364+
displayio_epaperdisplay_background(self);
365+
return self->refreshing;
366+
}
367+
361368
void release_epaperdisplay(displayio_epaperdisplay_obj_t* self) {
362369
if (self->refreshing) {
363370
wait_for_busy(self);
@@ -375,8 +382,8 @@ void release_epaperdisplay(displayio_epaperdisplay_obj_t* self) {
375382

376383
void displayio_epaperdisplay_collect_ptrs(displayio_epaperdisplay_obj_t* self) {
377384
displayio_display_core_collect_ptrs(&self->core);
378-
gc_collect_ptr(self->start_sequence);
379-
gc_collect_ptr(self->stop_sequence);
385+
gc_collect_ptr((void *) self->start_sequence);
386+
gc_collect_ptr((void *) self->stop_sequence);
380387
}
381388

382389
bool maybe_refresh_epaperdisplay(void) {

shared-module/displayio/EPaperDisplay.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ typedef struct {
3838
displayio_display_core_t core;
3939
digitalio_digitalinout_obj_t busy;
4040
uint32_t milliseconds_per_frame;
41-
uint8_t* start_sequence;
41+
const uint8_t* start_sequence;
4242
uint32_t start_sequence_len;
43-
uint8_t* stop_sequence;
43+
const uint8_t* stop_sequence;
4444
uint32_t stop_sequence_len;
4545
uint16_t refresh_time;
4646
uint16_t set_column_window_command;

0 commit comments

Comments
 (0)