Skip to content

Commit 03ea81f

Browse files
authored
Merge pull request #10565 from tannewt/epd_refactor
Refactor EPaperDisplay args into struct
2 parents 3b1b700 + b739a86 commit 03ea81f

File tree

14 files changed

+452
-519
lines changed

14 files changed

+452
-519
lines changed

ports/atmel-samd/boards/openbook_m4/board.c

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,42 +53,24 @@ void board_init(void) {
5353

5454
epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
5555
display->base.type = &epaperdisplay_epaperdisplay_type;
56-
common_hal_epaperdisplay_epaperdisplay_construct(display,
57-
bus,
58-
start_sequence,
59-
sizeof(start_sequence),
60-
0, // start up time
61-
stop_sequence,
62-
sizeof(stop_sequence),
63-
300, // width
64-
400, // height
65-
300, // RAM width
66-
400, // RAM height
67-
0, // colstart
68-
0, // rowstart
69-
270, // rotation
70-
NO_COMMAND, // set_column_window_command
71-
NO_COMMAND, // set_row_window_command
72-
NO_COMMAND, // set_current_column_command
73-
NO_COMMAND, // set_current_row_command
74-
0x13, // write_black_ram_command
75-
false, // black_bits_inverted
76-
NO_COMMAND, // write_color_ram_command (can add this for grayscale eventually)
77-
false, // color_bits_inverted
78-
0x000000, // highlight_color
79-
0x000000, // highlight_color2
80-
refresh_sequence, // refresh_display_sequence
81-
sizeof(refresh_sequence),
82-
40, // refresh_time
83-
&pin_PA01, // busy_pin
84-
false, // busy_state
85-
5, // seconds_per_frame
86-
false, // chip_select (don't always toggle chip select)
87-
false, // grayscale
88-
false, // acep
89-
false, // spectra6
90-
false, // two_byte_sequence_length
91-
false); // address_little_endian
56+
epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
57+
args.bus = bus;
58+
args.start_sequence = start_sequence;
59+
args.start_sequence_len = sizeof(start_sequence);
60+
args.stop_sequence = stop_sequence;
61+
args.stop_sequence_len = sizeof(stop_sequence);
62+
args.width = 300;
63+
args.height = 400;
64+
args.ram_width = 300;
65+
args.ram_height = 400;
66+
args.rotation = 270;
67+
args.write_black_ram_command = 0x13;
68+
args.refresh_sequence = refresh_sequence;
69+
args.refresh_sequence_len = sizeof(refresh_sequence);
70+
args.refresh_time = 40.0;
71+
args.busy_pin = &pin_PA01;
72+
args.seconds_per_frame = 5.0;
73+
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
9274
}
9375

9476
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

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

Lines changed: 47 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -217,75 +217,54 @@ void board_init(void) {
217217
display->base.type = &epaperdisplay_epaperdisplay_type;
218218

219219
if (is_ssd1680) {
220-
common_hal_epaperdisplay_epaperdisplay_construct(
221-
display,
222-
bus,
223-
ssd1680_display_start_sequence, sizeof(ssd1680_display_start_sequence),
224-
0, // start up time
225-
ssd1680_display_stop_sequence, sizeof(ssd1680_display_stop_sequence),
226-
296, // width
227-
128, // height
228-
250, // ram_width
229-
296, // ram_height
230-
0, // colstart
231-
0, // rowstart
232-
270, // rotation
233-
0x44, // set_column_window_command
234-
0x45, // set_row_window_command
235-
0x4e, // set_current_column_command
236-
0x4f, // set_current_row_command
237-
0x24, // write_black_ram_command
238-
false, // black_bits_inverted
239-
0x26, // write_color_ram_command
240-
false, // color_bits_inverted
241-
0x000000, // highlight_color
242-
0x000000, // highlight_color2
243-
ssd1680_display_refresh_sequence, sizeof(ssd1680_display_refresh_sequence),
244-
1.0, // refresh_time
245-
&pin_GPIO5, // busy_pin
246-
true, // busy_state
247-
5.0, // seconds_per_frame
248-
false, // always_toggle_chip_select
249-
true, // grayscale
250-
false, // acep
251-
false, // spectra6
252-
true, // two_byte_sequence_length
253-
true); // address_little_endian
220+
epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
221+
args.bus = bus;
222+
args.start_sequence = ssd1680_display_start_sequence;
223+
args.start_sequence_len = sizeof(ssd1680_display_start_sequence);
224+
args.stop_sequence = ssd1680_display_stop_sequence;
225+
args.stop_sequence_len = sizeof(ssd1680_display_stop_sequence);
226+
args.width = 296;
227+
args.height = 128;
228+
args.ram_width = 250;
229+
args.ram_height = 296;
230+
args.rotation = 270;
231+
args.set_column_window_command = 0x44;
232+
args.set_row_window_command = 0x45;
233+
args.set_current_column_command = 0x4e;
234+
args.set_current_row_command = 0x4f;
235+
args.write_black_ram_command = 0x24;
236+
args.write_color_ram_command = 0x26;
237+
args.refresh_sequence = ssd1680_display_refresh_sequence;
238+
args.refresh_sequence_len = sizeof(ssd1680_display_refresh_sequence);
239+
args.refresh_time = 1.0;
240+
args.busy_pin = &pin_GPIO5;
241+
args.busy_state = true;
242+
args.seconds_per_frame = 5.0;
243+
args.grayscale = true;
244+
args.two_byte_sequence_length = true;
245+
args.address_little_endian = true;
246+
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
254247
} else {
255-
common_hal_epaperdisplay_epaperdisplay_construct(
256-
display,
257-
bus,
258-
il0373_display_start_sequence, sizeof(il0373_display_start_sequence),
259-
0, // start up time
260-
il0373_display_stop_sequence, sizeof(il0373_display_stop_sequence),
261-
296, // width
262-
128, // height
263-
160, // ram_width
264-
296, // ram_height
265-
0, // colstart
266-
0, // rowstart
267-
270, // rotation
268-
NO_COMMAND, // set_column_window_command
269-
NO_COMMAND, // set_row_window_command
270-
NO_COMMAND, // set_current_column_command
271-
NO_COMMAND, // set_current_row_command
272-
0x10, // write_black_ram_command
273-
false, // black_bits_inverted
274-
0x13, // write_color_ram_command
275-
false, // color_bits_inverted
276-
0x000000, // highlight_color
277-
0x000000, // highlight_color2
278-
il0373_display_refresh_sequence, sizeof(il0373_display_refresh_sequence),
279-
1.0, // refresh_time
280-
&pin_GPIO5, // busy_pin
281-
false, // busy_state
282-
5.0, // seconds_per_frame
283-
false, // always_toggle_chip_select
284-
true, // grayscale
285-
false, // acep
286-
false, // spectra6
287-
false, // two_byte_sequence_length
288-
false); // address_little_endian
248+
epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
249+
args.bus = bus;
250+
args.start_sequence = il0373_display_start_sequence;
251+
args.start_sequence_len = sizeof(il0373_display_start_sequence);
252+
args.stop_sequence = il0373_display_stop_sequence;
253+
args.stop_sequence_len = sizeof(il0373_display_stop_sequence);
254+
args.width = 296;
255+
args.height = 128;
256+
args.ram_width = 160;
257+
args.ram_height = 296;
258+
args.rotation = 270;
259+
args.write_black_ram_command = 0x10;
260+
args.write_color_ram_command = 0x13;
261+
args.refresh_sequence = il0373_display_refresh_sequence;
262+
args.refresh_sequence_len = sizeof(il0373_display_refresh_sequence);
263+
args.refresh_time = 1.0;
264+
args.busy_pin = &pin_GPIO5;
265+
args.seconds_per_frame = 5.0;
266+
args.grayscale = true;
267+
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
289268
}
290269
}
291270

ports/espressif/boards/elecrow_crowpanel_4_2_epaper/board.c

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -63,43 +63,30 @@ void board_init(void) {
6363
0, // Polarity
6464
0); // Phase
6565

66-
// Set up the DisplayIO epaper object
66+
// Set up the DisplayIO epaper object
6767
epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
6868
display->base.type = &epaperdisplay_epaperdisplay_type;
69-
common_hal_epaperdisplay_epaperdisplay_construct(
70-
display,
71-
bus,
72-
display_start_sequence, sizeof(display_start_sequence),
73-
1, // start up time
74-
display_stop_sequence, sizeof(display_stop_sequence),
75-
400, // width
76-
300, // height
77-
400, // ram_width
78-
300, // ram_height
79-
0, // colstart
80-
0, // rowstart
81-
0, // rotation
82-
NO_COMMAND, // set_column_window_command
83-
NO_COMMAND, // set_row_window_command
84-
NO_COMMAND, // set_current_column_command
85-
NO_COMMAND, // set_current_row_command
86-
0x24, // write_black_ram_command
87-
false, // black_bits_inverted
88-
0x26, // write_color_ram_command
89-
false, // color_bits_inverted
90-
0x000000, // highlight_color
91-
0x000000, // highlight_color2
92-
refresh_sequence, sizeof(refresh_sequence), // refresh_display_command
93-
1.0, // refresh_time
94-
&pin_GPIO48, // busy_pin
95-
true, // busy_state
96-
2.0, // seconds_per_frame
97-
false, // always_toggle_chip_select
98-
false, // grayscale
99-
false, // acep
100-
false, // spectra6
101-
false, // two_byte_sequence_length
102-
false); // address_little_endian
69+
70+
epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
71+
args.bus = bus;
72+
args.start_sequence = display_start_sequence;
73+
args.start_sequence_len = sizeof(display_start_sequence);
74+
args.start_up_time = 1.0;
75+
args.stop_sequence = display_stop_sequence;
76+
args.stop_sequence_len = sizeof(display_stop_sequence);
77+
args.width = 400;
78+
args.height = 300;
79+
args.ram_width = 400;
80+
args.ram_height = 300;
81+
args.write_black_ram_command = 0x24;
82+
args.write_color_ram_command = 0x26;
83+
args.refresh_sequence = refresh_sequence;
84+
args.refresh_sequence_len = sizeof(refresh_sequence);
85+
args.refresh_time = 1.0;
86+
args.busy_pin = &pin_GPIO48;
87+
args.busy_state = true;
88+
args.seconds_per_frame = 2.0;
89+
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
10390
}
10491

10592
void board_deinit(void) {

ports/espressif/boards/heltec_vision_master_e290/board.c

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -61,43 +61,37 @@ void board_init(void) {
6161
0, // Polarity
6262
0); // Phase
6363

64-
// Set up the DisplayIO epaper object
64+
// Set up the DisplayIO epaper object
6565
epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
6666
display->base.type = &epaperdisplay_epaperdisplay_type;
67-
common_hal_epaperdisplay_epaperdisplay_construct(
68-
display,
69-
bus,
70-
display_start_sequence, sizeof(display_start_sequence),
71-
0, // start up time
72-
display_stop_sequence, sizeof(display_stop_sequence),
73-
296, // width
74-
128, // height
75-
250, // ram_width
76-
296, // ram_height
77-
8, // colstart
78-
0, // rowstart
79-
90, // rotation
80-
0x44, // set_column_window_command
81-
0x45, // set_row_window_command
82-
0x4E, // set_current_column_command
83-
0x4F, // set_current_row_command
84-
0x24, // write_black_ram_command
85-
false, // black_bits_inverted
86-
0x26, // write_color_ram_command
87-
false, // color_bits_inverted
88-
0xFF0000, // highlight_color
89-
0x000000, // highlight_color2
90-
refresh_sequence, sizeof(refresh_sequence), // refresh_display_command
91-
1.0, // refresh_time
92-
&pin_GPIO6, // busy_pin
93-
true, // busy_state
94-
2.0, // seconds_per_frame
95-
false, // always_toggle_chip_select
96-
false, // grayscale
97-
false, // acep
98-
false, // spectra6
99-
false, // two_byte_sequence_length
100-
true); // address_little_endian
67+
68+
epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
69+
args.bus = bus;
70+
args.start_sequence = display_start_sequence;
71+
args.start_sequence_len = sizeof(display_start_sequence);
72+
args.stop_sequence = display_stop_sequence;
73+
args.stop_sequence_len = sizeof(display_stop_sequence);
74+
args.width = 296;
75+
args.height = 128;
76+
args.ram_width = 250;
77+
args.ram_height = 296;
78+
args.colstart = 8;
79+
args.rotation = 90;
80+
args.set_column_window_command = 0x44;
81+
args.set_row_window_command = 0x45;
82+
args.set_current_column_command = 0x4E;
83+
args.set_current_row_command = 0x4F;
84+
args.write_black_ram_command = 0x24;
85+
args.write_color_ram_command = 0x26;
86+
args.highlight_color = 0xFF0000;
87+
args.refresh_sequence = refresh_sequence;
88+
args.refresh_sequence_len = sizeof(refresh_sequence);
89+
args.refresh_time = 1.0;
90+
args.busy_pin = &pin_GPIO6;
91+
args.busy_state = true;
92+
args.seconds_per_frame = 2.0;
93+
args.address_little_endian = true;
94+
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
10195
}
10296

10397
void board_deinit(void) {

ports/espressif/boards/heltec_wireless_paper/board.c

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -101,43 +101,29 @@ void board_init(void) {
101101
0, // Polarity
102102
0); // Phase
103103

104-
// Set up the DisplayIO epaper object
104+
// Set up the DisplayIO epaper object
105105
epaperdisplay_epaperdisplay_obj_t *display = &allocate_display()->epaper_display;
106106
display->base.type = &epaperdisplay_epaperdisplay_type;
107-
common_hal_epaperdisplay_epaperdisplay_construct(
108-
display,
109-
bus,
110-
display_start_sequence, sizeof(display_start_sequence),
111-
0, // start up time
112-
display_stop_sequence, sizeof(display_stop_sequence),
113-
250, // width
114-
122, // height
115-
128, // ram_width
116-
296, // ram_height
117-
0, // colstart
118-
0, // rowstart
119-
270, // rotation
120-
NO_COMMAND, // set_column_window_command
121-
NO_COMMAND, // set_row_window_command
122-
NO_COMMAND, // set_current_column_command
123-
NO_COMMAND, // set_current_row_command
124-
0x13, // write_black_ram_command
125-
false, // black_bits_inverted
126-
0x10, // write_color_ram_command
127-
false, // color_bits_inverted
128-
0x000000, // highlight_color
129-
0x000000, // highlight_color2
130-
refresh_sequence, sizeof(refresh_sequence), // refresh_display_command
131-
1.0, // refresh_time
132-
&pin_GPIO7, // busy_pin
133-
false, // busy_state
134-
2.0, // seconds_per_frame
135-
false, // always_toggle_chip_select
136-
false, // grayscale
137-
false, // acep
138-
false, // spectra6
139-
false, // two_byte_sequence_length
140-
false); // address_little_endian
107+
108+
epaperdisplay_construct_args_t args = EPAPERDISPLAY_CONSTRUCT_ARGS_DEFAULTS;
109+
args.bus = bus;
110+
args.start_sequence = display_start_sequence;
111+
args.start_sequence_len = sizeof(display_start_sequence);
112+
args.stop_sequence = display_stop_sequence;
113+
args.stop_sequence_len = sizeof(display_stop_sequence);
114+
args.width = 250;
115+
args.height = 122;
116+
args.ram_width = 128;
117+
args.ram_height = 296;
118+
args.rotation = 270;
119+
args.write_black_ram_command = 0x13;
120+
args.write_color_ram_command = 0x10;
121+
args.refresh_sequence = refresh_sequence;
122+
args.refresh_sequence_len = sizeof(refresh_sequence);
123+
args.refresh_time = 1.0;
124+
args.busy_pin = &pin_GPIO7;
125+
args.seconds_per_frame = 2.0;
126+
common_hal_epaperdisplay_epaperdisplay_construct(display, &args);
141127
}
142128

143129
void board_deinit(void) {

0 commit comments

Comments
 (0)